From fb53341be1603c9fe069f677baf2fffe10449ce9 Mon Sep 17 00:00:00 2001 From: thesn10 <38666407+thesn10@users.noreply.github.com> Date: Thu, 2 Jul 2026 23:04:18 +0200 Subject: [PATCH] Add order detail screen --- app/src/app/orders/[id].tsx | 121 ++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 app/src/app/orders/[id].tsx diff --git a/app/src/app/orders/[id].tsx b/app/src/app/orders/[id].tsx new file mode 100644 index 0000000..a53d18e --- /dev/null +++ b/app/src/app/orders/[id].tsx @@ -0,0 +1,121 @@ +import type { JSX } from "react"; +import { useMemo, useState } from "react"; +import { ScrollView, View } from "react-native"; +import { useLocalSearchParams, useRouter } from "expo-router"; +import { Button, Typography, useToast } from "heroui-native"; +import { ORDERS } from "@/data/mock"; +import { orderStatusInfo } from "@/lib/status"; +import { AppHeader } from "@/components/AppHeader"; +import { StatusChip } from "@/components/StatusChip"; + +const STEP_LABELS = ["Payment\nHeld", "Seller\nConfirms", "You Confirm\nReceipt"] as const; + +export default function OrderDetailScreen(): JSX.Element { + const { id } = useLocalSearchParams<{ id: string }>(); + const router = useRouter(); + const { toast } = useToast(); + + const order = useMemo(() => ORDERS.find((item) => item.id === Number(id)) ?? ORDERS[0], [id]); + const [status, setStatus] = useState(order.status); + const statusInfo = orderStatusInfo(status); + + const step2Done = status !== "AwaitingConfirm"; + const step3Done = status === "Complete"; + const activeStepIndex = step3Done ? 2 : step2Done ? 1 : 0; + + const canCancel = status === "AwaitingConfirm"; + const canConfirm = status === "Active"; + + const handleCancel = () => { + setStatus("Cancelled"); + toast.show({ variant: "success", label: "Order cancelled. Full refund initiated." }); + }; + + const handleConfirmReceipt = () => { + setStatus("Complete"); + toast.show({ variant: "success", label: "Receipt confirmed! Seller has been paid." }); + }; + + return ( + + + + + + + Order placed {order.date} + + {order.name} + + {order.seller} + + + + {order.amt} + + + + + + + Order Progress + + + {STEP_LABELS.map((label, index) => { + const done = index < activeStepIndex || (index === activeStepIndex && step3Done); + const active = index === activeStepIndex && !step3Done; + return ( + + + + {done ? "✓" : String(index + 1)} + + + + {label} + + + ); + })} + + + + + + + {order.amt} + + {" is locked in a secure on-chain escrow. Funds are released to the seller only after you "} + confirm receipt — no third party can touch them. + + + + + {canCancel && ( + + )} + {canConfirm && ( + + )} + + + + + ); +}