brackt/app/components/UserMenu.tsx
Chris Parsons 8fe9c40850 Fix avatar display bugs in navbar, standings, and draft views
- Remove rounded clipping on navbar user avatar button (was showing dark circular background)
- Fix "My Avatar" preview in team settings showing circular instead of square shape
- Pass owner avatar data through to TeamAvatar in standings, draft room, and draft board so teams with avatarType="owner" correctly show the user's avatar instead of the generated flag
- Consolidate user lookups in draft board loader to avoid duplicate DB queries
- Fix DraftSlotWithTeam interface to use RawFlagConfig type and include logoUrl/flagConfig/avatarType fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 16:45:52 -07:00

68 lines
2 KiB
TypeScript

import { Link, useNavigate } from "react-router";
import { authClient } from "~/lib/auth-client";
import { Popover, PopoverContent, PopoverTrigger } from "~/components/ui/popover";
import { Button } from "~/components/ui/button";
import { UserAvatar } from "~/components/ui/UserAvatar";
import type { RawFlagConfig } from "~/lib/flag-types";
interface UserMenuProps {
userId: string;
name: string | null;
email: string;
customAvatarUrl?: string | null;
flagConfig?: RawFlagConfig | null;
avatarType?: string | null;
}
export function UserMenu({
userId,
name,
email,
customAvatarUrl,
flagConfig,
avatarType,
}: UserMenuProps) {
const navigate = useNavigate();
async function handleSignOut() {
await authClient.signOut();
navigate("/");
}
return (
<Popover>
<PopoverTrigger asChild>
<Button variant="ghost" className="relative h-9 w-9 p-0 rounded-none">
<UserAvatar
userId={userId}
name={name}
email={email}
customAvatarUrl={customAvatarUrl}
flagConfig={flagConfig}
avatarType={avatarType}
/>
</Button>
</PopoverTrigger>
<PopoverContent align="end" className="w-48 p-1">
<div className="px-2 py-1.5 text-sm">
<p className="font-medium truncate">{name ?? email}</p>
<p className="text-muted-foreground truncate text-xs">{email}</p>
</div>
<div className="border-t border-border my-1" />
<Link
to="/user-profile"
className="flex w-full items-center rounded-sm px-2 py-1.5 text-sm hover:bg-accent transition-colors"
>
Profile
</Link>
<div className="border-t border-border my-1" />
<button
onClick={handleSignOut}
className="flex w-full items-center rounded-sm px-2 py-1.5 text-sm text-destructive hover:bg-accent transition-colors"
>
Sign Out
</button>
</PopoverContent>
</Popover>
);
}