import 'react-toastify/dist/ReactToastify.css'; import classes from './UserSettings.module.css'; import { useState, useEffect } from 'react'; import { Session } from 'next-auth'; import { Optional, WizardEnvType, SessionStatus } from '~/types'; // Components import EmailSettings from './EmailSettings/EmailSettings'; import PasswordSettings from './PasswordSettings/PasswordSettings'; import UsernameSettings from './UsernameSettings/UsernameSettings'; import EmailAlertSettings from './EmailAlertSettings/EmailAlertSettings'; import AppriseAlertSettings from './AppriseAlertSettings/AppriseAlertSettings'; import Integrations from './Integrations/Integrations'; type UserSettingsProps = { status: SessionStatus; data: Session; }; export default function UserSettings({ data }: UserSettingsProps) { const [tab, setTab] = useState<'General' | 'Notifications' | 'Integrations'>('General'); const [wizardEnv, setWizardEnv] = useState>(undefined); // Fetch wizard environment on mount useEffect(() => { const fetchWizardEnv = async () => { try { const response = await fetch('/api/v1/account/wizard-env'); const data: WizardEnvType = await response.json(); setWizardEnv(data); } catch (error) { console.error('Failed to fetch wizard environment:', error); } }; fetchWizardEnv(); }, []); // If Integrations tab is selected but disabled, fallback to General useEffect(() => { if (tab === 'Integrations' && wizardEnv?.DISABLE_INTEGRATIONS === 'true') { setTab('General'); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [wizardEnv?.DISABLE_INTEGRATIONS]); return (

Account

{wizardEnv != undefined && ( <>
{wizardEnv.DISABLE_INTEGRATIONS !== 'true' && ( )}
{tab === 'General' && ( <> )} {tab === 'Notifications' && ( <> )} {tab === 'Integrations' && wizardEnv.DISABLE_INTEGRATIONS !== 'true' && } )}
); }