Spaces:
Sleeping
Sleeping
| export const CHATBOT_CONFIG = { | |
| name: process.env.NEXT_PUBLIC_CHATBOT_NAME || "EMA", | |
| caption: process.env.NEXT_PUBLIC_CHATBOT_CAPTION || "Expert Mining Assistant", | |
| description: process.env.NEXT_PUBLIC_CHATBOT_DESCRIPTION || "Saya EMA, Expert Mining Assistant. Saya siap membantu kamu menganalisis data equipment dan menjawab pertanyaan seputar operasional tambang.", | |
| }; | |
| export type ChatbotConfig = typeof CHATBOT_CONFIG; | |
| // Function to load from localStorage with defaults | |
| export const getChatbotConfig = (): ChatbotConfig => { | |
| if (typeof window === "undefined") return CHATBOT_CONFIG; | |
| const stored = localStorage.getItem("ema-chatbot-config"); | |
| if (!stored) return CHATBOT_CONFIG; | |
| try { | |
| return { ...CHATBOT_CONFIG, ...JSON.parse(stored) }; | |
| } catch { | |
| return CHATBOT_CONFIG; | |
| } | |
| }; | |
| // Function to save to localStorage | |
| export const saveChatbotConfig = (config: Partial<ChatbotConfig>) => { | |
| if (typeof window === "undefined") return; | |
| const current = getChatbotConfig(); | |
| localStorage.setItem("ema-chatbot-config", JSON.stringify({ ...current, ...config })); | |
| }; | |
| // Function to reset to defaults | |
| export const resetChatbotConfig = () => { | |
| if (typeof window === "undefined") return; | |
| localStorage.removeItem("ema-chatbot-config"); | |
| }; | |