import { Ionicons } from "@expo/vector-icons"; import { router, useLocalSearchParams } from "expo-router"; import { Alert, Image, ScrollView, View } from "react-native"; import { Badge } from "@/components/ui/Badge"; import { Button } from "@/components/ui/Button"; import { Card, InfoRow, Section } from "@/components/ui/Card"; import { AppHeader } from "@/components/ui/Header"; import { Screen } from "@/components/ui/Screen"; import { Text } from "@/components/ui/Text"; import { getBranchById } from "@/lib/data/branches"; import { routes } from "@/lib/routes"; import { useOrdersStore } from "@/lib/stores/ordersStore"; import { colors, gutter, radii } from "@/lib/theme"; import { formatETB } from "@/lib/utils"; const toneFor = { requested: "neutral", confirmed: "info", paid: "brand", dispatched: "warn", delivered: "brand", completed: "brand", cancelled: "danger", } as const; export default function OrderDetailScreen() { const { id } = useLocalSearchParams<{ id: string }>(); const order = useOrdersStore((s) => s.getById(id)); const cancelOrder = useOrdersStore((s) => s.cancelOrder); const updateStatus = useOrdersStore((s) => s.updateStatus); if (!order) { return ( Order not found. ); } const branch = order.branchId ? getBranchById(order.branchId) : undefined; const canCancel = !["delivered", "completed", "cancelled"].includes(order.status); return ( } /> {order.id} {order.isGuestOrder ? " · Guest" : ""} {order.anyBranch ? "Any-branch pickup" : order.fulfillment === "pickup" ? "Pickup order" : "Delivery order"} {order.customerName} · {order.customerPhone} {order.notes ? ( Notes: {order.notes} ) : null} {order.pickupCode ? ( {order.isGuestOrder ? "Pharmacist admin code" : "Show this at the branch counter"} {order.pickupCode} {order.isGuestOrder ? "Share or screenshot so a pharmacist can create your order in admin." : order.anyBranch ? "Valid at any Gishen Pharmacy branch for fulfillment." : `Pickup at ${branch?.name ?? "selected branch"}.`}