Compare commits

..

No commits in common. "ac58b57645ffe60d21263ad94ad9dc3ef1024e39" and "015e9a1064170661392a5b8875042085b0abeba9" have entirely different histories.

2 changed files with 38 additions and 51 deletions

View file

@ -47,13 +47,10 @@ const Login: React.FC = () => {
const savedAccountPassword = localStorage.getItem('accountPassword'); const savedAccountPassword = localStorage.getItem('accountPassword');
const savedAccountName = localStorage.getItem('accountName'); const savedAccountName = localStorage.getItem('accountName');
if ( if ((email === savedAccountEmail || accountName === savedAccountName) && password === savedAccountPassword) {
(email === savedAccountEmail || accountName === savedAccountName) &&
password === savedAccountPassword
) {
setIsLoggedIn(true); // Successful login setIsLoggedIn(true); // Successful login
setShowLoginPopup(false); // Close the login popup setShowLoginPopup(false); // Close the login popup
// Save credentials to localStorage (optional in case of changes) // Save credentials to localStorage
localStorage.setItem('accountName', savedAccountName || accountName); localStorage.setItem('accountName', savedAccountName || accountName);
localStorage.setItem('accountEmail', savedAccountEmail || email); localStorage.setItem('accountEmail', savedAccountEmail || email);
localStorage.setItem('accountPassword', savedAccountPassword || password); localStorage.setItem('accountPassword', savedAccountPassword || password);
@ -78,7 +75,7 @@ const Login: React.FC = () => {
<div> <div>
{/* Login or Settings Button */} {/* Login or Settings Button */}
<button className='header-login-button' onClick={isLoggedIn ? toggleSettingsPopup : toggleLoginPopup}> <button className='header-login-button' onClick={isLoggedIn ? toggleSettingsPopup : toggleLoginPopup}>
{isLoggedIn ? <img src="" alt="Settings" /> : 'Log In'} {isLoggedIn ? 'Settings' : 'Log In'}
</button> </button>
{/* Conditional rendering of the Login Popup */} {/* Conditional rendering of the Login Popup */}
@ -97,12 +94,8 @@ const Login: React.FC = () => {
<input <input
type="text" type="text"
placeholder="Name or Email" placeholder="Name or Email"
value={email || accountName} // Display whichever is set value={email}
onChange={(e) => { onChange={(e) => setEmail(e.target.value)}
const input = e.target.value;
setEmail(input); // Update both email and accountName states
setAccountName(input);
}}
/> />
</div> </div>
@ -185,7 +178,7 @@ const Login: React.FC = () => {
)} )}
{/* Conditional rendering of the Settings Popup */} {/* Conditional rendering of the Settings Popup */}
{showSettingsPopup && <Settings closeSettings={toggleSettingsPopup} accountName={accountName} />} {showSettingsPopup && <Settings closeSettings={toggleSettingsPopup} accountName={accountName}/>}
</div> </div>
); );
}; };

View file

@ -30,12 +30,12 @@ const modelDropdown = {
const Models: React.FC = () => { const Models: React.FC = () => {
// Initialize state with value from localStorage or default to '' // Initialize state with value from localStorage or default to ''
const [radioSelection, setRadioSelection] = useState(''); const [radioSelection, setRadioSelection] = useState('');
useEffect(() => { useEffect(() => {
const handleStorageChange = () => { const handleStorageChange = () => {
setRadioSelection(localStorage.getItem('radioSelection') || ''); setRadioSelection(localStorage.getItem('radioSelection') || '');
}; };
handleStorageChange(); handleStorageChange()
// Update dropdown immediately when localStorage changes internally or externally // Update dropdown immediately when localStorage changes internally or externally
window.addEventListener('storage', handleStorageChange); window.addEventListener('storage', handleStorageChange);
@ -54,58 +54,52 @@ const Models: React.FC = () => {
// Determine the filtered models based on current radioSelection // Determine the filtered models based on current radioSelection
const filteredModels = (() => { const filteredModels = (() => {
let models = [];
switch (radioSelection) { switch (radioSelection) {
case 'Offline': case 'Offline':
models = modelDropdown.offlineModels; // Show only offline models return modelDropdown.offlineModels; // Show only offline models
break;
case 'AI Online': case 'AI Online':
models = modelDropdown.onlineModels; // Show only online models return modelDropdown.onlineModels; // Show only online models
break;
case 'FOSS': case 'FOSS':
models = modelDropdown.fossModels; // Show only FOSS models return modelDropdown.fossModels; // Show only FOSS models
break;
default: default:
models = [...modelDropdown.offlineModels, ...modelDropdown.onlineModels, ...modelDropdown.fossModels]; // Show all models if nothing matches return [...modelDropdown.offlineModels, ...modelDropdown.onlineModels, ...modelDropdown.fossModels]; // Show all models if nothing matches
break;
} }
return Array.from(new Set(models)); // Remove duplicates using Set
})(); })();
const isOfflineModel = (model: string) => modelDropdown.offlineModels.includes(model); const isOfflineModel = (model: string) => modelDropdown.offlineModels.includes(model);
return ( return (
<div className="model-background"> <div className="model-background">
<div className="models"> <div className="models">
<div className="title"> <div className="title">
<h3>Different AI Models</h3> <h3>Different AI Models</h3>
</div> </div>
{/* Model Selection Dropdown */} {/* Model Selection Dropdown */}
<div className="model-dropdown"> <div className="model-dropdown">
<label htmlFor="model-select">Select AI Model:</label> <label htmlFor="model-select">Select AI Model:</label>
<select id="model-select" value={radioSelection} onChange={handleModelChange}> <select id="model-select" value={radioSelection} onChange={handleModelChange}>
{filteredModels.map((model) => ( {filteredModels.map((model) => (
<option key={model} value={model}> <option key={model} value={model}>
{model} {model}
</option> </option>
))}
</select>
</div>
{/* Model Grid with Cards */}
<div className="grid">
{['Code', 'Math', 'Language', 'Character', 'Finance', 'Weather', 'Time', 'Image', 'Custom1', 'Custom2'].map((category) => (
<button key={category} className={`${category.toLowerCase()}-model model-box`}>
<div className="overlay">
<h3>{category}</h3>
{isOfflineModel(radioSelection) && <img src="/img/nowifi.svg" alt="No Wi-Fi" />}
</div>
</button>
))} ))}
</div> </select>
</div>
{/* Model Grid with Cards */}
<div className="grid">
{['Code', 'Math', 'Language', 'Character', 'Finance', 'Weather', 'Time', 'Image', 'Custom1', 'Custom2'].map((category) => (
<button key={category} className={`${category.toLowerCase()}-model model-box`}>
<div className="overlay">
<h3>{category}</h3>
{isOfflineModel(radioSelection) && <img src="/img/nowifi.svg" alt="No Wi-Fi" />}
</div>
</button>
))}
</div> </div>
</div> </div>
</div>
); );
}; };