UI fixes
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user