Implement medicine library and cabinet
This commit is contained in:
parent
db79af06f7
commit
1f66fab30f
72 changed files with 7642 additions and 319 deletions
|
|
@ -2,11 +2,7 @@ import Link from 'next/link';
|
|||
|
||||
const navItems = [
|
||||
{ label: 'Dashboard', href: '/dashboard' },
|
||||
{ label: 'Products', href: '/products' },
|
||||
{ label: 'Recipes', href: '/recipes' },
|
||||
{ label: 'Pantry', href: '/pantry' },
|
||||
{ label: 'Meal Plans', href: '/meal-plans' },
|
||||
{ label: 'Shopping', href: '/shopping' },
|
||||
{ label: 'Medicines', href: '/medicines' },
|
||||
{ label: 'Settings', href: '/settings' },
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,47 @@
|
|||
import { auth } from '@/lib/auth';
|
||||
'use client';
|
||||
|
||||
export async function TopBar() {
|
||||
const session = await auth();
|
||||
const name = session?.user?.name ?? 'Unknown';
|
||||
import Link from 'next/link';
|
||||
import useSWR from 'swr';
|
||||
import { useApi } from '@/lib/useApi';
|
||||
import { getHousehold } from '@/services/households';
|
||||
|
||||
export function TopBar() {
|
||||
const { householdId, profile, isLoading } = useApi();
|
||||
const name = profile?.displayName ?? 'Unknown';
|
||||
const initial = name.charAt(0).toUpperCase();
|
||||
const householdId = session?.householdIds?.[0] ?? null;
|
||||
|
||||
const { data: household } = useSWR(householdId ? `household-${householdId}` : null, () =>
|
||||
getHousehold(householdId!),
|
||||
);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<header className="flex h-16 items-center justify-between border-b bg-white px-6">
|
||||
<div className="h-6 w-32 animate-pulse rounded bg-gray-200" />
|
||||
<div className="h-8 w-8 animate-pulse rounded-full bg-gray-200" />
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<header className="flex h-16 items-center justify-between border-b bg-white px-6">
|
||||
<div className="text-sm text-gray-500">
|
||||
{householdId ? (
|
||||
<span className="rounded-md border px-3 py-1 font-medium text-gray-700">
|
||||
{householdId}
|
||||
{household?.name ?? householdId}
|
||||
</span>
|
||||
) : (
|
||||
<span className="rounded-md border px-3 py-1 text-gray-400">No household</span>
|
||||
<Link
|
||||
href="/settings"
|
||||
className="rounded-md border border-amber-300 bg-amber-50 px-3 py-1 text-amber-700 hover:bg-amber-100 transition-colors"
|
||||
>
|
||||
No household - Create one
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-sm text-gray-600">{name}</span>
|
||||
<div className="h-8 w-8 rounded-full bg-primary-200 flex items-center justify-center text-sm font-medium text-primary-800">
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-primary-200 text-sm font-medium text-primary-800">
|
||||
{initial}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue