import type { CartItem } from "./cart";

// sessionStorage, not localStorage — this is a one-time receipt for the
// tab that just placed the order, not something that should persist
// forever. Written by /checkout's "Jetzt kaufen" submit once
// POST /api/checkout confirms the order was actually persisted in
// Payload (orderNumber/orderDateIso come back from that response, not
// generated locally), read once by /bestellbestaetigung.
export const ORDER_KEY = "ep_last_order";

export type OrderSnapshot = {
  items: CartItem[];
  orderNumber: string;
  orderDateIso: string;
  shippingCost: number;
  paymentMethodTitle: string;
  /** Persisted (not re-derived) so /bestellbestaetigung shows exactly what
   * was actually applied at purchase time, not a fresh re-validation —
   * null/0 when no discount was ever applied. */
  discountCode: string | null;
  discountAmount: number;
};
