2026-03-28 08:19:48 +09:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { useApi } from '@/lib/useApi';
|
2026-04-26 18:44:59 +09:00
|
|
|
import { SetPageHeader } from '@/components/layout/SetPageHeader';
|
|
|
|
|
import { Icon } from '@/components/ui/Icon';
|
|
|
|
|
import type { IconName } from '@/components/ui/Icon';
|
2026-03-28 08:19:48 +09:00
|
|
|
|
|
|
|
|
export default function MedicinesPage() {
|
|
|
|
|
const { householdId, isLoading: sessionLoading } = useApi();
|
|
|
|
|
|
|
|
|
|
if (sessionLoading) {
|
2026-04-26 18:44:59 +09:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<SetPageHeader title="Medicines" subtitle="All known medicines" />
|
|
|
|
|
<PageSkeleton />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2026-03-28 08:19:48 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!householdId) {
|
|
|
|
|
return (
|
2026-04-26 18:44:59 +09:00
|
|
|
<>
|
|
|
|
|
<SetPageHeader title="Medicines" subtitle="All known medicines" />
|
|
|
|
|
<div style={{ padding: '28px 32px' }}>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
background: 'var(--bg-elev)',
|
|
|
|
|
border: '1px solid var(--border)',
|
|
|
|
|
borderRadius: 'var(--r-md)',
|
|
|
|
|
padding: 24,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<p style={{ color: 'var(--ink-muted)', fontSize: 14 }}>
|
|
|
|
|
You need to{' '}
|
|
|
|
|
<Link href="/settings" style={{ color: 'var(--brand)', textDecoration: 'underline' }}>
|
|
|
|
|
create or join a household
|
|
|
|
|
</Link>{' '}
|
|
|
|
|
before managing medicines.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-03-28 08:19:48 +09:00
|
|
|
</div>
|
2026-04-26 18:44:59 +09:00
|
|
|
</>
|
2026-03-28 08:19:48 +09:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2026-04-26 18:44:59 +09:00
|
|
|
<>
|
|
|
|
|
<SetPageHeader title="Medicines" subtitle="All known medicines" />
|
|
|
|
|
<div style={{ padding: '28px 32px 56px', maxWidth: 1400 }}>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: 'grid',
|
|
|
|
|
gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
|
|
|
|
|
gap: 14,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Library"
|
|
|
|
|
description="Manage your medicines and their products"
|
|
|
|
|
href="/medicines/library"
|
|
|
|
|
icon="pill"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Cabinet"
|
|
|
|
|
description="Track your medicine inventory, quantities and expiry dates"
|
|
|
|
|
href="/medicines/cabinet"
|
|
|
|
|
icon="cabinet"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Schedule"
|
|
|
|
|
description="Today's dose log and weekly overview"
|
|
|
|
|
href="/medicines/schedule"
|
|
|
|
|
icon="clock"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Regimens"
|
|
|
|
|
description="Define daily medication schedules"
|
|
|
|
|
href="/medicines/regimens"
|
|
|
|
|
icon="list"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Organizer"
|
|
|
|
|
description="Fill your pill organizer and track cabinet usage"
|
|
|
|
|
href="/medicines/organizer"
|
|
|
|
|
icon="calendar"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Activity"
|
|
|
|
|
description="View cabinet event history and spending summaries"
|
|
|
|
|
href="/medicines/activity"
|
|
|
|
|
icon="trend"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Stores"
|
|
|
|
|
description="Manage pharmacies and stores for price tracking"
|
|
|
|
|
href="/stores"
|
|
|
|
|
icon="store"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Prices"
|
|
|
|
|
description="Track and compare medicine prices across stores"
|
|
|
|
|
href="/medicine-prices"
|
|
|
|
|
icon="tag"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Refills"
|
|
|
|
|
description="Get refill alerts and manage shopping lists"
|
|
|
|
|
href="/refills"
|
|
|
|
|
icon="refresh"
|
|
|
|
|
/>
|
|
|
|
|
<SectionCard
|
|
|
|
|
title="Purchases"
|
|
|
|
|
description="Record medicine purchases and track online orders"
|
|
|
|
|
href="/purchases"
|
|
|
|
|
icon="truck"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-03-28 08:19:48 +09:00
|
|
|
</div>
|
2026-04-26 18:44:59 +09:00
|
|
|
</>
|
2026-03-28 08:19:48 +09:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SectionCard({
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
href,
|
2026-04-26 18:44:59 +09:00
|
|
|
icon,
|
2026-03-28 08:19:48 +09:00
|
|
|
}: {
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
href: string;
|
2026-04-26 18:44:59 +09:00
|
|
|
icon: IconName;
|
2026-03-28 08:19:48 +09:00
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
href={href}
|
2026-04-26 18:44:59 +09:00
|
|
|
style={{
|
|
|
|
|
display: 'flex',
|
|
|
|
|
flexDirection: 'column',
|
|
|
|
|
gap: 10,
|
|
|
|
|
padding: 18,
|
|
|
|
|
background: 'var(--bg-elev)',
|
|
|
|
|
border: '1px solid var(--border)',
|
|
|
|
|
borderRadius: 'var(--r-md)',
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
transition: 'all 0.15s',
|
|
|
|
|
}}
|
2026-03-28 08:19:48 +09:00
|
|
|
>
|
2026-04-26 18:44:59 +09:00
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
width: 34,
|
|
|
|
|
height: 34,
|
|
|
|
|
borderRadius: 'var(--r-sm)',
|
|
|
|
|
background: 'var(--brand-soft)',
|
|
|
|
|
color: 'var(--brand)',
|
|
|
|
|
display: 'grid',
|
|
|
|
|
placeItems: 'center',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Icon name={icon} size={16} />
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div style={{ fontSize: 14, fontWeight: 500, color: 'var(--ink-strong)' }}>{title}</div>
|
|
|
|
|
<div style={{ fontSize: 12, color: 'var(--ink-muted)', marginTop: 2 }}>{description}</div>
|
|
|
|
|
</div>
|
2026-03-28 08:19:48 +09:00
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function PageSkeleton() {
|
|
|
|
|
return (
|
2026-04-26 18:44:59 +09:00
|
|
|
<div style={{ padding: '28px 32px' }}>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: 'grid',
|
|
|
|
|
gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
|
|
|
|
|
gap: 14,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-18 12:36:29 +09:00
|
|
|
{Array.from({ length: 9 }).map((_, i) => (
|
2026-04-26 18:44:59 +09:00
|
|
|
<div
|
|
|
|
|
key={i}
|
|
|
|
|
style={{ height: 96, borderRadius: 'var(--r-md)', background: 'var(--bg-inset)' }}
|
|
|
|
|
/>
|
2026-04-18 12:36:29 +09:00
|
|
|
))}
|
2026-03-28 08:19:48 +09:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|