import { Ionicons } from "@expo/vector-icons"; import { router } from "expo-router"; import { Alert, Image, Pressable, ScrollView, TextInput, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/Button"; import { Card, InfoRow } from "@/components/ui/Card"; import { EmptyState } from "@/components/ui/EmptyState"; import { QtyStepper } from "@/components/ui/QtyStepper"; import { Screen, TAB_BAR_INSET } from "@/components/ui/Screen"; import { StickyBar } from "@/components/ui/StickyBar"; import { Text } from "@/components/ui/Text"; import { DELIVERY_FEE, DEMO_VOUCHER, voucherDiscount } from "@/lib/commerce"; import { routes } from "@/lib/routes"; import { useCartStore } from "@/lib/stores/cartStore"; import { colors, fonts, gutter, radii } from "@/lib/theme"; import { formatETB } from "@/lib/utils"; export default function CartScreen() { const { t } = useTranslation(); const insets = useSafeAreaInsets(); const items = useCartStore((s) => s.items); const setQuantity = useCartStore((s) => s.setQuantity); const removeItem = useCartStore((s) => s.removeItem); const subtotal = useCartStore((s) => s.subtotal()); const voucher = useCartStore((s) => s.voucherCode); const setVoucher = useCartStore((s) => s.setVoucher); const delivery = items.length ? DELIVERY_FEE : 0; const discount = voucherDiscount(subtotal, voucher); const total = subtotal + delivery - discount; return ( {t("common.cart")} {items.length} item{items.length === 1 ? "" : "s"} in your bag {items.length === 0 ? ( router.push(routes.shop)} /> ) : ( {items.map((item) => ( {item.name} removeItem(item.productId)} hitSlop={8}> {item.unit} {item.requiresPrescription ? " ยท RX" : ""} {formatETB(item.price)} setQuantity(item.productId, n)} min={0} /> ))} router.push(routes.shop)}> + Add product Voucher setVoucher(v || null)} placeholder="Try GISHEN10" placeholderTextColor={colors.subtle} style={{ flex: 1, fontFamily: fonts.regular, fontSize: 14, color: colors.ink, }} />