All blocks
Seattle, WA · Westlake RouteSea-Tac Distribution Hub, WANarita Air Cargo Terminal, JPKuro Roastery & Kiln · KyotoOnline Storefront
Order Detail
Commerce order detail page with breadcrumb navigation, fulfillment and payment status badges, itemized line-item table with product photo thumbnails, invoice breakdown, live shipment tracking timeline, customer and shipping sidebar cards with collapsible risk analysis, cancel-order confirmation dialog, and toast feedback.
Built withAlert DialogAvatarBadgeBreadcrumbButtonCardCodeCollapsibleData ListGridHeadingIconIcon ButtonMenuProgressSeparatorStackStatusTableTabsTextTimelineToast
Order #KRN-90418
In transitPaid6 itemsKTKenji TakahashiDec 1, 2026 · 08:42 PSTEst. delivery Dec 3
Order items
6 of 6 packed| Item | Qty | Unit | Total |
|---|---|---|---|
Kuro Matte Pour-Over Dripper KRN-DRP-02V60 02 · Basalt Black | ×1 | $64.00 | $64.00 |
Bizen Double-Wall Espresso Tumbler KRN-TMB-04140 ml · Iron Ash Glaze | ×2 | $38.00 | $76.00 |
Yirgacheffe Washed Reserve KRN-COF-19340 g · Whole Bean · Light Roast | ×2 | $26.00 | $52.00 |
Walnut & Brass Scale Tray KRN-TRY-07180 mm · Oiled Walnut | ×1 | $52.00 | $52.00 |
Payment & invoice
Paid- Subtotal
- 6 units (4 SKUs)$244.00
- Discount
- Loyalty code
ROASTCLUB10−$24.40 - Shipping
- Yamato Express Priority (1.75 kg)$14.00
- Tax
- WA destination tax (8.5%)$18.67
- Total
- USD · Settled$252.27
- Paid by customer
- Apple Pay · Mastercard •••• 4821$252.27
- Settlement ref
KR-90418-OKDec 1, 2026 · 08:42 PST
Shipment tracking
In transitYamato Express Priority · Parcel weight 1.75 kg
Signature requiredKRN-JP-8841-2904Est. delivery Dec 3Scheduled deliveryEst. Dec 3 · by 18:00 PST
Signature requested upon delivery. SMS notice armed for 30 minutes prior.
Arrived at regional sort facilityDec 2 · 06:14 PST
Customs duty pre-cleared (HS 6912.00) and scanned onto local courier pallet.
Departed international gatewayDec 1 · 21:40 JST
Temperature-controlled cargo hold loaded on Yamato Express Flight NH-178.
Packed & kiln-inspected at studioDec 1 · 13:05 JST
4 SKUs verified, tumblers double-boxed, and roast batch #26-44 sealed.
Order confirmed & payment capturedDec 1 · 08:42 PST
Authorized via Apple Pay (Mastercard •••• 4821) · Ref KR-90418-OK.
Install
1npx stylexblocks add order-detailSource
components/blocks/ui-sdk/order-detail.tsx
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891import * as stylex from "@stylexjs/stylex";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { AlertDialog } from "#components/ui/ui-sdk/alert-dialog.tsx";import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Breadcrumb } from "#components/ui/ui-sdk/breadcrumb.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { Code } from "#components/ui/ui-sdk/code.tsx";import { Collapsible } from "#components/ui/ui-sdk/collapsible.tsx";import { DataList } from "#components/ui/ui-sdk/data-list.tsx";import { Grid } from "#components/ui/ui-sdk/grid.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { IconButton } from "#components/ui/ui-sdk/icon-button.tsx";import { Menu } from "#components/ui/ui-sdk/menu.tsx";import { Progress } from "#components/ui/ui-sdk/progress.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { HStack, Stack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Status } from "#components/ui/ui-sdk/status.tsx";import { Table } from "#components/ui/ui-sdk/table.tsx";import { Tabs } from "#components/ui/ui-sdk/tabs.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Timeline } from "#components/ui/ui-sdk/timeline.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";import { accentPalette, amberPalette, bluePalette, grayPalette, greenPalette, redPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fontWeights } from "@stylexblocks/ui/tokens/font-weights.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
const NARROW = "@container order-detail (max-width: 920px)";const COMPACT = "@container order-detail (max-width: 600px)";
export type OrderStatus = "in_transit" | "delivered" | "cancelled";export type ProductArtworkKind = "dripper" | "tumbler" | "coffee" | "tray";
export interface OrderLineItem { id: string; name: string; sku: string; variant: string; unitPrice: number; quantity: number; weightGrams: number; artwork: ProductArtworkKind;}
export interface ShipmentEvent { id: string; title: string; location: string; timestamp: string; detail: string; state: "completed" | "current" | "upcoming" | "cancelled";}
interface ActivityEntry { id: string; actor: string; initials: string; role: string; timestamp: string; summary: string; details?: string[];}
type OrderTab = "overview" | "shipment" | "activity";
const DEFAULT_ITEMS: OrderLineItem[] = [ { id: "item-dripper", name: "Kuro Matte Pour-Over Dripper", sku: "KRN-DRP-02", variant: "V60 02 · Basalt Black", unitPrice: 64, quantity: 1, weightGrams: 340, artwork: "dripper", }, { id: "item-tumbler", name: "Bizen Double-Wall Espresso Tumbler", sku: "KRN-TMB-04", variant: "140 ml · Iron Ash Glaze", unitPrice: 38, quantity: 2, weightGrams: 420, artwork: "tumbler", }, { id: "item-coffee", name: "Yirgacheffe Washed Reserve", sku: "KRN-COF-19", variant: "340 g · Whole Bean · Light Roast", unitPrice: 26, quantity: 2, weightGrams: 680, artwork: "coffee", }, { id: "item-tray", name: "Walnut & Brass Scale Tray", sku: "KRN-TRY-07", variant: "180 mm · Oiled Walnut", unitPrice: 52, quantity: 1, weightGrams: 310, artwork: "tray", },];
const BASE_SHIPMENT_EVENTS: ShipmentEvent[] = [ { id: "ship-delivery", title: "Scheduled delivery", location: "Seattle, WA · Westlake Route", timestamp: "Est. Dec 3 · by 18:00 PST", detail: "Signature requested upon delivery. SMS notice armed for 30 minutes prior.", state: "upcoming", }, { id: "ship-hub", title: "Arrived at regional sort facility", location: "Sea-Tac Distribution Hub, WA", timestamp: "Dec 2 · 06:14 PST", detail: "Customs duty pre-cleared (HS 6912.00) and scanned onto local courier pallet.", state: "current", }, { id: "ship-air", title: "Departed international gateway", location: "Narita Air Cargo Terminal, JP", timestamp: "Dec 1 · 21:40 JST", detail: "Temperature-controlled cargo hold loaded on Yamato Express Flight NH-178.", state: "completed", }, { id: "ship-packed", title: "Packed & kiln-inspected at studio", location: "Kuro Roastery & Kiln · Kyoto", timestamp: "Dec 1 · 13:05 JST", detail: "4 SKUs verified, tumblers double-boxed, and roast batch #26-44 sealed.", state: "completed", }, { id: "ship-confirmed", title: "Order confirmed & payment captured", location: "Online Storefront", timestamp: "Dec 1 · 08:42 PST", detail: "Authorized via Apple Pay (Mastercard •••• 4821) · Ref KR-90418-OK.", state: "completed", },];
const INITIAL_ACTIVITY: ActivityEntry[] = [ { id: "act-4", actor: "Yamato Express API", initials: "YE", role: "Carrier", timestamp: "Dec 2 · 06:14 PST", summary: "Parcel scanned at Sea-Tac regional hub; cleared US Customs without hold.", }, { id: "act-3", actor: "Mina Fujimoto", initials: "MF", role: "Kiln Fulfillment", timestamp: "Dec 1 · 13:05 JST", summary: "Wrapped the Bizen espresso tumblers in double-flute sleeves and added a hand-stamped brew ratio card for the Yirgacheffe lot.", }, { id: "act-2", actor: "Fraud & Risk Engine", initials: "FR", role: "Automated", timestamp: "Dec 1 · 08:43 PST", summary: "Completed automated payment verification with low risk score (12 / 100).", details: [ "3DS 2.2 cryptogram validated for Mastercard •••• 4821", "Shipping address matches 5 prior delivered orders", ], }, { id: "act-1", actor: "Kenji Takahashi", initials: "KT", role: "Customer", timestamp: "Dec 1 · 08:42 PST", summary: "Placed order #KRN-90418 with loyalty code ROASTCLUB10.", },];
const ORDER_DOCUMENTS = [ { id: "doc-invoice", title: "Commercial Invoice", filename: "INV-KRN-90418.pdf", meta: "Issued Dec 1, 2026 · Paid", }, { id: "doc-packing", title: "Kiln Packing Slip", filename: "PACK-KRN-90418.pdf", meta: "6 units · 1.75 kg gross", }, { id: "doc-customs", title: "Export Customs Declaration", filename: "CN23-KRN-90418.pdf", meta: "HS 6912.00 / 0901.21 · Pre-cleared", },];
function formatCurrency(amount: number) { return `$${amount.toFixed(2)}`;}
function getInitials(name: string) { const parts = name.trim().split(/\s+/).filter(Boolean); if (parts.length === 0) return "KT"; if (parts.length === 1) return parts[0]!.slice(0, 2).toUpperCase(); return `${parts[0]![0] ?? ""}${parts[parts.length - 1]![0] ?? ""}`.toUpperCase();}
const THUMBNAIL_SRC: Record<ProductArtworkKind, string> = { dripper: "/images/blocks/order-detail/dripper.webp", tumbler: "/images/blocks/order-detail/tumbler.webp", coffee: "/images/blocks/order-detail/coffee.webp", tray: "/images/blocks/order-detail/tray.webp",};
function ProductThumbnail({ kind }: { kind: ProductArtworkKind }) { return ( <img src={THUMBNAIL_SRC[kind]} alt="" width={48} height={48} loading="lazy" decoding="async" {...stylex.props(styles.thumbnailImage)} /> );}
function ChevronRightSeparatorIcon() { return ( <Breadcrumb.SeparatorIcon viewBox="0 0 16 16" fill="none"> <path d="M6 3.5 10.5 8 6 12.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> </Breadcrumb.SeparatorIcon> );}
function CopyIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="7" y="7" width="9.5" height="9.5" rx="1.8" /> <path d="M13 7V5.3A1.8 1.8 0 0 0 11.2 3.5H5.3A1.8 1.8 0 0 0 3.5 5.3v5.9A1.8 1.8 0 0 0 5.3 13H7" /> </Icon> );}
function CheckIcon({ size = "sm" }: { size?: "xs" | "sm" }) { return ( <Icon size={size} viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="m4.5 10.5 3.5 3.5 7.5-8" /> </Icon> );}
function DownloadIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M10 3.5v8.5" /> <path d="m6.5 8.8 3.5 3.5 3.5-3.5" /> <path d="M3.8 14.2v1.3a1.5 1.5 0 0 0 1.5 1.5h9.4a1.5 1.5 0 0 0 1.5-1.5v-1.3" /> </Icon> );}
function MoreHorizontalIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" > <circle cx="4.5" cy="10" r="1.4" /> <circle cx="10" cy="10" r="1.4" /> <circle cx="15.5" cy="10" r="1.4" /> </Icon> );}
function PanelRightIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="2.5" y="3.5" width="15" height="13" rx="2" /> <path d="M12.5 3.5v13" /> </Icon> );}
function TruckIcon() { return ( <Icon size="xs" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M2.5 5.5h9v8h-9z" /> <path d="M11.5 8.5h3.3l2.7 2.8v2.2h-6" /> <circle cx="5.8" cy="14.5" r="1.6" /> <circle cx="14.6" cy="14.5" r="1.6" /> </Icon> );}
function WarningTriangleIcon() { return ( <Icon size="md" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z" /> <path d="M12 9v4" /> <path d="M12 17h.01" /> </Icon> );}
function CloseXIcon() { return ( <Icon size="xs" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" aria-hidden="true" > <path d="m5.5 5.5 9 9m0-9-9 9" /> </Icon> );}
function ChevronDownIcon({ rotated }: { rotated?: boolean }) { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" style={rotated ? styles.chevronOpen : styles.chevronClosed} > <path d="m5.5 7.5 4.5 5 4.5-5" /> </Icon> );}
function CalendarIcon() { return ( <Icon size="xs" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <rect x="3" y="4.5" width="14" height="12.5" rx="2" /> <path d="M6.5 2.8v3M13.5 2.8v3M3 8.5h14" /> </Icon> );}
function ClockDotIcon() { return ( <Icon size="xs" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="10" cy="10" r="6.5" /> <path d="M10 6.8v3.4l2.2 1.4" /> </Icon> );}
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, containerName: "order-detail", containerType: "inline-size", display: "flex", flexDirection: "column", fontFamily: fonts.body, minHeight: "100%", width: "100%", }, headerBand: { backgroundColor: semanticColors.bgSurface, borderBottomColor: semanticColors.border, borderBottomStyle: "solid", borderBottomWidth: "1px", paddingTop: spacing._5, paddingBottom: 0, paddingInline: { default: spacing._6, [COMPACT]: spacing._4, }, width: "100%", }, container: { marginInline: "auto", maxWidth: "78rem", width: "100%", }, headerTopRow: { alignItems: { default: "flex-start", [NARROW]: "stretch", }, flexDirection: { default: "row", [NARROW]: "column", }, }, orderHeading: { marginBlock: 0, fontVariantNumeric: "tabular-nums", }, metaIconRow: { color: semanticColors.fgMuted, }, metaDot: { userSelect: "none", }, shrink0: { flexShrink: 0, }, fullWidth: { width: "100%", }, noWrap: { whiteSpace: "nowrap", }, preLine: { whiteSpace: "pre-line", }, mb4: { marginBottom: spacing._4, }, pt2: { paddingTop: spacing._2, }, leadingSm: { lineHeight: lineHeights.sm, }, plainList: { listStyle: "none", marginBlock: 0, paddingInlineStart: 0, }, panelToggleDesktop: { display: { default: "inline-flex", [NARROW]: "none", }, marginBottom: spacing._1, }, bodyShell: { flex: 1, paddingBlock: { default: spacing._6, [COMPACT]: spacing._4, }, paddingInline: { default: spacing._6, [COMPACT]: spacing._4, }, width: "100%", }, workspaceGrid: { gridTemplateColumns: { default: "minmax(0, 1fr) 21rem", [NARROW]: "minmax(0, 1fr)", }, }, tabPanelFlush: { paddingBlock: 0, paddingInline: 0, }, cardHeaderRow: { alignItems: "center", display: "flex", flexDirection: "row", flexWrap: "wrap", gap: spacing._3, justifyContent: "space-between", }, cardTitleReset: { marginBlock: 0, }, tableScroller: { overflowX: "auto", width: "100%", }, tableRowInteractive: { cursor: "pointer", backgroundColor: { default: "transparent", ":hover": semanticColors.bgSubtle, }, }, cellMiddle: { verticalAlign: "middle", }, cellNumericHeader: { textAlign: "end", whiteSpace: "nowrap", }, cellNumericStrong: { color: semanticColors.fg, fontVariantNumeric: "tabular-nums", fontWeight: fontWeights.medium, textAlign: "end", verticalAlign: "middle", whiteSpace: "nowrap", }, cellNumericMuted: { color: semanticColors.fgMuted, fontVariantNumeric: "tabular-nums", textAlign: "end", verticalAlign: "middle", whiteSpace: "nowrap", }, productCell: { minWidth: "15rem", paddingBlock: spacing._1, }, thumbnailImage: { borderColor: semanticColors.border, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", display: "block", flexShrink: 0, height: "3rem", objectFit: "cover", width: "3rem", }, dataListRow: { justifyContent: "space-between", width: "100%", }, trackingToolbar: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", marginBottom: spacing._5, paddingBlock: spacing._3, paddingInline: spacing._3_5, }, timelineLastContent: { paddingBottom: 0, }, indicatorCompleted: { backgroundColor: semanticColors.bgSuccess, color: semanticColors.fgSuccess, }, indicatorCurrent: { backgroundColor: semanticColors.bgInfo, color: semanticColors.fgInfo, }, indicatorUpcoming: { backgroundColor: semanticColors.bgMuted, color: semanticColors.fgSubtle, }, indicatorCancelled: { backgroundColor: semanticColors.bgError, color: semanticColors.fgError, }, collapsibleTrigger: { alignItems: "center", appearance: "none", backgroundColor: "transparent", borderWidth: 0, color: semanticColors.fg, cursor: "pointer", display: "flex", fontFamily: fonts.body, fontSize: fontSizes.sm, fontWeight: fontWeights.medium, justifyContent: "space-between", paddingBlock: spacing._1, paddingInline: 0, width: "100%", }, chevronClosed: { color: semanticColors.fgMuted, transform: "rotate(0deg)", transitionDuration: "180ms", transitionProperty: "transform", }, chevronOpen: { color: semanticColors.fgMuted, transform: "rotate(180deg)", transitionDuration: "180ms", transitionProperty: "transform", }, sideCardFooter: { justifyContent: "space-between", }, documentRow: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", paddingBlock: spacing._3, paddingInline: spacing._3_5, }, activityCard: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.borderSubtle, borderRadius: semanticRadii.control, borderStyle: "solid", borderWidth: "1px", flex: 1, paddingBlock: spacing._3, paddingInline: spacing._3_5, }, detailBullet: { backgroundColor: semanticColors.borderEmphasized, borderRadius: radii.full, display: "inline-block", flexShrink: 0, height: "4px", width: "4px", },});
export interface OrderDetailProps extends StyleOverrideProps { /** Human-readable order identifier shown in the breadcrumb and page title. */ orderNumber?: string; /** Merchant or studio name paired with the order header. */ storeName?: string; /** Initial fulfillment state for the interactive demo. */ initialStatus?: OrderStatus; /** Carrier service label displayed in the shipment card. */ carrier?: string; /** Carrier tracking number copied by the tracking action. */ trackingNumber?: string; /** Customer full name. */ customerName?: string; /** Customer contact email address. */ customerEmail?: string; /** Customer contact phone number. */ customerPhone?: string; /** Multi-line shipping destination address. */ shippingAddress?: string; /** Billing address summary or full address. */ billingAddress?: string; /** Masked payment instrument description. */ paymentMethod?: string; /** Line items rendered in the order items table. */ items?: OrderLineItem[]; /** Called when the user copies the carrier tracking number. */ onCopyTracking?: (trackingNumber: string) => void; /** Called when the user triggers an invoice download. */ onDownloadInvoice?: (orderNumber: string) => void; /** Called when the user confirms order cancellation in the alert dialog. */ onCancelOrder?: (orderNumber: string) => void;}
/** * OrderDetail — commerce order detail workspace combining breadcrumb * navigation, order status chrome, itemized line-item table with self-contained * vector thumbnails, invoice & payment summary, live shipment tracking * timeline, customer/shipping/billing side cards, collapsible risk notes, * cancel-order confirmation dialog, and toast feedback. */export function OrderDetail({ orderNumber = "#KRN-90418", storeName = "Kuro Roastery & Kiln", initialStatus = "in_transit", carrier = "Yamato Express Priority", trackingNumber = "KRN-JP-8841-2904", customerName = "Kenji Takahashi", customerEmail = "kenji.takahashi@harborcraft.io", customerPhone = "+1 (206) 555-0194", shippingAddress = "412 Western Ave, Suite 308\nSeattle, WA 98109\nUnited States", billingAddress = "Same as shipping address", paymentMethod = "Apple Pay · Mastercard •••• 4821", items = DEFAULT_ITEMS, onCopyTracking, onDownloadInvoice, onCancelOrder, palette, style,}: OrderDetailProps) { const queue = useMemo(() => Toast.createToaster(), []); const [orderStatus, setOrderStatus] = useState<OrderStatus>(initialStatus); const [activeTab, setActiveTab] = useState<OrderTab>("overview"); const [showSidePanel, setShowSidePanel] = useState(true); const [cancelDialogOpen, setCancelDialogOpen] = useState(false); const [copiedTracking, setCopiedTracking] = useState(false); const [notesOpen, setNotesOpen] = useState(true); const [riskOpen, setRiskOpen] = useState(true); const [activityLog, setActivityLog] = useState<ActivityEntry[]>(INITIAL_ACTIVITY); const copyTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => { return () => { if (copyTimerRef.current) { clearTimeout(copyTimerRef.current); } }; }, []);
const totals = useMemo(() => { const unitCount = items.reduce((sum, item) => sum + item.quantity, 0); const totalWeightGrams = items.reduce((sum, item) => sum + item.weightGrams, 0); const subtotal = items.reduce((sum, item) => sum + item.unitPrice * item.quantity, 0); const discount = Math.round(subtotal * 0.1 * 100) / 100; const shipping = 14; const tax = Math.round((subtotal - discount) * 0.085 * 100) / 100; const total = subtotal - discount + shipping + tax; return { unitCount, totalWeightKg: (totalWeightGrams / 1000).toFixed(2), subtotal, discount, shipping, tax, total, }; }, [items]);
const shipmentEvents = useMemo<ShipmentEvent[]>(() => { if (orderStatus === "delivered") { return BASE_SHIPMENT_EVENTS.map((event) => event.id === "ship-delivery" ? { ...event, title: "Delivered · Signed by K. Takahashi", timestamp: "Dec 2 · 15:18 PST", detail: "Left with reception desk at 412 Western Ave, Suite 308.", state: "completed", } : { ...event, state: "completed" }, ); }
if (orderStatus === "cancelled") { return [ { id: "ship-cancelled", title: "Order cancelled & carrier intercept issued", location: "Sea-Tac Distribution Hub, WA", timestamp: "Just now", detail: `Return-to-sender requested with ${carrier}. Full refund of ${formatCurrency(totals.total)} queued.`, state: "cancelled", }, ...BASE_SHIPMENT_EVENTS.filter((event) => event.id !== "ship-delivery").map( (event) => ({ ...event, state: "completed" as const, }), ), ]; }
return BASE_SHIPMENT_EVENTS; }, [carrier, orderStatus, totals.total]);
const statusMeta = useMemo(() => { if (orderStatus === "delivered") { return { label: "Delivered", palette: greenPalette, paymentLabel: "Paid", paymentPalette: greenPalette, etaText: "Delivered Dec 2 · 15:18 PST", }; } if (orderStatus === "cancelled") { return { label: "Cancelled", palette: redPalette, paymentLabel: "Refund pending", paymentPalette: amberPalette, etaText: "Shipment intercepted", }; } return { label: "In transit", palette: bluePalette, paymentLabel: "Paid", paymentPalette: greenPalette, etaText: "Est. delivery Dec 3", }; }, [orderStatus]);
const handleCopyTracking = useCallback(() => { if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) { void navigator.clipboard.writeText(trackingNumber).catch(() => {}); } setCopiedTracking(true); if (copyTimerRef.current) { clearTimeout(copyTimerRef.current); } copyTimerRef.current = setTimeout(() => { setCopiedTracking(false); }, 2000); onCopyTracking?.(trackingNumber); queue.success("Tracking number copied", { description: `${carrier} · ${trackingNumber}`, }); }, [carrier, onCopyTracking, queue, trackingNumber]);
const handleDownloadInvoice = useCallback( (docName?: string) => { onDownloadInvoice?.(orderNumber); queue.info(`Downloading ${docName ?? `INV-${orderNumber.replace("#", "")}.pdf`}`, { description: `Prepared receipt for ${orderNumber} (${formatCurrency(totals.total)}).`, }); }, [onDownloadInvoice, orderNumber, queue, totals.total], );
const handleMarkDelivered = useCallback(() => { if (orderStatus === "delivered") { setOrderStatus("in_transit"); queue.info(`Order ${orderNumber} reopened as in transit`, { description: "Tracking milestones restored to active Sea-Tac hub scan.", }); return; } setOrderStatus("delivered"); setActivityLog((prev) => [ { id: `act-delivered-${Date.now()}`, actor: "Operations Desk", initials: "OD", role: "Fulfillment", timestamp: "Just now", summary: `Marked order ${orderNumber} as delivered and notified ${customerName}.`, }, ...prev, ]); queue.success(`Order ${orderNumber} marked as delivered`, { description: `Delivery confirmation sent to ${customerEmail}.`, }); }, [customerEmail, customerName, orderNumber, orderStatus, queue]);
const handleConfirmCancel = useCallback(() => { setOrderStatus("cancelled"); setCancelDialogOpen(false); setActivityLog((prev) => [ { id: `act-cancel-${Date.now()}`, actor: "Operations Desk", initials: "OD", role: "Fulfillment", timestamp: "Just now", summary: `Cancelled order ${orderNumber} and initiated a ${formatCurrency(totals.total)} refund.`, details: [ `Carrier intercept dispatched for ${trackingNumber}`, `Refund queued to ${paymentMethod}`, ], }, ...prev, ]); onCancelOrder?.(orderNumber); queue.warning(`Order ${orderNumber} cancelled`, { description: `Carrier intercept issued and ${formatCurrency(totals.total)} refund queued.`, }); }, [onCancelOrder, orderNumber, paymentMethod, queue, totals.total, trackingNumber]);
const handleRestoreOrder = useCallback(() => { setOrderStatus("in_transit"); queue.success(`Order ${orderNumber} restored`, { description: "Shipment tracking resumed as in transit.", }); }, [orderNumber, queue]);
const customerInitials = useMemo(() => getInitials(customerName), [customerName]);
const itemsCard = ( <Card.Root variant="outline" size="md"> <Card.Header style={styles.cardHeaderRow}> <HStack wrap="wrap" gap="2"> <Card.Title style={styles.cardTitleReset}>Order items</Card.Title> <Badge variant="subtle" size="sm" palette={statusMeta.palette}> {orderStatus === "cancelled" ? "Cancelled" : `${totals.unitCount} of ${totals.unitCount} packed`} </Badge> </HStack> <HStack wrap="wrap" gap="2"> <Button variant="ghost" size="sm" onClick={() => handleDownloadInvoice(`PACK-${orderNumber.replace("#", "")}.pdf`)} > Packing slip </Button> {orderStatus === "cancelled" ? ( <Button variant="surface" size="sm" onClick={handleRestoreOrder}> Restore order </Button> ) : ( <Button variant="surface" size="sm" onClick={handleMarkDelivered}> {orderStatus === "delivered" ? "Reopen transit" : "Mark delivered"} </Button> )} </HStack> </Card.Header> <Card.Body> <div {...stylex.props(styles.tableScroller)}> <Table.Root variant="line" size="md"> <Table.Header> <Table.Row> <Table.ColumnHeader>Item</Table.ColumnHeader> <Table.ColumnHeader style={styles.cellNumericHeader}>Qty</Table.ColumnHeader> <Table.ColumnHeader style={styles.cellNumericHeader}>Unit</Table.ColumnHeader> <Table.ColumnHeader style={styles.cellNumericHeader}>Total</Table.ColumnHeader> </Table.Row> </Table.Header> <Table.Body> {items.map((item) => ( <Table.Row key={item.id} style={styles.tableRowInteractive} onClick={() => queue.info(item.name, { description: `SKU ${item.sku} · ${item.variant} · ${item.weightGrams} g`, }) } > <Table.Cell style={styles.cellMiddle}> <HStack gap="3" style={styles.productCell}> <ProductThumbnail kind={item.artwork} /> <VStack gap="0.5"> <Text render={<span />} size="sm" weight="medium"> {item.name} </Text> <HStack wrap="wrap" gap="1.5"> <Code variant="subtle" size="xs" palette={grayPalette}> {item.sku} </Code> <Text render={<span />} variant="caption"> {item.variant} </Text> </HStack> </VStack> </HStack> </Table.Cell> <Table.Cell style={styles.cellNumericMuted}>×{item.quantity}</Table.Cell> <Table.Cell style={styles.cellNumericMuted}> {formatCurrency(item.unitPrice)} </Table.Cell> <Table.Cell style={styles.cellNumericStrong}> {formatCurrency(item.unitPrice * item.quantity)} </Table.Cell> </Table.Row> ))} </Table.Body> </Table.Root> </div> </Card.Body> </Card.Root> );
const invoiceCard = ( <Card.Root variant="outline" size="md"> <Card.Header style={styles.cardHeaderRow}> <HStack wrap="wrap" gap="2"> <Card.Title style={styles.cardTitleReset}>Payment & invoice</Card.Title> <Badge variant="subtle" size="sm" palette={statusMeta.paymentPalette}> {statusMeta.paymentLabel} </Badge> </HStack> <HStack wrap="wrap" gap="2"> <Button variant="ghost" size="sm" onClick={() => queue.success("Receipt emailed", { description: `Sent invoice summary for ${orderNumber} to ${customerEmail}.`, }) } > Email receipt </Button> <Button variant="surface" size="sm" onClick={() => handleDownloadInvoice()}> <DownloadIcon /> Download PDF </Button> </HStack> </Card.Header> <Card.Body> <VStack gap="4"> <DataList.Root orientation="horizontal" size="md"> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Subtotal</DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <Text render={<span />} variant="muted" size="sm"> {totals.unitCount} units ({items.length} SKUs) </Text> <Text render={<span />} size="sm" tabular="true" style={styles.noWrap}> {formatCurrency(totals.subtotal)} </Text> </HStack> </DataList.ItemValue> </DataList.Item>
<DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Discount</DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <Text render={<span />} variant="muted" size="sm"> Loyalty code <Code variant="subtle" size="xs" palette={grayPalette}>ROASTCLUB10</Code> </Text> <Text render={<span />} size="sm" tone="success" tabular="true" style={styles.noWrap} > −{formatCurrency(totals.discount)} </Text> </HStack> </DataList.ItemValue> </DataList.Item>
<DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Shipping</DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <Text render={<span />} variant="muted" size="sm"> {carrier} ({totals.totalWeightKg} kg) </Text> <Text render={<span />} size="sm" tabular="true" style={styles.noWrap}> {formatCurrency(totals.shipping)} </Text> </HStack> </DataList.ItemValue> </DataList.Item>
<DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Tax</DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <Text render={<span />} variant="muted" size="sm"> WA destination tax (8.5%) </Text> <Text render={<span />} size="sm" tabular="true" style={styles.noWrap}> {formatCurrency(totals.tax)} </Text> </HStack> </DataList.ItemValue> </DataList.Item>
<DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Total</DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <Text render={<span />} variant="muted" size="sm"> USD · Settled </Text> <Text render={<span />} size="md" weight="semibold" tabular="true" style={styles.noWrap} > {formatCurrency(totals.total)} </Text> </HStack> </DataList.ItemValue> </DataList.Item> </DataList.Root>
<Separator />
<DataList.Root orientation="horizontal" size="sm"> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel> {orderStatus === "cancelled" ? "Refund target" : "Paid by customer"} </DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <span>{paymentMethod}</span> <Text render={<span />} size="sm" tabular="true" style={styles.noWrap}> {orderStatus === "cancelled" ? `−${formatCurrency(totals.total)}` : formatCurrency(totals.total)} </Text> </HStack> </DataList.ItemValue> </DataList.Item> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Settlement ref</DataList.ItemLabel> <DataList.ItemValue> <HStack justify="between" gap="3" style={styles.fullWidth}> <Code variant="subtle" size="xs" palette={grayPalette}> KR-90418-OK </Code> <Text render={<span />} variant="muted" size="sm"> Dec 1, 2026 · 08:42 PST </Text> </HStack> </DataList.ItemValue> </DataList.Item> </DataList.Root> </VStack> </Card.Body> </Card.Root> );
const shipmentTimelineCard = ( <Card.Root variant="outline" size="md"> <Card.Header style={styles.cardHeaderRow}> <HStack wrap="wrap" gap="2"> <Card.Title style={styles.cardTitleReset}>Shipment tracking</Card.Title> <Status.Root size="sm" palette={statusMeta.palette}> <Status.Indicator /> {statusMeta.label} </Status.Root> </HStack> <Button variant="surface" size="sm" onClick={handleCopyTracking}> {copiedTracking ? <CheckIcon size="sm" /> : <CopyIcon />} {copiedTracking ? "Copied" : "Copy tracking"} </Button> </Card.Header> <Card.Body> <HStack wrap="wrap" justify="between" gap="3" style={styles.trackingToolbar}> <VStack gap="1"> <Text render={<span />} variant="caption"> {carrier} · Parcel weight {totals.totalWeightKg} kg </Text> <HStack wrap="wrap" gap="2"> <Code variant="surface" size="sm" palette={grayPalette}> {trackingNumber} </Code> <Text render={<span />} variant="caption"> {statusMeta.etaText} </Text> </HStack> </VStack> <Badge variant="subtle" size="sm" palette={statusMeta.palette}> {orderStatus === "cancelled" ? "Intercept active" : "Signature required"} </Badge> </HStack>
<Timeline.Root variant="subtle" size="lg"> {shipmentEvents.map((event, index) => { const isLast = index === shipmentEvents.length - 1; const indicatorStyle = event.state === "completed" ? styles.indicatorCompleted : event.state === "current" ? styles.indicatorCurrent : event.state === "cancelled" ? styles.indicatorCancelled : styles.indicatorUpcoming;
return ( <Timeline.Item key={event.id}> <Timeline.Connector> {!isLast ? <Timeline.Separator /> : null} <Timeline.Indicator style={indicatorStyle}> {event.state === "completed" ? ( <CheckIcon size="xs" /> ) : event.state === "current" ? ( <TruckIcon /> ) : event.state === "cancelled" ? ( <CloseXIcon /> ) : ( <ClockDotIcon /> )} </Timeline.Indicator> </Timeline.Connector> <Timeline.Content style={isLast ? styles.timelineLastContent : undefined}> <Timeline.Title> <HStack align="baseline" wrap="wrap" justify="between" gap="2" style={styles.fullWidth} > <span>{event.title}</span> <Text render={<span />} variant="caption" tone="subtle" weight="normal" tabular="true" > {event.timestamp} </Text> </HStack> </Timeline.Title> <Text render={<span />} variant="caption" weight="medium"> {event.location} </Text> <Timeline.Description>{event.detail}</Timeline.Description> </Timeline.Content> </Timeline.Item> ); })} </Timeline.Root> </Card.Body> </Card.Root> );
const sidePanel = ( <VStack render={<aside aria-label="Order summary sidebar" />} gap="5"> <Card.Root variant="outline" size="md"> <Card.Header style={styles.cardHeaderRow}> <Card.Title style={styles.cardTitleReset}>Customer</Card.Title> <Badge variant="subtle" size="xs" palette={amberPalette}> 6 orders </Badge> </Card.Header> <Card.Body> <HStack gap="3" style={styles.mb4}> <Avatar.Root size="md" variant="subtle" palette={amberPalette}> <Avatar.Fallback>{customerInitials}</Avatar.Fallback> </Avatar.Root> <VStack gap="0.5"> <Text render={<span />} size="sm" weight="semibold"> {customerName} </Text> <Text render={<span />} variant="caption"> Roast Club collector · Seattle, WA </Text> </VStack> </HStack>
<DataList.Root orientation="vertical" size="sm"> <DataList.Item> <DataList.ItemLabel>Email</DataList.ItemLabel> <DataList.ItemValue>{customerEmail}</DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Phone</DataList.ItemLabel> <DataList.ItemValue>{customerPhone}</DataList.ItemValue> </DataList.Item> </DataList.Root> </Card.Body> </Card.Root>
<Card.Root variant="outline" size="md"> <Card.Header> <Card.Title style={styles.cardTitleReset}>Shipping & billing</Card.Title> </Card.Header> <Card.Body> <DataList.Root orientation="vertical" size="sm"> <DataList.Item> <DataList.ItemLabel>Shipping address</DataList.ItemLabel> <DataList.ItemValue> <Text render={<span />} size="sm" style={styles.preLine}> {shippingAddress} </Text> </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Tracking code</DataList.ItemLabel> <DataList.ItemValue> <HStack wrap="wrap" gap="1.5"> <Code variant="subtle" size="xs" palette={grayPalette}> {trackingNumber} </Code> <IconButton variant="ghost" size="xs" onClick={handleCopyTracking} aria-label="Copy tracking number" > {copiedTracking ? <CheckIcon size="xs" /> : <CopyIcon />} </IconButton> </HStack> </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Billing address</DataList.ItemLabel> <DataList.ItemValue> <Text render={<span />} variant="muted" size="sm"> {billingAddress} </Text> </DataList.ItemValue> </DataList.Item> <DataList.Item> <DataList.ItemLabel>Payment method</DataList.ItemLabel> <DataList.ItemValue>{paymentMethod}</DataList.ItemValue> </DataList.Item> </DataList.Root> </Card.Body> </Card.Root>
<Card.Root variant="outline" size="md"> <Card.Body> <VStack gap="3"> <Collapsible.Root open={notesOpen} onOpenChange={setNotesOpen}> <Collapsible.Trigger render={<button type="button" {...stylex.props(styles.collapsibleTrigger)} />} > <span>Fulfillment notes</span> <ChevronDownIcon rotated={notesOpen} /> </Collapsible.Trigger> <Collapsible.Panel> <Text variant="muted" size="sm" style={styles.pt2}> Double-box the Bizen espresso tumblers with corrugated inserts. Roast batch #26-44 was sealed on Nov 30 — include the Kyoto pour-over brew card inside the outer tray. </Text> </Collapsible.Panel> </Collapsible.Root>
<Separator />
<Collapsible.Root open={riskOpen} onOpenChange={setRiskOpen}> <Collapsible.Trigger render={<button type="button" {...stylex.props(styles.collapsibleTrigger)} />} > <span>Fraud & risk analysis</span> <ChevronDownIcon rotated={riskOpen} /> </Collapsible.Trigger> <Collapsible.Panel> <VStack gap="2.5" style={styles.pt2}> <HStack justify="between" gap="2"> <Status.Root size="sm" palette={greenPalette}> <Status.Indicator /> Low risk </Status.Root> <Text render={<span />} variant="caption" weight="medium" tabular="true"> 12 / 100 </Text> </HStack> <Progress.Root value={12} max={100} size="sm" shape="full" palette={greenPalette} aria-label="Order risk score" > <Progress.Track> <Progress.Range /> </Progress.Track> </Progress.Root> <Text variant="caption" style={styles.leadingSm}> Recommendation: Fulfill order. Billing ZIP, 3DS cryptogram, and repeat customer shipping history all match. </Text> </VStack> </Collapsible.Panel> </Collapsible.Root> </VStack> </Card.Body>
{orderStatus !== "cancelled" ? ( <Card.Footer style={styles.sideCardFooter}> <Text render={<span />} variant="caption"> Need to halt dispatch? </Text> <Button variant="ghost" size="xs" palette={redPalette} onClick={() => setCancelDialogOpen(true)} > Cancel order… </Button> </Card.Footer> ) : null} </Card.Root> </VStack> );
return ( <div {...stylex.props(palette, styles.root, style)}> <Tabs.Root value={activeTab} onValueChange={setActiveTab} variant="line" size="md" palette={accentPalette} style={styles.fullWidth} > <header {...stylex.props(styles.headerBand)}> <VStack gap="4" style={styles.container}> <Breadcrumb.Root size="sm" aria-label="Breadcrumb"> <Breadcrumb.List> <Breadcrumb.Item> <Breadcrumb.Link href="#storefront" onClick={(event) => { event.preventDefault(); queue.info(storeName, { description: "Switched breadcrumb context to storefront overview.", }); }} > {storeName} </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true"> <ChevronRightSeparatorIcon /> </Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.Link href="#orders" onClick={(event) => { event.preventDefault(); queue.info("All orders", { description: "Viewing 148 recent studio orders in the demo workspace.", }); }} > Orders </Breadcrumb.Link> </Breadcrumb.Item> <Breadcrumb.Separator aria-hidden="true"> <ChevronRightSeparatorIcon /> </Breadcrumb.Separator> <Breadcrumb.Item> <Breadcrumb.CurrentLink aria-current="page"> Order {orderNumber} </Breadcrumb.CurrentLink> </Breadcrumb.Item> </Breadcrumb.List> </Breadcrumb.Root>
<Stack justify="between" gap="4" style={styles.headerTopRow}> <VStack gap="2"> <HStack wrap="wrap" gap="2.5"> <Heading render={<h1 />} size="2xl" style={styles.orderHeading}> Order {orderNumber} </Heading> <Badge variant="subtle" size="sm" palette={statusMeta.palette}> {statusMeta.label} </Badge> <Status.Root size="sm" palette={statusMeta.paymentPalette}> <Status.Indicator /> {statusMeta.paymentLabel} </Status.Root> </HStack>
<HStack wrap="wrap" gap="2"> <Text render={<span />} size="sm" weight="medium"> {totals.unitCount} items </Text> <Text render={<span />} variant="subtle" size="sm" style={styles.metaDot} aria-hidden="true" > · </Text> <HStack render={<span />} gap="1.5"> <Avatar.Root size="xs" variant="subtle" palette={amberPalette}> <Avatar.Fallback>{customerInitials}</Avatar.Fallback> </Avatar.Root> <Text render={<span />} size="sm" weight="medium"> {customerName} </Text> </HStack> <Text render={<span />} variant="subtle" size="sm" style={styles.metaDot} aria-hidden="true" > · </Text> <HStack render={<span />} gap="1.5" style={styles.metaIconRow}> <CalendarIcon /> <Text render={<span />} variant="muted" size="sm"> Dec 1, 2026 · 08:42 PST </Text> </HStack> <Text render={<span />} variant="subtle" size="sm" style={styles.metaDot} aria-hidden="true" > · </Text> <Text render={<span />} variant="muted" size="sm"> {statusMeta.etaText} </Text> </HStack> </VStack>
<HStack wrap="wrap" gap="2" style={styles.shrink0}> <Button variant="surface" size="sm" onClick={handleCopyTracking}> {copiedTracking ? <CheckIcon size="sm" /> : <CopyIcon />} {copiedTracking ? "Copied tracking" : "Copy tracking"} </Button>
<Button variant="surface" size="sm" onClick={() => handleDownloadInvoice()}> <DownloadIcon /> Invoice </Button>
<Menu.Root size="sm"> <Menu.Trigger render={ <IconButton variant="surface" size="sm" aria-label="More order actions" /> } > <MoreHorizontalIcon /> </Menu.Trigger> <Menu.Content align="end"> <Menu.Group> <Menu.GroupLabel>Order actions</Menu.GroupLabel> <Menu.Item onSelect={() => queue.success("Receipt email queued", { description: `Sending PDF copy to ${customerEmail}.`, }) } > <Menu.ItemText>Send invoice email</Menu.ItemText> </Menu.Item> <Menu.Item onSelect={() => handleDownloadInvoice(`PACK-${orderNumber.replace("#", "")}.pdf`) } > <Menu.ItemText>Print packing slip</Menu.ItemText> </Menu.Item> {orderStatus !== "cancelled" ? ( <Menu.Item onSelect={handleMarkDelivered}> <Menu.ItemText> {orderStatus === "delivered" ? "Reopen as in transit" : "Mark as delivered"} </Menu.ItemText> </Menu.Item> ) : ( <Menu.Item onSelect={handleRestoreOrder}> <Menu.ItemText>Restore order</Menu.ItemText> </Menu.Item> )} </Menu.Group> <Menu.Separator /> <Menu.Item destructive disabled={orderStatus === "cancelled"} onSelect={() => setCancelDialogOpen(true)} > <Menu.ItemText>Cancel order…</Menu.ItemText> </Menu.Item> </Menu.Content> </Menu.Root> </HStack> </Stack>
<HStack justify="between" gap="2"> <Tabs.List aria-label="Order sections"> <Tabs.Tab value="overview">Overview</Tabs.Tab> <Tabs.Tab value="shipment"> Shipment <Badge variant="subtle" size="xs" palette={grayPalette}> {shipmentEvents.length} </Badge> </Tabs.Tab> <Tabs.Tab value="activity"> Invoices & activity <Badge variant="subtle" size="xs" palette={grayPalette}> {activityLog.length} </Badge> </Tabs.Tab> </Tabs.List>
<Button variant="ghost" size="sm" style={styles.panelToggleDesktop} onClick={() => setShowSidePanel((prev) => !prev)} aria-label={showSidePanel ? "Hide details sidebar" : "Show details sidebar"} aria-pressed={showSidePanel} > <PanelRightIcon /> {showSidePanel ? "Hide details" : "Show details"} </Button> </HStack> </VStack> </header>
<main {...stylex.props(styles.bodyShell)}> <div {...stylex.props(styles.container)}> <Grid align="start" gap="6" style={showSidePanel ? styles.workspaceGrid : undefined} > <VStack gap="5"> <Tabs.Panel value="overview" style={styles.tabPanelFlush}> <VStack gap="5"> {itemsCard} {invoiceCard} {shipmentTimelineCard} </VStack> </Tabs.Panel>
<Tabs.Panel value="shipment" style={styles.tabPanelFlush}> <VStack gap="5"> {shipmentTimelineCard} <Card.Root variant="outline" size="md"> <Card.Header> <Card.Title style={styles.cardTitleReset}>Parcel manifest</Card.Title> </Card.Header> <Card.Body> <DataList.Root orientation="horizontal" size="md"> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Carrier</DataList.ItemLabel> <DataList.ItemValue>{carrier}</DataList.ItemValue> </DataList.Item> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Origin workshop</DataList.ItemLabel> <DataList.ItemValue> Kuro Roastery & Kiln · Higashiyama-ku, Kyoto </DataList.ItemValue> </DataList.Item> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Dimensions</DataList.ItemLabel> <DataList.ItemValue> 34 × 26 × 18 cm · {totals.totalWeightKg} kg </DataList.ItemValue> </DataList.Item> <DataList.Item style={styles.dataListRow}> <DataList.ItemLabel>Packaging</DataList.ItemLabel> <DataList.ItemValue> Double-walled recycled kraft · Fragile ceramic seal </DataList.ItemValue> </DataList.Item> </DataList.Root> </Card.Body> </Card.Root> </VStack> </Tabs.Panel>
<Tabs.Panel value="activity" style={styles.tabPanelFlush}> <VStack gap="5"> <Card.Root variant="outline" size="md"> <Card.Header> <Card.Title style={styles.cardTitleReset}> Invoices & export documents </Card.Title> </Card.Header> <Card.Body> <VStack gap="2.5"> {ORDER_DOCUMENTS.map((doc) => ( <HStack key={doc.id} wrap="wrap" justify="between" gap="3" style={styles.documentRow} > <VStack gap="0.5"> <Text render={<span />} size="sm" weight="medium"> {doc.title} </Text> <Text render={<span />} variant="caption"> {doc.filename} · {doc.meta} </Text> </VStack> <Button variant="surface" size="xs" onClick={() => handleDownloadInvoice(doc.filename)} > <DownloadIcon /> Download </Button> </HStack> ))} </VStack> </Card.Body> </Card.Root>
<Card.Root variant="outline" size="md"> <Card.Header> <Card.Title style={styles.cardTitleReset}>Order activity log</Card.Title> </Card.Header> <Card.Body> <VStack gap="3"> {activityLog.map((entry) => ( <HStack key={entry.id} align="start" gap="3"> <Avatar.Root size="sm" variant="subtle" palette={grayPalette}> <Avatar.Fallback>{entry.initials}</Avatar.Fallback> </Avatar.Root> <VStack gap="1.5" style={styles.activityCard}> <HStack wrap="wrap" justify="between" gap="2"> <HStack wrap="wrap" gap="2"> <Text render={<span />} size="sm" weight="medium"> {entry.actor} </Text> <Badge variant="subtle" size="xs" palette={grayPalette}> {entry.role} </Badge> </HStack> <Text render={<span />} variant="caption" tone="subtle" weight="normal" tabular="true" > {entry.timestamp} </Text> </HStack> <Text variant="muted" size="sm"> {entry.summary} </Text> {entry.details ? ( <VStack render={<ul />} gap="1" style={styles.plainList}> {entry.details.map((detail) => ( <HStack key={detail} render={<li />} gap="1.5"> <span {...stylex.props(styles.detailBullet)} aria-hidden="true" /> <Text render={<span />} variant="caption" tone="subtle"> {detail} </Text> </HStack> ))} </VStack> ) : null} </VStack> </HStack> ))} </VStack> </Card.Body> </Card.Root> </VStack> </Tabs.Panel> </VStack>
{showSidePanel ? sidePanel : null} </Grid> </div> </main> </Tabs.Root>
<AlertDialog.Root open={cancelDialogOpen} onOpenChange={(next) => setCancelDialogOpen(next)} size="sm" > <AlertDialog.Backdrop /> <AlertDialog.Content> <AlertDialog.Header> <AlertDialog.Icon palette={redPalette}> <WarningTriangleIcon /> </AlertDialog.Icon> <AlertDialog.Title>Cancel order {orderNumber}?</AlertDialog.Title> </AlertDialog.Header> <AlertDialog.Body> <AlertDialog.Description> This sends a return-to-sender intercept to {carrier} for tracking{" "} {trackingNumber} and queues a full {formatCurrency(totals.total)} refund back to{" "} {paymentMethod}. </AlertDialog.Description> </AlertDialog.Body> <AlertDialog.Footer> <AlertDialog.Cancel render={<Button variant="surface" size="sm" />}> Keep order </AlertDialog.Cancel> <Button variant="solid" size="sm" palette={redPalette} onClick={handleConfirmCancel} > Cancel order & refund </Button> </AlertDialog.Footer> </AlertDialog.Content> </AlertDialog.Root>
<Toaster toaster={queue} /> </div> );}
Inspired by the Order Detail template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).