forked from React-Group/interstellar_ai
made eslint happy
This commit is contained in:
parent
90af1ae147
commit
a8064509d0
7 changed files with 58 additions and 71 deletions
|
@ -55,7 +55,7 @@ const Login: React.FC = () => {
|
||||||
const success = await checkCredentials(accountName, password);
|
const success = await checkCredentials(accountName, password);
|
||||||
if (success) {
|
if (success) {
|
||||||
setIsLoggedIn(true); // Successful login
|
setIsLoggedIn(true); // Successful login
|
||||||
var data = await getData(accountName, password)
|
const data = await getData(accountName, password)
|
||||||
if (data) {
|
if (data) {
|
||||||
localStorage.setItem("dataFromServer", data)
|
localStorage.setItem("dataFromServer", data)
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ const Login: React.FC = () => {
|
||||||
|
|
||||||
{/* Text for creating an account */}
|
{/* Text for creating an account */}
|
||||||
<p>
|
<p>
|
||||||
Don't have an account yet? Create one{' '}
|
Don't have an account yet? Create one{' '}
|
||||||
<span
|
<span
|
||||||
style={{ color: 'blue', cursor: 'pointer' }}
|
style={{ color: 'blue', cursor: 'pointer' }}
|
||||||
onClick={toggleSignUpPopup}
|
onClick={toggleSignUpPopup}
|
||||||
|
|
|
@ -173,10 +173,10 @@ const ModelSection: React.FC = () => {
|
||||||
const [radioSelection, setRadioSelection] = useState<string | null>("")
|
const [radioSelection, setRadioSelection] = useState<string | null>("")
|
||||||
const [activeSelectedAIFunction, setActiveSelectedAIFunction] = useState('');
|
const [activeSelectedAIFunction, setActiveSelectedAIFunction] = useState('');
|
||||||
const [currentSelectedAIFunction, setCurrentSelectedAIFunction] = useState<string | null>("");
|
const [currentSelectedAIFunction, setCurrentSelectedAIFunction] = useState<string | null>("");
|
||||||
const [isOpenSourceMode, setIsOpenSourceMode] = useState(localStorage.getItem('openSourceMode') || "false")
|
const [isOpenSourceMode] = useState(localStorage.getItem('openSourceMode') || "false")
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
var temp = localStorage.getItem("activeSelectedAIFunction") || ""
|
const temp = localStorage.getItem("activeSelectedAIFunction") || ""
|
||||||
setActiveSelectedAIFunction(temp)
|
setActiveSelectedAIFunction(temp)
|
||||||
if (!localStorage.getItem('selectedModelDropdown')) {
|
if (!localStorage.getItem('selectedModelDropdown')) {
|
||||||
localStorage.setItem("selectedModelDropdown", "Offline Fast")
|
localStorage.setItem("selectedModelDropdown", "Offline Fast")
|
||||||
|
@ -215,7 +215,7 @@ const ModelSection: React.FC = () => {
|
||||||
}, []); // Dependency array can remain empty if you only want this to run on mount
|
}, []); // Dependency array can remain empty if you only want this to run on mount
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
var storedActiveSelectedAIFunction = localStorage.getItem("activeSelectedAIFunction") || "";
|
const storedActiveSelectedAIFunction = localStorage.getItem("activeSelectedAIFunction") || "";
|
||||||
if (storedActiveSelectedAIFunction !== currentSelectedAIFunction) {
|
if (storedActiveSelectedAIFunction !== currentSelectedAIFunction) {
|
||||||
setCurrentSelectedAIFunction(storedActiveSelectedAIFunction);
|
setCurrentSelectedAIFunction(storedActiveSelectedAIFunction);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ const ModelSection: React.FC = () => {
|
||||||
const newModel = event.target.value;
|
const newModel = event.target.value;
|
||||||
setSelectedModelDropdown(newModel);
|
setSelectedModelDropdown(newModel);
|
||||||
localStorage.setItem('selectedModelDropdown', newModel); // Update localStorage directly
|
localStorage.setItem('selectedModelDropdown', newModel); // Update localStorage directly
|
||||||
var model = localStorage.getItem('activeSelectedAIFunction') || "Code"
|
const model = localStorage.getItem('activeSelectedAIFunction') || "Code"
|
||||||
modelClicked(model)
|
modelClicked(model)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ const ModelSection: React.FC = () => {
|
||||||
const modelClicked = (model: string) => {
|
const modelClicked = (model: string) => {
|
||||||
localStorage.setItem('activeSelectedAIFunction', model)
|
localStorage.setItem('activeSelectedAIFunction', model)
|
||||||
setActiveSelectedAIFunction(model)
|
setActiveSelectedAIFunction(model)
|
||||||
var modelDropdown = localStorage.getItem('selectedModelDropdown') || 'Offline Fast'
|
const modelDropdown = localStorage.getItem('selectedModelDropdown') || 'Offline Fast'
|
||||||
const selectedAIFunction = modelDropdown as keyof typeof modelList;
|
const selectedAIFunction = modelDropdown as keyof typeof modelList;
|
||||||
localStorage.setItem("model", modelList[selectedAIFunction][model as keyof typeof modelList[typeof selectedAIFunction]])
|
localStorage.setItem("model", modelList[selectedAIFunction][model as keyof typeof modelList[typeof selectedAIFunction]])
|
||||||
localStorage.setItem("type", modelList[selectedAIFunction]['model_type' as keyof typeof modelList[typeof selectedAIFunction]])
|
localStorage.setItem("type", modelList[selectedAIFunction]['model_type' as keyof typeof modelList[typeof selectedAIFunction]])
|
||||||
|
|
|
@ -6,12 +6,12 @@ interface ButtonSettingProps {
|
||||||
className?: string; // Optional additional classes for styling
|
className?: string; // Optional additional classes for styling
|
||||||
}
|
}
|
||||||
|
|
||||||
const ButtonSetting: React.FC<ButtonSettingProps> = ({ label, onClick, className }) => {
|
const ButtonSetting: React.FC<ButtonSettingProps> = ({ label, onClick }) => {
|
||||||
return (
|
return (
|
||||||
<div className="settings-option">
|
<div className="settings-option">
|
||||||
<button
|
<button
|
||||||
onClick={onClick} // Call the onClick function when the button is clicked
|
onClick={onClick} // Call the onClick function when the button is clicked
|
||||||
className={className="export-button"} // Apply any additional classes
|
className={"export-button"} // Apply any additional classes
|
||||||
>
|
>
|
||||||
{label} {/* Display the label on the button */}
|
{label} {/* Display the label on the button */}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// ThemeDropdown.tsx
|
// ThemeDropdown.tsx
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { applyTheme, applyCustomTheme } from './theme';
|
|
||||||
|
|
||||||
const ThemeDropdown: React.FC<{
|
const ThemeDropdown: React.FC<{
|
||||||
selectedTheme: string;
|
selectedTheme: string;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { applyTheme, applyCustomTheme } from './theme';
|
import { applyTheme } from './theme';
|
||||||
import { exportSettings, importSettings } from './settingUtils'; // Import utility functions
|
import { exportSettings, importSettings } from './settingUtils'; // Import utility functions
|
||||||
import { getAllLocalStorageItems } from '../../backend/GetLocalStorage';
|
import { getAllLocalStorageItems } from '../../backend/GetLocalStorage';
|
||||||
import ColorSetting from './ColorSettings';
|
import ColorSetting from './ColorSettings';
|
||||||
|
@ -14,7 +14,6 @@ import {
|
||||||
changeData,
|
changeData,
|
||||||
createAccount,
|
createAccount,
|
||||||
deleteAccount,
|
deleteAccount,
|
||||||
getData,
|
|
||||||
} from '../../backend/database';
|
} from '../../backend/database';
|
||||||
import ThemeDropdown from './DropDownTheme';
|
import ThemeDropdown from './DropDownTheme';
|
||||||
|
|
||||||
|
@ -35,12 +34,6 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
return false; // Default to false if item is null or empty
|
return false; // Default to false if item is null or empty
|
||||||
};
|
};
|
||||||
|
|
||||||
interface SettingsProps {
|
|
||||||
closeSettings: () => void;
|
|
||||||
accountName: string;
|
|
||||||
handleLogout: () => void; // Add this line to accept handleLogout as a prop
|
|
||||||
}
|
|
||||||
|
|
||||||
// Active section
|
// Active section
|
||||||
const [activeSection, setActiveSection] = useState(() => localStorage.getItem('activeSection') || 'general');
|
const [activeSection, setActiveSection] = useState(() => localStorage.getItem('activeSection') || 'general');
|
||||||
|
|
||||||
|
@ -65,7 +58,6 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
const [newName, setNewName] = useState(() => localStorage.getItem('newName') || '');
|
const [newName, setNewName] = useState(() => localStorage.getItem('newName') || '');
|
||||||
const [newEmail, setNewEmail] = useState(() => localStorage.getItem('newEmail') || '');
|
const [newEmail, setNewEmail] = useState(() => localStorage.getItem('newEmail') || '');
|
||||||
const [newPassword, setNewPassword] = useState(() => localStorage.getItem('newPassword') || '');
|
const [newPassword, setNewPassword] = useState(() => localStorage.getItem('newPassword') || '');
|
||||||
const [currentPassword, setCurrentPassword] = useState('');
|
|
||||||
|
|
||||||
// Measurement setting
|
// Measurement setting
|
||||||
const [preferredMeasurement, setPreferredMeasurement] = useState(() => localStorage.getItem('preferredMeasurement') || 'Metric');
|
const [preferredMeasurement, setPreferredMeasurement] = useState(() => localStorage.getItem('preferredMeasurement') || 'Metric');
|
||||||
|
@ -91,7 +83,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
const [inputBorderColor, setInputBorderColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--input-border-color').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 [fontFamily, setFontFamily] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-family').trim());
|
||||||
const [fontSize, setFontSize] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-size').trim());
|
const [fontSize, setFontSize] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--font-size').trim());
|
||||||
const [burgerMenu, setBurgerMenu] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color').trim());
|
const [burgerMenu] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color').trim());
|
||||||
const [burgerMenuBackgroundColor, setBurgerMenuBackgroundColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color').trim());
|
const [burgerMenuBackgroundColor, setBurgerMenuBackgroundColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--burger-menu-background-color').trim());
|
||||||
const [faqBackgroundColor, setFaqBackgroundColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--faq-background-color').trim());
|
const [faqBackgroundColor, setFaqBackgroundColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--faq-background-color').trim());
|
||||||
const [faqHeadingColor, setFaqHeadingColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--faq-heading-color').trim());
|
const [faqHeadingColor, setFaqHeadingColor] = useState(() => getComputedStyle(document.documentElement).getPropertyValue('--faq-heading-color').trim());
|
||||||
|
@ -122,7 +114,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
const [openai, setOpenai] = useState(localStorage.getItem('openai') || "");
|
const [openai, setOpenai] = useState(localStorage.getItem('openai') || "");
|
||||||
const [anthropic, setAnthropic] = useState(localStorage.getItem('anthropic') || "");
|
const [anthropic, setAnthropic] = useState(localStorage.getItem('anthropic') || "");
|
||||||
const [google, setGoogle] = useState(localStorage.getItem('google') || "");
|
const [google, setGoogle] = useState(localStorage.getItem('google') || "");
|
||||||
const [myBoolean, setMyBoolean] = useState<boolean | any>(() => getItemFromLocalStorage('myBoolean'));
|
const [myBoolean, setMyBoolean] = useState<boolean>(() => getItemFromLocalStorage('myBoolean'));
|
||||||
|
|
||||||
const settings = {
|
const settings = {
|
||||||
userPreferences: {
|
userPreferences: {
|
||||||
|
@ -344,9 +336,9 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
|
|
||||||
// Function to handle updating all credentials
|
// Function to handle updating all credentials
|
||||||
const handleUpdateCredentials = async () => {
|
const handleUpdateCredentials = async () => {
|
||||||
var useName = localStorage.getItem("accountName")
|
let useName = localStorage.getItem("accountName")
|
||||||
var useEmail = localStorage.getItem("accountEmail")
|
let useEmail = localStorage.getItem("accountEmail")
|
||||||
var usePassword = localStorage.getItem("accountPassword")
|
let usePassword = localStorage.getItem("accountPassword")
|
||||||
if (useName && useEmail && usePassword) {
|
if (useName && useEmail && usePassword) {
|
||||||
await deleteAccount(useName, usePassword)
|
await deleteAccount(useName, usePassword)
|
||||||
|
|
||||||
|
@ -372,8 +364,8 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
||||||
|
|
||||||
// Function to handle account deletion
|
// Function to handle account deletion
|
||||||
const handleDeleteAccount = async () => {
|
const handleDeleteAccount = async () => {
|
||||||
var useName = localStorage.getItem("accountName")
|
const useName = localStorage.getItem("accountName")
|
||||||
var usePassword = localStorage.getItem("accountPassword")
|
const usePassword = localStorage.getItem("accountPassword")
|
||||||
if (useName && usePassword) {
|
if (useName && usePassword) {
|
||||||
const success = await deleteAccount(useName, usePassword);
|
const success = await deleteAccount(useName, usePassword);
|
||||||
if (success) {
|
if (success) {
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
// Method to export localStorage to a JSON object
|
// Method to export localStorage to a JSON object
|
||||||
export function exportSettings(): string {
|
export function exportSettings(): string {
|
||||||
const settings: { [key: string]: any } = {};
|
const settings: { [key: string]: string } = {};
|
||||||
|
|
||||||
// Loop through all keys in localStorage and add them to the settings object
|
// Loop through all keys in localStorage and add them to the settings object
|
||||||
for (let i = 0; i < localStorage.length; i++) {
|
for (let i = 0; i < localStorage.length; i++) {
|
||||||
const key = localStorage.key(i);
|
const key = localStorage.key(i);
|
||||||
if (key) {
|
if (key) {
|
||||||
if (key !== "accountName" && key !== "accountPassword" && key !== "accountEmail") {
|
if (key !== "accountName" && key !== "accountPassword" && key !== "accountEmail") {
|
||||||
settings[key] = localStorage.getItem(key);
|
settings[key] = localStorage.getItem(key) || "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,10 @@ const LandingPage: React.FC = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [selectedTheme, setSelectedTheme] = useState<string>('');
|
|
||||||
|
|
||||||
// Apply theme based on selectedTheme and color settings
|
// Apply theme based on selectedTheme and color settings
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const savedTheme = localStorage.getItem('selectedTheme');
|
const savedTheme = localStorage.getItem('selectedTheme');
|
||||||
if (savedTheme) {
|
if (savedTheme) {
|
||||||
setSelectedTheme(savedTheme);
|
|
||||||
switch (savedTheme) {
|
switch (savedTheme) {
|
||||||
case 'IOMARKET':
|
case 'IOMARKET':
|
||||||
applyIOMarketTheme();
|
applyIOMarketTheme();
|
||||||
|
@ -107,4 +104,3 @@ const LandingPage: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LandingPage;
|
export default LandingPage;
|
||||||
|
|
Loading…
Reference in a new issue