diff --git a/components/medication/DoseCard.tsx b/components/medication/DoseCard.tsx index c33413e..2e9e13e 100644 --- a/components/medication/DoseCard.tsx +++ b/components/medication/DoseCard.tsx @@ -59,6 +59,13 @@ const statusStyles = { }, }; +const statusLabels: Record = { + [DoseStatus.UPCOMING]: 'Upcoming dose', + [DoseStatus.TAKEN]: 'Dose taken', + [DoseStatus.MISSED]: 'Dose missed', + [DoseStatus.SNOOZED]: 'Dose snoozed', +}; + const DoseCard: React.FC = ({ dose, medication, @@ -68,6 +75,7 @@ const DoseCard: React.FC = ({ snoozedUntil, }) => { const styles = statusStyles[status]; + const statusLabel = statusLabels[status]; const timeString = dose.scheduledTime.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', @@ -85,17 +93,48 @@ const DoseCard: React.FC = ({ }) : ''; const MedicationIcon = getMedicationIcon(medication.icon); + const cardTitleId = `dose-${dose.id}-title`; + const statusId = `dose-${dose.id}-status`; + + const handleCardKeyDown = ( + event: React.KeyboardEvent + ): void => { + if (event.target !== event.currentTarget) { + return; + } + + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault(); + onToggleDose(dose.id); + } + + if ( + (event.key.toLowerCase() === 's' || event.key === 'S') && + status === DoseStatus.UPCOMING + ) { + event.preventDefault(); + onSnooze(dose.id); + } + }; return (
  • -

    +

    {medication.name}

    @@ -106,9 +145,14 @@ const DoseCard: React.FC = ({ {styles.icon}

    + {statusLabel} {timeString}
    diff --git a/components/ui/ReminderCard.tsx b/components/ui/ReminderCard.tsx index c20e91f..9f242f9 100644 --- a/components/ui/ReminderCard.tsx +++ b/components/ui/ReminderCard.tsx @@ -12,15 +12,23 @@ const ReminderCard: React.FC = ({ reminder }) => { minute: '2-digit', }); const ReminderIcon = getReminderIcon(reminder.icon); + const titleId = `reminder-${reminder.id}-title`; return ( -
  • +
  • -

    +

    {reminder.title}