import React, { useState, useEffect } from 'react'; const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = ({ closeSettings, accountName }) => { const [activeSection, setActiveSection] = useState('general'); // Theme settings state const [backgroundColor, setBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--background-color').trim()); const [textColor, setTextColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--text-color').trim()); const [inputBackgroundColor, setInputBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--input-background-color').trim()); const [inputButtonColor, setInputButtonColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--input-button-color').trim()); const [inputButtonHoverColor, setInputButtonHoverColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--input-button-hover-color').trim()); const [userMessageBackgroundColor, setUserMessageBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--user-message-background-color').trim()); const [userMessageTextColor, setUserMessageTextColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--user-message-text-color').trim()); const [aiMessageBackgroundColor, setAiMessageBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--ai-message-background-color').trim()); const [aiMessageTextColor, setAiMessageTextColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--ai-message-text-color').trim()); const [buttonBackgroundColor, setButtonBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--button-background-color').trim()); const [buttonHoverBackgroundColor, setButtonHoverBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--button-hover-background-color').trim()); const [modelsBackgroundColor, setModelsBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--models-background-color').trim()); const [historyBackgroundColor, setHistoryBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--history-background-color').trim()); const [leftPanelBackgroundColor, setLeftPanelBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--left-panel-background-color').trim()); const [conversationBackgroundColor, setConversationBackgroundColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--conversation-background-color').trim()); const [popUpTextColor, setPopUpTextColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--pop-up-text').trim()); const [inputBorderColor, setInputBorderColor] = useState(getComputedStyle(document.documentElement).getPropertyValue('--input-border-color').trim()); const [fontFamily, setFontFamily] = useState(getComputedStyle(document.documentElement).getPropertyValue('--font-family').trim()); const [fontSize, setFontSize] = useState(getComputedStyle(document.documentElement).getPropertyValue('--font-size').trim()); // General settings state const [preferredLanguage, setPreferredLanguage] = useState('English'); const [preferredCurrency, setPreferredCurrency] = useState('USD'); const [dateFormat, setDateFormat] = useState('MM/DD/YYYY'); const [timeFormat, setTimeFormat] = useState('12-hour'); const [timeZone, setTimeZone] = useState('UTC'); // Privacy settings state const [disableOnlineAI, setDisableOnlineAI] = useState(false); const [disableChatHistory, setDisableChatHistory] = useState(false); const [disableAIMemory, setDisableAIMemory] = useState(false); // FOSS settings state const [openSourceMode, setOpenSourceMode] = useState(false); // Account settings state const [newName, setNewName] = useState(''); const [newEmail, setNewEmail] = useState(''); const [newPassword, setNewPassword] = useState(''); // Effect to update CSS variables on theme state change useEffect(() => { document.documentElement.style.setProperty('--background-color', backgroundColor); document.documentElement.style.setProperty('--text-color', textColor); document.documentElement.style.setProperty('--input-background-color', inputBackgroundColor); document.documentElement.style.setProperty('--input-button-color', inputButtonColor); document.documentElement.style.setProperty('--input-button-hover-color', inputButtonHoverColor); document.documentElement.style.setProperty('--user-message-background-color', userMessageBackgroundColor); document.documentElement.style.setProperty('--user-message-text-color', userMessageTextColor); document.documentElement.style.setProperty('--ai-message-background-color', aiMessageBackgroundColor); document.documentElement.style.setProperty('--ai-message-text-color', aiMessageTextColor); document.documentElement.style.setProperty('--button-background-color', buttonBackgroundColor); document.documentElement.style.setProperty('--button-hover-background-color', buttonHoverBackgroundColor); document.documentElement.style.setProperty('--models-background-color', modelsBackgroundColor); document.documentElement.style.setProperty('--history-background-color', historyBackgroundColor); document.documentElement.style.setProperty('--left-panel-background-color', leftPanelBackgroundColor); document.documentElement.style.setProperty('--conversation-background-color', conversationBackgroundColor); document.documentElement.style.setProperty('--pop-up-text', popUpTextColor); document.documentElement.style.setProperty('--input-border-color', inputBorderColor); document.documentElement.style.setProperty('--font-family', fontFamily); document.documentElement.style.setProperty('--font-size', fontSize); }, [ backgroundColor, textColor, inputBackgroundColor, inputButtonColor, inputButtonHoverColor, userMessageBackgroundColor, userMessageTextColor, aiMessageBackgroundColor, aiMessageTextColor, buttonBackgroundColor, buttonHoverBackgroundColor, modelsBackgroundColor, historyBackgroundColor, leftPanelBackgroundColor, conversationBackgroundColor, popUpTextColor, inputBorderColor, fontFamily, fontSize ]); const renderSettingsContent = () => { switch (activeSection) { case 'general': return (

General Settings

setPreferredLanguage(e.target.value)} />
setPreferredCurrency(e.target.value)} />
setDateFormat(e.target.value)} />
setTimeFormat(e.target.value)} />
setTimeZone(e.target.value)} />
); case 'privacy': return (

Privacy Settings

); case 'theme': return (

Theme Settings

Font Size

{ const newSize = `${e.target.value}px`; setFontSize(newSize); document.documentElement.style.setProperty('--font-size', newSize); // Update the CSS variable }} /> {fontSize}

Background Color

setBackgroundColor(e.target.value)} />

Text Color

setTextColor(e.target.value)} />

Input Background Color

setInputBackgroundColor(e.target.value)} />

Input Button Color

setInputButtonColor(e.target.value)} />

Input Button Hover Color

setInputButtonHoverColor(e.target.value)} />

User Message Background Color

setUserMessageBackgroundColor(e.target.value)} />

User Message Text Color

setUserMessageTextColor(e.target.value)} />

AI Message Background Color

setAiMessageBackgroundColor(e.target.value)} />

AI Message Text Color

setAiMessageTextColor(e.target.value)} />

Button Background Color

setButtonBackgroundColor(e.target.value)} />

Button Hover Background Color

setButtonHoverBackgroundColor(e.target.value)} />

Models Background Color

setModelsBackgroundColor(e.target.value)} />

History Background Color

setHistoryBackgroundColor(e.target.value)} />

Left Panel Background Color

setLeftPanelBackgroundColor(e.target.value)} />

Conversation Background Color

setConversationBackgroundColor(e.target.value)} />

Pop-up Text Color

setPopUpTextColor(e.target.value)} />

Input Border Color

setInputBorderColor(e.target.value)} />

Font Family

); case 'foss': return (

FOSS Settings

(ONLY OPEN SOURCE MODULES WORK IN THERE)

); case 'account': return (

Account Settings

setNewName(e.target.value)} />
setNewEmail(e.target.value)} />
setNewPassword(e.target.value)} />

DANGER ZONE

); default: return null; } }; return (
  • setActiveSection('general')}>General
  • setActiveSection('privacy')}>Privacy
  • setActiveSection('theme')}>Theme
  • setActiveSection('foss')}>FOSS
  • setActiveSection('account')}>Account

Settings for {accountName}

{renderSettingsContent()}
); }; export default Settings;