'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">ВОЙТИ</Button>
                </DialogTrigger>
                <AuthDialog />
            </Dialog>
        );
    }

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