import { Share, ScrollView, View } from "react-native"; import { useTranslation } from "react-i18next"; 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 { DEMO_VOUCHER } from "@/lib/commerce"; import { useAuthStore } from "@/lib/stores/authStore"; import { useCartStore } from "@/lib/stores/cartStore"; import { colors, gutter } from "@/lib/theme"; import { router } from "expo-router"; import { routes } from "@/lib/routes"; import { Alert } from "react-native"; const tiers = [ { id: "bronze", min: 0, perks: "1 pt per 10 ETB · Birthday surprise" }, { id: "silver", min: 300, perks: "1.25x points · Free delivery over 800 ETB" }, { id: "gold", min: 1000, perks: "1.5x points · Priority pharmacist consult" }, ] as const; export default function LoyaltyScreen() { const { t } = useTranslation(); const user = useAuthStore((s) => s.user); const ledger = useAuthStore((s) => s.ledger); const redeemPoints = useAuthStore((s) => s.redeemPoints); const setVoucher = useCartStore((s) => s.setVoucher); const points = user?.points ?? 0; const next = tiers.find((tier) => points < tier.min) ?? null; const progress = next ? Math.min(1, points / next.min) : 1; return ( Available points {points} {next ? `${next.min - points} pts to ${next.id}` : "You've reached Gold — enjoy premium perks"}
{tiers.map((tier, i) => ( ))}
Redeem rewards Redeem 100 points for a {DEMO_VOUCHER} voucher (10% off your next order). {user?.activeVoucher ? ( ) : null}