summaryrefslogtreecommitdiff
path: root/src/components/header/ProfileOrLogin.tsx
blob: 416418b2fa5c82b8908c3cd145d770d400aeb433 (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
'use client';

import Image from 'next/image';
import { useUser } from '../../lib/contexts';
import { Button } from '../ui';
import Link from 'next/link';
import { Dialog, DialogTrigger } from '../ui/dialog';
import { AuthDialog } from './AuthDialog';
export function ProfileOrLogin() {
    const user = useUser();

    if (!user) {
        return (
            <Dialog>
                <DialogTrigger asChild>
                    <Button className="py-2.5 px-3.75 gap-10 w-21.75 h-10.5">
                        ВОЙТИ
                    </Button>
                </DialogTrigger>
                <AuthDialog />
            </Dialog>
        );
    }

    return (
        <Link href={'/profile'}>
            <Image
                src={user?.avatar ?? 'icons/avatar.svg'}
                alt=""
                width={60}
                height={60}
            />
        </Link>
    );
}