summaryrefslogtreecommitdiff
path: root/src/app/settings/page.tsx
blob: 5f630d1e0aa85daa3f12111799af0445627615d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use client';

import { useState, useEffect } from 'react';
import { useUser } from '@/lib/contexts/Auth.context';
import SettingsMenu from '@/components/settings/SettingsMenu';
import SecurityPage from '@/components/settings/SecurityPage';
import ProfilePage from '@/components/settings/ProfilePage';
import { Dialog, DialogTrigger, DialogContent } from '@/components/ui/dialog';
import { AuthDialog } from '@/components/header/AuthDialog';
//import ProfileDescription from '@/components/settings/ProfileDescription';
export default function Settings() {
    const user = useUser();
    const [tab, setTab] = useState('profile');
    const [showAuth, setShowAuth] = useState(false);

    useEffect(() => {
        if (user === null) {
            setShowAuth(true);
        }
    }, [user]);

    if (!user) {
        return (
            <Dialog open={showAuth} onOpenChange={setShowAuth}>
                <DialogTrigger asChild>
                    <div />
                </DialogTrigger>
                <DialogContent className="p-0 bg-transparent border-none">
                    <AuthDialog redirectTo="/settings" />
                </DialogContent>
            </Dialog>
        );
    }

    return (
        <div className="flex flex-row gap-[250px] w-full max-w-[1500px]">
            <SettingsMenu tab={tab} setTab={setTab} />
            <div className="flex-1">
                {tab === 'profile' && <ProfilePage />}
                {tab === 'security' && <SecurityPage />}
            </div>
        </div>
    );
}