import {Avatar, AvatarFallback, AvatarImage} from "@/components/ui/avatar";
import {Models} from "appwrite";
import Link from "next/link";
import {PROFILE_URL} from "@/lib/constants";

type AccountAvatarPropsType = {
    user: Models.User<any> | null;
}

export default function AccountAvatar(props: AccountAvatarPropsType) {

    let initials = "C"
    try {
        initials = props?.user?.name?.charAt(0) || "C"
    } catch (e) {}

    return (
        <Link href={PROFILE_URL}>
            <Avatar>
                <AvatarImage src="https://github.com/shadcn.png"/>
                <AvatarFallback>{initials}</AvatarFallback>
            </Avatar>
        </Link>
    )
}