import { Ionicons } from "@expo/vector-icons"; import { router } from "expo-router"; import { Image, Pressable, View } from "react-native"; import { Badge } from "@/components/ui/Badge"; import { Card } from "@/components/ui/Card"; import { DoseReminderPanel } from "@/components/ui/DoseReminderPanel"; import { Text } from "@/components/ui/Text"; import { routes } from "@/lib/routes"; import type { Prescription, Reminder } from "@/lib/stores/prescriptionStore"; import { colors } from "@/lib/theme"; const statusTone = { submitted: "neutral", under_review: "warn", approved: "brand", queried: "info", rejected: "danger", filled: "brand", } as const; function refillDays(rx: Prescription) { if (!rx.lastFilledAt) return null; const due = new Date(rx.lastFilledAt); due.setDate(due.getDate() + rx.daysSupply); return Math.ceil((due.getTime() - Date.now()) / (1000 * 60 * 60 * 24)); } export function RxCareCard({ rx, reminder, expanded, onToggleExpand, }: { rx: Prescription; reminder?: Reminder; expanded: boolean; onToggleExpand: () => void; }) { const dueIn = refillDays(rx); const thumb = rx.imageUris[0]; return ( router.push(routes.rxDetail(rx.id))} style={{ padding: 14 }}> {thumb ? ( ) : ( )} {rx.medicineName} {rx.patientName} · {rx.medicines.length} medicine {rx.medicines.length === 1 ? "" : "s"} · {rx.daysSupply}d supply {reminder?.enabled ? ( ) : ( )} {dueIn !== null ? ( ) : ( )} {expanded ? "Hide setup" : reminder?.enabled ? "Edit reminder" : "Set reminder"} router.push(routes.rxCalendar(rx.id))} style={{ flex: 1, paddingVertical: 12, alignItems: "center", flexDirection: "row", justifyContent: "center", gap: 6, }} > Calendar {expanded ? ( ) : null} ); }