- Add WorkOS SSO authentication (Google and Apple sign-in) - Add daily usage tracking with calendar view - Add setup wizard for substance selection (nicotine/cannabis) - Add daily check-in prompt on login - Add statistics dashboard (daily avg, streak, etc.) - Add quit plan generation after 7 days of tracking - Apply custom theme from brief.md - Add "stay logged in" preference Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
'use client';
|
|
|
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
|
import { Button } from '@/components/ui/button';
|
|
import { User } from '@/lib/session';
|
|
|
|
interface UserHeaderProps {
|
|
user: User;
|
|
}
|
|
|
|
export function UserHeader({ user }: UserHeaderProps) {
|
|
const initials = [user.firstName?.[0], user.lastName?.[0]]
|
|
.filter(Boolean)
|
|
.join('')
|
|
.toUpperCase() || user.email[0].toUpperCase();
|
|
|
|
const handleLogout = async () => {
|
|
window.location.href = '/api/auth/logout';
|
|
};
|
|
|
|
return (
|
|
<header className="border-b bg-card">
|
|
<div className="container mx-auto px-4 py-4 flex items-center justify-between">
|
|
<div className="flex items-center gap-4">
|
|
<h1 className="text-2xl font-bold text-primary">QuitTrack</h1>
|
|
</div>
|
|
|
|
<div className="flex items-center gap-4">
|
|
<div className="flex items-center gap-3">
|
|
<Avatar>
|
|
<AvatarImage src={user.profilePictureUrl ?? undefined} alt={user.firstName ?? 'User'} />
|
|
<AvatarFallback>{initials}</AvatarFallback>
|
|
</Avatar>
|
|
<div className="hidden sm:block">
|
|
<p className="text-sm font-medium">
|
|
{user.firstName ? `${user.firstName} ${user.lastName ?? ''}`.trim() : user.email}
|
|
</p>
|
|
<p className="text-xs text-muted-foreground">{user.email}</p>
|
|
</div>
|
|
</div>
|
|
<Button variant="outline" size="sm" onClick={handleLogout}>
|
|
Sign out
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
);
|
|
}
|