Add UI settings API and improve context initialization
- Add /settings/ui GET and PUT endpoints for UI settings - Improve ThemeContext with better initialization and auto accent handling - Update SidebarContext with expanded state persistence - Fix context initialization in ModulesContext and ViewModeContext - Update components to use improved theme/sidebar contexts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ export default function Login() {
|
||||
const [email, setEmail] = useState('');
|
||||
const [isRegister, setIsRegister] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [registrationEnabled, setRegistrationEnabled] = useState(true);
|
||||
const [registrationEnabled, setRegistrationEnabled] = useState<boolean | null>(null);
|
||||
const { login, register } = useAuth();
|
||||
const { t, language, setLanguage } = useTranslation();
|
||||
const { theme, toggleTheme, showDarkModeLogin, showLanguageLogin, showDarkModeToggle, showLanguageToggle } = useTheme();
|
||||
@@ -22,23 +22,31 @@ export default function Login() {
|
||||
|
||||
// Check if registration is enabled
|
||||
useEffect(() => {
|
||||
let isMounted = true;
|
||||
const checkRegistrationStatus = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/v1/auth/registration-status');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setRegistrationEnabled(data.registration_enabled !== false);
|
||||
const enabled = data.registration_enabled === true;
|
||||
if (isMounted) {
|
||||
setRegistrationEnabled(enabled);
|
||||
if (!enabled) setIsRegister(false);
|
||||
}
|
||||
} else {
|
||||
// Default to enabled if we can't fetch the setting
|
||||
setRegistrationEnabled(true);
|
||||
if (isMounted) setRegistrationEnabled(true);
|
||||
}
|
||||
} catch (error) {
|
||||
// Default to enabled if we can't fetch the setting
|
||||
setRegistrationEnabled(true);
|
||||
if (isMounted) setRegistrationEnabled(true);
|
||||
}
|
||||
};
|
||||
|
||||
checkRegistrationStatus();
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleSubmit = async (e: FormEvent) => {
|
||||
@@ -129,7 +137,7 @@ export default function Login() {
|
||||
</form>
|
||||
|
||||
<div className="login-footer">
|
||||
{registrationEnabled && (
|
||||
{registrationEnabled === true && (
|
||||
<button
|
||||
onClick={() => {
|
||||
setIsRegister(!isRegister);
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function Features() {
|
||||
const { user: currentUser } = useAuth();
|
||||
const { t } = useTranslation();
|
||||
const { toggleMobileMenu } = useSidebar();
|
||||
const { moduleStates, setModuleEnabled, saveModulesToBackend, hasInitialized } = useModules();
|
||||
const { moduleStates, setModuleEnabled, saveModulesToBackend, hasInitialized, isLoading } = useModules();
|
||||
const [activeTab, setActiveTab] = useState<TabId>('feature1');
|
||||
const hasUserMadeChanges = useRef(false);
|
||||
const saveRef = useRef(saveModulesToBackend);
|
||||
@@ -119,6 +119,9 @@ export default function Features() {
|
||||
};
|
||||
|
||||
const renderTabContent = () => {
|
||||
if (!hasInitialized || isLoading) {
|
||||
return <div className="loading">Loading...</div>;
|
||||
}
|
||||
switch (activeTab) {
|
||||
case 'feature1':
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user