feat(mall): run the transaction chain against the live API
Wave 3 of replacing the fixed-data mock adapter: cart, orders, shipments and invoices flip together, so one purchase runs end to end against the backend. - cart: CartItemView carries the line's shop and the SKU's stock, so the cart keeps grouping per shop and the quantity stepper caps at real stock instead of a hard-coded 999 - contract: Shipment.items is optional and Invoice.invoice_no nullable, both matching what the API actually returns. Invoice was declared twice in types.ts and TypeScript merges duplicate interfaces, so the duplicate had to go for the change to take effect at all - an anonymous add-to-cart redirects to /login?redirect=..., and sign-in honours only same-origin paths - the fixed-data adapter learns the new cart fields, and its persisted state key moves to v2 because a cart saved by an older build is no longer valid - order surfaces drop their storeById lookups and keep the generic store label until the public store read arrives Verified end to end: two-shop cart grouping with live shop names, stock caps read from the API, checkout, payment, shipment, delivery confirmation and an issued invoice. Rollback re-verified with every domain on fixed data and the backend stopped. Also checks off Wave 3 in docs/TBD-migrate-wave.md and re-points that file at the mock content that remains. OpenSpec change: openspec/changes/replace-mock-api-wave-3
This commit is contained in:
@@ -89,6 +89,11 @@ export interface CartItem {
|
||||
unit_price_minor: number;
|
||||
currency: string;
|
||||
qty: number;
|
||||
/** Owning shop, so the storefront can group lines without the mock catalog. */
|
||||
shop_id: string;
|
||||
shop_name: LocalizedText;
|
||||
/** Current SKU stock; advisory, since checkout is what enforces it. */
|
||||
stock: number;
|
||||
}
|
||||
|
||||
export interface Cart {
|
||||
@@ -130,7 +135,8 @@ export type InvoiceKind = "personal" | "company";
|
||||
|
||||
export interface Invoice {
|
||||
id: string;
|
||||
invoice_no: string;
|
||||
/** Null until the shop issues the invoice. */
|
||||
invoice_no: string | null;
|
||||
order_id: string;
|
||||
order_no?: string;
|
||||
title: string;
|
||||
@@ -163,7 +169,8 @@ export interface Shipment {
|
||||
carrier: string;
|
||||
tracking_no: string;
|
||||
status: ShipmentStatus;
|
||||
items: { order_item_id: string; qty: number }[];
|
||||
/** Not returned by the API; only shipment creation sends line items. */
|
||||
items?: { order_item_id: string; qty: number }[];
|
||||
shipped_at: string | null;
|
||||
delivered_at: string | null;
|
||||
created_at: string;
|
||||
@@ -171,21 +178,6 @@ export interface Shipment {
|
||||
|
||||
export type InvoiceStatus = "requested" | "issued" | "cancelled";
|
||||
|
||||
export interface Invoice {
|
||||
id: string;
|
||||
invoice_no: string;
|
||||
order_id: string;
|
||||
order_no?: string;
|
||||
title: string;
|
||||
tax_no: string | null;
|
||||
kind: "personal" | "company";
|
||||
amount_minor: number;
|
||||
currency: string;
|
||||
status: InvoiceStatus;
|
||||
issued_at: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface Paged<T> {
|
||||
items: T[];
|
||||
total: number;
|
||||
|
||||
Reference in New Issue
Block a user