This commit is contained in:
2026-02-15 22:19:48 -06:00
parent 749f734aff
commit 782b1d2931
9 changed files with 1400 additions and 269 deletions

View File

@@ -156,21 +156,27 @@ export default function MedicationsPage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [todayMeds, tick]);
const [error, setError] = useState<string | null>(null);
const handleTake = async (medId: string, time?: string) => {
try {
setError(null);
await api.medications.take(medId, time);
window.location.reload();
} catch (err) {
console.error('Failed to log medication:', err);
setError(err instanceof Error ? err.message : 'Failed to log medication');
}
};
const handleSkip = async (medId: string, time?: string) => {
try {
setError(null);
await api.medications.skip(medId, time);
window.location.reload();
} catch (err) {
console.error('Failed to skip medication:', err);
setError(err instanceof Error ? err.message : 'Failed to skip medication');
}
};
@@ -217,6 +223,12 @@ export default function MedicationsPage() {
{/* Push Notification Toggle */}
<PushNotificationToggle />
{error && (
<div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg">
{error}
</div>
)}
{/* Due Now Section */}
{dueEntries.length > 0 && (
<div>