@nok-integration/storefront-react 0.19.49 → 0.19.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2885,6 +2885,20 @@ declare function createClient(options: ClientOptions): {
2885
2885
  images?: string[] | undefined;
2886
2886
  return_status?: "reported" | "package_received" | "completed" | undefined;
2887
2887
  }[];
2888
+ returns?: {
2889
+ value: {
2890
+ amount: number;
2891
+ currency: string;
2892
+ };
2893
+ status: "reported" | "package_received" | "completed";
2894
+ currency: string;
2895
+ order_ref: string;
2896
+ headline: string;
2897
+ item_count: number;
2898
+ return_ref: string;
2899
+ reported_at: string;
2900
+ images?: string[] | undefined;
2901
+ }[] | undefined;
2888
2902
  }>;
2889
2903
  get: (orderRef: string) => Promise<{
2890
2904
  status: "packing" | "on_its_way" | "out_for_delivery" | "delivered" | "cancelled";
@@ -4217,6 +4231,14 @@ export declare function OrderListView(props: OrderListViewProps): JSX.Element;
4217
4231
  export declare interface OrderListViewProps {
4218
4232
  /** Opens one order. Without it the rows render as static cards rather than dead links. */
4219
4233
  onOpenOrder?: (orderRef: string) => void;
4234
+ /**
4235
+ * Opens one return, which is its own screen rather than the order's.
4236
+ *
4237
+ * Without it a return row renders as a static card. It is deliberately not defaulted to
4238
+ * `onOpenOrder`: a fan tapping a return is asking about the return, and landing them on
4239
+ * the order is a different answer to the question they asked.
4240
+ */
4241
+ onOpenReturn?: (returnRef: string) => void;
4220
4242
  /** The empty state's call to action — the design's "Continue shopping" button. */
4221
4243
  onStartShopping?: () => void;
4222
4244
  /** Overrides the provider's locale for dates. */
@@ -4247,16 +4269,10 @@ declare const OrderStatus: z.ZodEnum<["confirmed", "packed", "shipped", "deliver
4247
4269
 
4248
4270
  declare type OrderStatus = z.infer<typeof OrderStatus>;
4249
4271
 
4250
- export declare function OrderStatusBadge({ status, returnStatus }: OrderStatusBadgeProps): JSX.Element;
4272
+ export declare function OrderStatusBadge({ status }: OrderStatusBadgeProps): JSX.Element;
4251
4273
 
4252
4274
  export declare interface OrderStatusBadgeProps {
4253
4275
  status: OrderProgressStep;
4254
- /**
4255
- * An open return against this order, when there is one. The engine omits it once every
4256
- * return has completed, so a value here always means "still outstanding" — this component
4257
- * does not have to decide which return statuses count as started.
4258
- */
4259
- returnStatus?: ReturnStatus;
4260
4276
  }
4261
4277
 
4262
4278
  /**
@@ -4581,7 +4597,7 @@ declare const Product: z.ZodObject<{
4581
4597
  }>;
4582
4598
  /**
4583
4599
  * Optional strike-through "was" price for a sale. Additive/optional: the engine only
4584
- * populates it once the pricing source is agreed. Display
4600
+ * populates it once the pricing source is agreed (A2 — pricing contract). Display
4585
4601
  * only; never authoritative. Absent = not on sale.
4586
4602
  */
4587
4603
  compare_at: z.ZodOptional<z.ZodObject<{
@@ -5454,6 +5470,12 @@ declare const ReturnStatus: z.ZodEnum<["reported", "package_received", "complete
5454
5470
 
5455
5471
  declare type ReturnStatus = z.infer<typeof ReturnStatus>;
5456
5472
 
5473
+ export declare function ReturnStatusBadge({ status }: ReturnStatusBadgeProps): JSX.Element;
5474
+
5475
+ export declare interface ReturnStatusBadgeProps {
5476
+ status: ReturnStatus;
5477
+ }
5478
+
5457
5479
  export declare function ReturnTrackingView({ ret, locale: localeProp }: ReturnTrackingViewProps): JSX.Element;
5458
5480
 
5459
5481
  export declare interface ReturnTrackingViewProps {
package/dist/index.mjs CHANGED
@@ -4647,7 +4647,7 @@ function requireOrderTracking() {
4647
4647
  Object.defineProperty(exports, "__esModule", {
4648
4648
  value: true
4649
4649
  });
4650
- exports.ReturnDetail = exports.ReturnItem = exports.ReturnProgressEntry = exports.CreateReturnRequest = exports.ReturnRequestItem = exports.FanReturnReason = exports.RequestCancellationRequest = exports.FanCancelReason = exports.OrderDetail = exports.ReturnSummary = exports.OrderList = exports.OrderSummaryItem = exports.ReturnOutcome = exports.ReturnStatus = exports.OrderItem = exports.OrderTracking = exports.OrderProgressEntry = exports.OrderProgressStep = void 0;
4650
+ exports.ReturnDetail = exports.ReturnItem = exports.ReturnProgressEntry = exports.CreateReturnRequest = exports.ReturnRequestItem = exports.FanReturnReason = exports.RequestCancellationRequest = exports.FanCancelReason = exports.OrderDetail = exports.ReturnSummary = exports.OrderList = exports.ReturnSummaryItem = exports.OrderSummaryItem = exports.ReturnOutcome = exports.ReturnStatus = exports.OrderItem = exports.OrderTracking = exports.OrderProgressEntry = exports.OrderProgressStep = void 0;
4651
4651
  const zod_1 = requireZod();
4652
4652
  const money_1 = requireMoney();
4653
4653
  const ids_1 = requireIds();
@@ -4693,8 +4693,20 @@ function requireOrderTracking() {
4693
4693
  images: zod_1.z.array(common_1.Url).max(3).optional(),
4694
4694
  return_status: exports.ReturnStatus.optional()
4695
4695
  });
4696
+ exports.ReturnSummaryItem = zod_1.z.object({
4697
+ return_ref: zod_1.z.string().min(1),
4698
+ order_ref: ids_1.OrderRef,
4699
+ status: exports.ReturnStatus,
4700
+ reported_at: common_1.Timestamp,
4701
+ currency: money_1.Currency,
4702
+ headline: zod_1.z.string().min(1),
4703
+ value: money_1.Money,
4704
+ item_count: zod_1.z.number().int().nonnegative(),
4705
+ images: zod_1.z.array(common_1.Url).max(3).optional()
4706
+ });
4696
4707
  exports.OrderList = zod_1.z.object({
4697
- orders: zod_1.z.array(exports.OrderSummaryItem)
4708
+ orders: zod_1.z.array(exports.OrderSummaryItem),
4709
+ returns: zod_1.z.array(exports.ReturnSummaryItem).optional()
4698
4710
  });
4699
4711
  exports.ReturnSummary = zod_1.z.object({
4700
4712
  return_ref: zod_1.z.string().min(1),
@@ -5830,7 +5842,13 @@ const ES = {
5830
5842
  Delivered: "Entregado",
5831
5843
  Cancelled: "Cancelado",
5832
5844
  Refunded: "Reembolsado",
5833
- "In progress": "En curso"
5845
+ "In progress": "En curso",
5846
+ Return: "Devolución",
5847
+ Initiated: "Iniciada",
5848
+ Received: "Recibida",
5849
+ Completed: "Completada",
5850
+ item: "artículo",
5851
+ items: "artículos"
5834
5852
  };
5835
5853
  const CATALOGUES = {
5836
5854
  es: ES
@@ -7040,7 +7058,7 @@ const line$1 = "_line_1pjby_6";
7040
7058
  const thumb$1 = "_thumb_1pjby_12";
7041
7059
  const img$1 = "_img_1pjby_22";
7042
7060
  const placeholder$7 = "_placeholder_1pjby_29";
7043
- const meta$2 = "_meta_1pjby_34";
7061
+ const meta$3 = "_meta_1pjby_34";
7044
7062
  const name$2 = "_name_1pjby_43";
7045
7063
  const attrs$1 = "_attrs_1pjby_55";
7046
7064
  const price$3 = "_price_1pjby_63";
@@ -7051,7 +7069,7 @@ const styles$C = {
7051
7069
  thumb: thumb$1,
7052
7070
  img: img$1,
7053
7071
  placeholder: placeholder$7,
7054
- meta: meta$2,
7072
+ meta: meta$3,
7055
7073
  name: name$2,
7056
7074
  attrs: attrs$1,
7057
7075
  price: price$3,
@@ -7423,7 +7441,7 @@ const item$1 = "_item_1l21t_38";
7423
7441
  const thumb = "_thumb_1l21t_53";
7424
7442
  const img = "_img_1l21t_63";
7425
7443
  const placeholder$6 = "_placeholder_1l21t_70";
7426
- const meta$1 = "_meta_1l21t_75";
7444
+ const meta$2 = "_meta_1l21t_75";
7427
7445
  const name$1 = "_name_1l21t_83";
7428
7446
  const attrs = "_attrs_1l21t_103";
7429
7447
  const price$2 = "_price_1l21t_118";
@@ -7439,7 +7457,7 @@ const styles$z = {
7439
7457
  thumb,
7440
7458
  img,
7441
7459
  placeholder: placeholder$6,
7442
- meta: meta$1,
7460
+ meta: meta$2,
7443
7461
  name: name$1,
7444
7462
  attrs,
7445
7463
  price: price$2,
@@ -8131,14 +8149,8 @@ const TONE = {
8131
8149
  delivered: "delivered",
8132
8150
  cancelled: "critical"
8133
8151
  };
8134
- function OrderStatusBadge({ status, returnStatus }) {
8152
+ function OrderStatusBadge({ status }) {
8135
8153
  const t = useT();
8136
- if (returnStatus) {
8137
- return jsx("span", {
8138
- className: [styles$w.badge, styles$w.critical].join(" "),
8139
- children: t("Return started")
8140
- });
8141
- }
8142
8154
  const label2 = LABEL[status] ?? status.replace(/_/g, " ");
8143
8155
  const tone = TONE[status] ?? "progress";
8144
8156
  return jsx("span", {
@@ -8146,22 +8158,42 @@ function OrderStatusBadge({ status, returnStatus }) {
8146
8158
  children: t(label2)
8147
8159
  });
8148
8160
  }
8149
- const page$1 = "_page_1bhfq_2";
8150
- const empty = "_empty_1bhfq_22";
8151
- const cta$1 = "_cta_1bhfq_32";
8152
- const card$1 = "_card_1bhfq_55";
8153
- const tappable = "_tappable_1bhfq_70";
8154
- const head$1 = "_head_1bhfq_79";
8155
- const heading = "_heading_1bhfq_87";
8156
- const title$g = "_title_1bhfq_96";
8157
- const date = "_date_1bhfq_115";
8158
- const bottom$1 = "_bottom_1bhfq_120";
8159
- const strip = "_strip_1bhfq_128";
8160
- const tile$2 = "_tile_1bhfq_133";
8161
- const image$8 = "_image_1bhfq_143";
8162
- const placeholder$5 = "_placeholder_1bhfq_150";
8163
- const more = "_more_1bhfq_157";
8164
- const chevron$2 = "_chevron_1bhfq_170";
8161
+ const RETURN_LABEL = {
8162
+ reported: "Initiated",
8163
+ package_received: "Received",
8164
+ completed: "Completed"
8165
+ };
8166
+ const RETURN_TONE = {
8167
+ reported: "progress",
8168
+ package_received: "progress",
8169
+ completed: "delivered"
8170
+ };
8171
+ function ReturnStatusBadge({ status }) {
8172
+ const t = useT();
8173
+ const label2 = RETURN_LABEL[status] ?? status.replace(/_/g, " ");
8174
+ const tone = RETURN_TONE[status] ?? "progress";
8175
+ return jsx("span", {
8176
+ className: [styles$w.badge, styles$w[tone]].join(" "),
8177
+ children: t(label2)
8178
+ });
8179
+ }
8180
+ const page$1 = "_page_qj11j_2";
8181
+ const empty = "_empty_qj11j_22";
8182
+ const cta$1 = "_cta_qj11j_32";
8183
+ const card$1 = "_card_qj11j_55";
8184
+ const tappable = "_tappable_qj11j_70";
8185
+ const head$1 = "_head_qj11j_79";
8186
+ const heading = "_heading_qj11j_87";
8187
+ const title$g = "_title_qj11j_96";
8188
+ const date = "_date_qj11j_115";
8189
+ const bottom$1 = "_bottom_qj11j_120";
8190
+ const strip = "_strip_qj11j_128";
8191
+ const meta$1 = "_meta_qj11j_141";
8192
+ const tile$2 = "_tile_qj11j_150";
8193
+ const image$8 = "_image_qj11j_160";
8194
+ const placeholder$5 = "_placeholder_qj11j_167";
8195
+ const more = "_more_qj11j_174";
8196
+ const chevron$2 = "_chevron_qj11j_187";
8165
8197
  const styles$v = {
8166
8198
  page: page$1,
8167
8199
  empty,
@@ -8174,6 +8206,7 @@ const styles$v = {
8174
8206
  date,
8175
8207
  bottom: bottom$1,
8176
8208
  strip,
8209
+ meta: meta$1,
8177
8210
  tile: tile$2,
8178
8211
  image: image$8,
8179
8212
  placeholder: placeholder$5,
@@ -8206,18 +8239,20 @@ function OrderListView(props) {
8206
8239
  })
8207
8240
  });
8208
8241
  }
8209
- function OrderListContent({ onOpenOrder, onStartShopping, locale: localeProp }) {
8242
+ function OrderListContent({ onOpenOrder, onOpenReturn, onStartShopping, locale: localeProp }) {
8210
8243
  const t = useT();
8211
8244
  const { api } = useShop();
8212
8245
  const locale = useLocale(localeProp);
8213
8246
  const [orders2, setOrders] = useState([]);
8247
+ const [returns, setReturns] = useState([]);
8214
8248
  const [state, setState] = useState("loading");
8215
8249
  const [errorCode, setErrorCode] = useState(void 0);
8216
8250
  const load = useCallback(async () => {
8217
8251
  setState("loading");
8218
8252
  try {
8219
- const { orders: rows } = await api.orders.list();
8220
- setOrders(rows);
8253
+ const { orders: rows2, returns: returned } = await api.orders.list();
8254
+ setOrders(rows2);
8255
+ setReturns(returned ?? []);
8221
8256
  setState("ready");
8222
8257
  } catch (err) {
8223
8258
  setErrorCode(codeOf(err));
@@ -8248,7 +8283,7 @@ function OrderListContent({ onOpenOrder, onStartShopping, locale: localeProp })
8248
8283
  onRetry: () => void load()
8249
8284
  });
8250
8285
  }
8251
- if (orders2.length === 0) {
8286
+ if (orders2.length === 0 && returns.length === 0) {
8252
8287
  return jsx("div", {
8253
8288
  className: styles$v.empty,
8254
8289
  children: jsx(EmptyState, {
@@ -8265,17 +8300,115 @@ function OrderListContent({ onOpenOrder, onStartShopping, locale: localeProp })
8265
8300
  })
8266
8301
  });
8267
8302
  }
8303
+ const rows = [...orders2.map((order) => ({
8304
+ at: order.placed_at,
8305
+ key: `o:${order.order_ref}`,
8306
+ order
8307
+ })), ...returns.map((ret) => ({
8308
+ at: ret.reported_at,
8309
+ key: `r:${ret.return_ref}`,
8310
+ ret
8311
+ }))].sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
8268
8312
  return jsx("ul", {
8269
8313
  className: styles$v.page,
8270
- children: orders2.map((order) => jsx("li", {
8271
- children: jsx(OrderCard, {
8272
- order,
8314
+ children: rows.map((row2) => jsx("li", {
8315
+ children: "order" in row2 ? jsx(OrderCard, {
8316
+ order: row2.order,
8273
8317
  locale,
8274
8318
  ...onOpenOrder ? {
8275
- onOpen: () => onOpenOrder(order.order_ref)
8319
+ onOpen: () => onOpenOrder(row2.order.order_ref)
8320
+ } : {}
8321
+ }) : jsx(ReturnCard, {
8322
+ ret: row2.ret,
8323
+ locale,
8324
+ ...onOpenReturn ? {
8325
+ onOpen: () => onOpenReturn(row2.ret.return_ref)
8276
8326
  } : {}
8277
8327
  })
8278
- }, order.order_ref))
8328
+ }, row2.key))
8329
+ });
8330
+ }
8331
+ function ReturnCard({ ret, locale, onOpen }) {
8332
+ const t = useT();
8333
+ const { format: money2 } = useMoney(locale);
8334
+ const items2 = `${ret.item_count} ${ret.item_count === 1 ? t("item") : t("items")}`;
8335
+ const body3 = jsxs(Fragment, {
8336
+ children: [jsxs("div", {
8337
+ className: styles$v.head,
8338
+ children: [jsxs("div", {
8339
+ className: styles$v.heading,
8340
+ children: [jsx("span", {
8341
+ className: styles$v.title,
8342
+ children: `${t("Return")} #${shortRef(ret.return_ref)}`
8343
+ }), jsx("span", {
8344
+ className: styles$v.date,
8345
+ children: formatPlaced(ret.reported_at, locale)
8346
+ })]
8347
+ }), jsx(ReturnStatusBadge, {
8348
+ status: ret.status
8349
+ })]
8350
+ }), jsxs("div", {
8351
+ className: styles$v.bottom,
8352
+ children: [jsx(ReturnThumbnails, {
8353
+ ret
8354
+ }), jsx("span", {
8355
+ className: styles$v.meta,
8356
+ children: `${items2} · ${money2(ret.value)}`
8357
+ }), onOpen && jsx("span", {
8358
+ className: styles$v.chevron,
8359
+ children: jsx(Chevron, {})
8360
+ })]
8361
+ })]
8362
+ });
8363
+ if (!onOpen) return jsx("div", {
8364
+ className: styles$v.card,
8365
+ children: body3
8366
+ });
8367
+ return jsx("button", {
8368
+ type: "button",
8369
+ className: [styles$v.card, styles$v.tappable].join(" "),
8370
+ onClick: onOpen,
8371
+ "aria-label": `${t("Return")} ${shortRef(ret.return_ref)}, ${ret.headline}`,
8372
+ children: body3
8373
+ });
8374
+ }
8375
+ function ReturnThumbnails({ ret }) {
8376
+ const images = ret.images ?? [];
8377
+ const hidden = ret.item_count - TILES + 1;
8378
+ const overflow = images.length >= TILES && hidden > 1 ? hidden : 0;
8379
+ if (images.length === 0) {
8380
+ return jsx("div", {
8381
+ className: styles$v.strip,
8382
+ children: jsx("div", {
8383
+ className: [styles$v.tile, styles$v.placeholder].join(" "),
8384
+ "aria-hidden": "true"
8385
+ })
8386
+ });
8387
+ }
8388
+ return jsx("div", {
8389
+ className: styles$v.strip,
8390
+ children: images.map((src, i) => {
8391
+ const last = i === images.length - 1;
8392
+ return jsxs("div", {
8393
+ className: styles$v.tile,
8394
+ children: [jsx(ShopImage, {
8395
+ src,
8396
+ alt: "",
8397
+ fill: true,
8398
+ sizes: "56px",
8399
+ className: styles$v.image
8400
+ }), overflow > 0 && last && jsxs("span", {
8401
+ className: styles$v.more,
8402
+ children: [jsxs("span", {
8403
+ "aria-hidden": "true",
8404
+ children: ["+", overflow]
8405
+ }), jsx("span", {
8406
+ className: "visually-hidden",
8407
+ children: `and ${overflow} more items`
8408
+ })]
8409
+ })]
8410
+ }, `${src}-${i}`);
8411
+ })
8279
8412
  });
8280
8413
  }
8281
8414
  function OrderCard({ order, locale, onOpen }) {
@@ -8292,8 +8425,7 @@ function OrderCard({ order, locale, onOpen }) {
8292
8425
  children: formatPlaced(order.placed_at, locale)
8293
8426
  })]
8294
8427
  }), jsx(OrderStatusBadge, {
8295
- status: order.status,
8296
- returnStatus: order.return_status
8428
+ status: order.status
8297
8429
  })]
8298
8430
  }), jsxs("div", {
8299
8431
  className: styles$v.bottom,
@@ -11710,6 +11842,7 @@ export {
11710
11842
  ReturnFlowView,
11711
11843
  ReturnItemsView,
11712
11844
  ReturnLabelView,
11845
+ ReturnStatusBadge,
11713
11846
  ReturnTrackingView,
11714
11847
  ReviewCarousel,
11715
11848
  SaleBadge,
@@ -4647,7 +4647,7 @@ function requireOrderTracking() {
4647
4647
  Object.defineProperty(exports, "__esModule", {
4648
4648
  value: true
4649
4649
  });
4650
- exports.ReturnDetail = exports.ReturnItem = exports.ReturnProgressEntry = exports.CreateReturnRequest = exports.ReturnRequestItem = exports.FanReturnReason = exports.RequestCancellationRequest = exports.FanCancelReason = exports.OrderDetail = exports.ReturnSummary = exports.OrderList = exports.OrderSummaryItem = exports.ReturnOutcome = exports.ReturnStatus = exports.OrderItem = exports.OrderTracking = exports.OrderProgressEntry = exports.OrderProgressStep = void 0;
4650
+ exports.ReturnDetail = exports.ReturnItem = exports.ReturnProgressEntry = exports.CreateReturnRequest = exports.ReturnRequestItem = exports.FanReturnReason = exports.RequestCancellationRequest = exports.FanCancelReason = exports.OrderDetail = exports.ReturnSummary = exports.OrderList = exports.ReturnSummaryItem = exports.OrderSummaryItem = exports.ReturnOutcome = exports.ReturnStatus = exports.OrderItem = exports.OrderTracking = exports.OrderProgressEntry = exports.OrderProgressStep = void 0;
4651
4651
  const zod_1 = requireZod();
4652
4652
  const money_1 = requireMoney();
4653
4653
  const ids_1 = requireIds();
@@ -4693,8 +4693,20 @@ function requireOrderTracking() {
4693
4693
  images: zod_1.z.array(common_1.Url).max(3).optional(),
4694
4694
  return_status: exports.ReturnStatus.optional()
4695
4695
  });
4696
+ exports.ReturnSummaryItem = zod_1.z.object({
4697
+ return_ref: zod_1.z.string().min(1),
4698
+ order_ref: ids_1.OrderRef,
4699
+ status: exports.ReturnStatus,
4700
+ reported_at: common_1.Timestamp,
4701
+ currency: money_1.Currency,
4702
+ headline: zod_1.z.string().min(1),
4703
+ value: money_1.Money,
4704
+ item_count: zod_1.z.number().int().nonnegative(),
4705
+ images: zod_1.z.array(common_1.Url).max(3).optional()
4706
+ });
4696
4707
  exports.OrderList = zod_1.z.object({
4697
- orders: zod_1.z.array(exports.OrderSummaryItem)
4708
+ orders: zod_1.z.array(exports.OrderSummaryItem),
4709
+ returns: zod_1.z.array(exports.ReturnSummaryItem).optional()
4698
4710
  });
4699
4711
  exports.ReturnSummary = zod_1.z.object({
4700
4712
  return_ref: zod_1.z.string().min(1),
@@ -5830,7 +5842,13 @@ const ES = {
5830
5842
  Delivered: "Entregado",
5831
5843
  Cancelled: "Cancelado",
5832
5844
  Refunded: "Reembolsado",
5833
- "In progress": "En curso"
5845
+ "In progress": "En curso",
5846
+ Return: "Devolución",
5847
+ Initiated: "Iniciada",
5848
+ Received: "Recibida",
5849
+ Completed: "Completada",
5850
+ item: "artículo",
5851
+ items: "artículos"
5834
5852
  };
5835
5853
  const CATALOGUES = {
5836
5854
  es: ES
@@ -7040,7 +7058,7 @@ const line$1 = "_line_1pjby_6";
7040
7058
  const thumb$1 = "_thumb_1pjby_12";
7041
7059
  const img$1 = "_img_1pjby_22";
7042
7060
  const placeholder$7 = "_placeholder_1pjby_29";
7043
- const meta$2 = "_meta_1pjby_34";
7061
+ const meta$3 = "_meta_1pjby_34";
7044
7062
  const name$2 = "_name_1pjby_43";
7045
7063
  const attrs$1 = "_attrs_1pjby_55";
7046
7064
  const price$3 = "_price_1pjby_63";
@@ -7051,7 +7069,7 @@ const styles$C = {
7051
7069
  thumb: thumb$1,
7052
7070
  img: img$1,
7053
7071
  placeholder: placeholder$7,
7054
- meta: meta$2,
7072
+ meta: meta$3,
7055
7073
  name: name$2,
7056
7074
  attrs: attrs$1,
7057
7075
  price: price$3,
@@ -7423,7 +7441,7 @@ const item$1 = "_item_1l21t_38";
7423
7441
  const thumb = "_thumb_1l21t_53";
7424
7442
  const img = "_img_1l21t_63";
7425
7443
  const placeholder$6 = "_placeholder_1l21t_70";
7426
- const meta$1 = "_meta_1l21t_75";
7444
+ const meta$2 = "_meta_1l21t_75";
7427
7445
  const name$1 = "_name_1l21t_83";
7428
7446
  const attrs = "_attrs_1l21t_103";
7429
7447
  const price$2 = "_price_1l21t_118";
@@ -7439,7 +7457,7 @@ const styles$z = {
7439
7457
  thumb,
7440
7458
  img,
7441
7459
  placeholder: placeholder$6,
7442
- meta: meta$1,
7460
+ meta: meta$2,
7443
7461
  name: name$1,
7444
7462
  attrs,
7445
7463
  price: price$2,
@@ -8131,14 +8149,8 @@ const TONE = {
8131
8149
  delivered: "delivered",
8132
8150
  cancelled: "critical"
8133
8151
  };
8134
- function OrderStatusBadge({ status, returnStatus }) {
8152
+ function OrderStatusBadge({ status }) {
8135
8153
  const t = useT();
8136
- if (returnStatus) {
8137
- return jsx("span", {
8138
- className: [styles$w.badge, styles$w.critical].join(" "),
8139
- children: t("Return started")
8140
- });
8141
- }
8142
8154
  const label2 = LABEL[status] ?? status.replace(/_/g, " ");
8143
8155
  const tone = TONE[status] ?? "progress";
8144
8156
  return jsx("span", {
@@ -8146,22 +8158,42 @@ function OrderStatusBadge({ status, returnStatus }) {
8146
8158
  children: t(label2)
8147
8159
  });
8148
8160
  }
8149
- const page$1 = "_page_1bhfq_2";
8150
- const empty = "_empty_1bhfq_22";
8151
- const cta$1 = "_cta_1bhfq_32";
8152
- const card$1 = "_card_1bhfq_55";
8153
- const tappable = "_tappable_1bhfq_70";
8154
- const head$1 = "_head_1bhfq_79";
8155
- const heading = "_heading_1bhfq_87";
8156
- const title$g = "_title_1bhfq_96";
8157
- const date = "_date_1bhfq_115";
8158
- const bottom$1 = "_bottom_1bhfq_120";
8159
- const strip = "_strip_1bhfq_128";
8160
- const tile$2 = "_tile_1bhfq_133";
8161
- const image$8 = "_image_1bhfq_143";
8162
- const placeholder$5 = "_placeholder_1bhfq_150";
8163
- const more = "_more_1bhfq_157";
8164
- const chevron$2 = "_chevron_1bhfq_170";
8161
+ const RETURN_LABEL = {
8162
+ reported: "Initiated",
8163
+ package_received: "Received",
8164
+ completed: "Completed"
8165
+ };
8166
+ const RETURN_TONE = {
8167
+ reported: "progress",
8168
+ package_received: "progress",
8169
+ completed: "delivered"
8170
+ };
8171
+ function ReturnStatusBadge({ status }) {
8172
+ const t = useT();
8173
+ const label2 = RETURN_LABEL[status] ?? status.replace(/_/g, " ");
8174
+ const tone = RETURN_TONE[status] ?? "progress";
8175
+ return jsx("span", {
8176
+ className: [styles$w.badge, styles$w[tone]].join(" "),
8177
+ children: t(label2)
8178
+ });
8179
+ }
8180
+ const page$1 = "_page_qj11j_2";
8181
+ const empty = "_empty_qj11j_22";
8182
+ const cta$1 = "_cta_qj11j_32";
8183
+ const card$1 = "_card_qj11j_55";
8184
+ const tappable = "_tappable_qj11j_70";
8185
+ const head$1 = "_head_qj11j_79";
8186
+ const heading = "_heading_qj11j_87";
8187
+ const title$g = "_title_qj11j_96";
8188
+ const date = "_date_qj11j_115";
8189
+ const bottom$1 = "_bottom_qj11j_120";
8190
+ const strip = "_strip_qj11j_128";
8191
+ const meta$1 = "_meta_qj11j_141";
8192
+ const tile$2 = "_tile_qj11j_150";
8193
+ const image$8 = "_image_qj11j_160";
8194
+ const placeholder$5 = "_placeholder_qj11j_167";
8195
+ const more = "_more_qj11j_174";
8196
+ const chevron$2 = "_chevron_qj11j_187";
8165
8197
  const styles$v = {
8166
8198
  page: page$1,
8167
8199
  empty,
@@ -8174,6 +8206,7 @@ const styles$v = {
8174
8206
  date,
8175
8207
  bottom: bottom$1,
8176
8208
  strip,
8209
+ meta: meta$1,
8177
8210
  tile: tile$2,
8178
8211
  image: image$8,
8179
8212
  placeholder: placeholder$5,
@@ -8206,18 +8239,20 @@ function OrderListView(props) {
8206
8239
  })
8207
8240
  });
8208
8241
  }
8209
- function OrderListContent({ onOpenOrder, onStartShopping, locale: localeProp }) {
8242
+ function OrderListContent({ onOpenOrder, onOpenReturn, onStartShopping, locale: localeProp }) {
8210
8243
  const t = useT();
8211
8244
  const { api } = useShop();
8212
8245
  const locale = useLocale(localeProp);
8213
8246
  const [orders2, setOrders] = useState([]);
8247
+ const [returns, setReturns] = useState([]);
8214
8248
  const [state, setState] = useState("loading");
8215
8249
  const [errorCode, setErrorCode] = useState(void 0);
8216
8250
  const load = useCallback(async () => {
8217
8251
  setState("loading");
8218
8252
  try {
8219
- const { orders: rows } = await api.orders.list();
8220
- setOrders(rows);
8253
+ const { orders: rows2, returns: returned } = await api.orders.list();
8254
+ setOrders(rows2);
8255
+ setReturns(returned ?? []);
8221
8256
  setState("ready");
8222
8257
  } catch (err) {
8223
8258
  setErrorCode(codeOf(err));
@@ -8248,7 +8283,7 @@ function OrderListContent({ onOpenOrder, onStartShopping, locale: localeProp })
8248
8283
  onRetry: () => void load()
8249
8284
  });
8250
8285
  }
8251
- if (orders2.length === 0) {
8286
+ if (orders2.length === 0 && returns.length === 0) {
8252
8287
  return jsx("div", {
8253
8288
  className: styles$v.empty,
8254
8289
  children: jsx(EmptyState, {
@@ -8265,17 +8300,115 @@ function OrderListContent({ onOpenOrder, onStartShopping, locale: localeProp })
8265
8300
  })
8266
8301
  });
8267
8302
  }
8303
+ const rows = [...orders2.map((order) => ({
8304
+ at: order.placed_at,
8305
+ key: `o:${order.order_ref}`,
8306
+ order
8307
+ })), ...returns.map((ret) => ({
8308
+ at: ret.reported_at,
8309
+ key: `r:${ret.return_ref}`,
8310
+ ret
8311
+ }))].sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
8268
8312
  return jsx("ul", {
8269
8313
  className: styles$v.page,
8270
- children: orders2.map((order) => jsx("li", {
8271
- children: jsx(OrderCard, {
8272
- order,
8314
+ children: rows.map((row2) => jsx("li", {
8315
+ children: "order" in row2 ? jsx(OrderCard, {
8316
+ order: row2.order,
8273
8317
  locale,
8274
8318
  ...onOpenOrder ? {
8275
- onOpen: () => onOpenOrder(order.order_ref)
8319
+ onOpen: () => onOpenOrder(row2.order.order_ref)
8320
+ } : {}
8321
+ }) : jsx(ReturnCard, {
8322
+ ret: row2.ret,
8323
+ locale,
8324
+ ...onOpenReturn ? {
8325
+ onOpen: () => onOpenReturn(row2.ret.return_ref)
8276
8326
  } : {}
8277
8327
  })
8278
- }, order.order_ref))
8328
+ }, row2.key))
8329
+ });
8330
+ }
8331
+ function ReturnCard({ ret, locale, onOpen }) {
8332
+ const t = useT();
8333
+ const { format: money2 } = useMoney(locale);
8334
+ const items2 = `${ret.item_count} ${ret.item_count === 1 ? t("item") : t("items")}`;
8335
+ const body3 = jsxs(Fragment, {
8336
+ children: [jsxs("div", {
8337
+ className: styles$v.head,
8338
+ children: [jsxs("div", {
8339
+ className: styles$v.heading,
8340
+ children: [jsx("span", {
8341
+ className: styles$v.title,
8342
+ children: `${t("Return")} #${shortRef(ret.return_ref)}`
8343
+ }), jsx("span", {
8344
+ className: styles$v.date,
8345
+ children: formatPlaced(ret.reported_at, locale)
8346
+ })]
8347
+ }), jsx(ReturnStatusBadge, {
8348
+ status: ret.status
8349
+ })]
8350
+ }), jsxs("div", {
8351
+ className: styles$v.bottom,
8352
+ children: [jsx(ReturnThumbnails, {
8353
+ ret
8354
+ }), jsx("span", {
8355
+ className: styles$v.meta,
8356
+ children: `${items2} · ${money2(ret.value)}`
8357
+ }), onOpen && jsx("span", {
8358
+ className: styles$v.chevron,
8359
+ children: jsx(Chevron, {})
8360
+ })]
8361
+ })]
8362
+ });
8363
+ if (!onOpen) return jsx("div", {
8364
+ className: styles$v.card,
8365
+ children: body3
8366
+ });
8367
+ return jsx("button", {
8368
+ type: "button",
8369
+ className: [styles$v.card, styles$v.tappable].join(" "),
8370
+ onClick: onOpen,
8371
+ "aria-label": `${t("Return")} ${shortRef(ret.return_ref)}, ${ret.headline}`,
8372
+ children: body3
8373
+ });
8374
+ }
8375
+ function ReturnThumbnails({ ret }) {
8376
+ const images = ret.images ?? [];
8377
+ const hidden = ret.item_count - TILES + 1;
8378
+ const overflow = images.length >= TILES && hidden > 1 ? hidden : 0;
8379
+ if (images.length === 0) {
8380
+ return jsx("div", {
8381
+ className: styles$v.strip,
8382
+ children: jsx("div", {
8383
+ className: [styles$v.tile, styles$v.placeholder].join(" "),
8384
+ "aria-hidden": "true"
8385
+ })
8386
+ });
8387
+ }
8388
+ return jsx("div", {
8389
+ className: styles$v.strip,
8390
+ children: images.map((src, i) => {
8391
+ const last = i === images.length - 1;
8392
+ return jsxs("div", {
8393
+ className: styles$v.tile,
8394
+ children: [jsx(ShopImage, {
8395
+ src,
8396
+ alt: "",
8397
+ fill: true,
8398
+ sizes: "56px",
8399
+ className: styles$v.image
8400
+ }), overflow > 0 && last && jsxs("span", {
8401
+ className: styles$v.more,
8402
+ children: [jsxs("span", {
8403
+ "aria-hidden": "true",
8404
+ children: ["+", overflow]
8405
+ }), jsx("span", {
8406
+ className: "visually-hidden",
8407
+ children: `and ${overflow} more items`
8408
+ })]
8409
+ })]
8410
+ }, `${src}-${i}`);
8411
+ })
8279
8412
  });
8280
8413
  }
8281
8414
  function OrderCard({ order, locale, onOpen }) {
@@ -8292,8 +8425,7 @@ function OrderCard({ order, locale, onOpen }) {
8292
8425
  children: formatPlaced(order.placed_at, locale)
8293
8426
  })]
8294
8427
  }), jsx(OrderStatusBadge, {
8295
- status: order.status,
8296
- returnStatus: order.return_status
8428
+ status: order.status
8297
8429
  })]
8298
8430
  }), jsxs("div", {
8299
8431
  className: styles$v.bottom,
@@ -11710,6 +11842,7 @@ export {
11710
11842
  ReturnFlowView,
11711
11843
  ReturnItemsView,
11712
11844
  ReturnLabelView,
11845
+ ReturnStatusBadge,
11713
11846
  ReturnTrackingView,
11714
11847
  ReviewCarousel,
11715
11848
  SaleBadge,
@@ -1645,7 +1645,7 @@
1645
1645
  background: var(--color-state-surface-critical-soft);
1646
1646
  color: var(--color-state-text-critical);
1647
1647
  }
1648
- ._page_1bhfq_2 {
1648
+ ._page_qj11j_2 {
1649
1649
  list-style: none;
1650
1650
  margin: 0;
1651
1651
  display: flex;
@@ -1653,14 +1653,14 @@
1653
1653
  gap: var(--space-12);
1654
1654
  padding: var(--space-16) var(--space-16) var(--space-24);
1655
1655
  }
1656
- ._empty_1bhfq_22 {
1656
+ ._empty_qj11j_22 {
1657
1657
  display: flex;
1658
1658
  align-items: center;
1659
1659
  justify-content: center;
1660
1660
  min-height: calc(100dvh - var(--header-height) - var(--space-32));
1661
1661
  padding-bottom: var(--space-32);
1662
1662
  }
1663
- ._cta_1bhfq_32 {
1663
+ ._cta_qj11j_32 {
1664
1664
  display: inline-flex;
1665
1665
  align-items: center;
1666
1666
  justify-content: center;
@@ -1677,11 +1677,11 @@
1677
1677
  line-height: 1;
1678
1678
  cursor: pointer;
1679
1679
  }
1680
- ._cta_1bhfq_32:focus-visible {
1680
+ ._cta_qj11j_32:focus-visible {
1681
1681
  outline: none;
1682
1682
  box-shadow: var(--focus-ring);
1683
1683
  }
1684
- ._card_1bhfq_55 {
1684
+ ._card_qj11j_55 {
1685
1685
  display: flex;
1686
1686
  flex-direction: column;
1687
1687
  gap: var(--space-24);
@@ -1695,21 +1695,21 @@
1695
1695
  text-align: left;
1696
1696
  overflow: hidden;
1697
1697
  }
1698
- ._tappable_1bhfq_70 {
1698
+ ._tappable_qj11j_70 {
1699
1699
  cursor: pointer;
1700
1700
  }
1701
- ._tappable_1bhfq_70:focus-visible {
1701
+ ._tappable_qj11j_70:focus-visible {
1702
1702
  outline: none;
1703
1703
  box-shadow: var(--focus-ring);
1704
1704
  }
1705
- ._head_1bhfq_79 {
1705
+ ._head_qj11j_79 {
1706
1706
  display: flex;
1707
1707
  align-items: flex-start;
1708
1708
  justify-content: space-between;
1709
1709
  gap: var(--space-8);
1710
1710
  width: 100%;
1711
1711
  }
1712
- ._heading_1bhfq_87 {
1712
+ ._heading_qj11j_87 {
1713
1713
  display: flex;
1714
1714
  flex: 1 1 auto;
1715
1715
  flex-direction: column;
@@ -1717,7 +1717,7 @@
1717
1717
  min-width: 0;
1718
1718
  color: var(--color-text-default);
1719
1719
  }
1720
- ._title_1bhfq_96 {
1720
+ ._title_qj11j_96 {
1721
1721
  font-size: var(--type-heading-md-size);
1722
1722
  font-weight: var(--font-weight-bold);
1723
1723
  line-height: 1.32;
@@ -1725,22 +1725,30 @@
1725
1725
  text-overflow: ellipsis;
1726
1726
  white-space: nowrap;
1727
1727
  }
1728
- ._date_1bhfq_115 {
1728
+ ._date_qj11j_115 {
1729
1729
  font-size: var(--type-trimmed-sm-size);
1730
1730
  line-height: 10px;
1731
1731
  }
1732
- ._bottom_1bhfq_120 {
1732
+ ._bottom_qj11j_120 {
1733
1733
  display: flex;
1734
1734
  align-items: center;
1735
1735
  justify-content: space-between;
1736
1736
  gap: var(--space-8);
1737
1737
  width: 100%;
1738
1738
  }
1739
- ._strip_1bhfq_128 {
1739
+ ._strip_qj11j_128 {
1740
1740
  display: flex;
1741
1741
  gap: var(--space-6);
1742
1742
  }
1743
- ._tile_1bhfq_133 {
1743
+ ._meta_qj11j_141 {
1744
+ flex: 1 1 auto;
1745
+ text-align: right;
1746
+ font-size: var(--type-trimmed-sm-size);
1747
+ color: var(--color-text-subtle);
1748
+ font-variant-numeric: tabular-nums;
1749
+ white-space: nowrap;
1750
+ }
1751
+ ._tile_qj11j_150 {
1744
1752
  position: relative;
1745
1753
  flex: 0 0 56px;
1746
1754
  width: 56px;
@@ -1749,14 +1757,14 @@
1749
1757
  overflow: hidden;
1750
1758
  background: var(--color-surface-subtle);
1751
1759
  }
1752
- ._image_1bhfq_143 {
1760
+ ._image_qj11j_160 {
1753
1761
  object-fit: cover;
1754
1762
  object-position: top;
1755
1763
  }
1756
- ._placeholder_1bhfq_150 {
1764
+ ._placeholder_qj11j_167 {
1757
1765
  background: var(--color-surface-subtle);
1758
1766
  }
1759
- ._more_1bhfq_157 {
1767
+ ._more_qj11j_174 {
1760
1768
  position: absolute;
1761
1769
  inset: 0;
1762
1770
  display: flex;
@@ -1768,7 +1776,7 @@
1768
1776
  font-weight: var(--font-weight-bold);
1769
1777
  line-height: 1;
1770
1778
  }
1771
- ._chevron_1bhfq_170 {
1779
+ ._chevron_qj11j_187 {
1772
1780
  display: inline-flex;
1773
1781
  flex: 0 0 24px;
1774
1782
  width: 24px;
package/dist/styles.css CHANGED
@@ -1645,7 +1645,7 @@
1645
1645
  background: var(--color-state-surface-critical-soft);
1646
1646
  color: var(--color-state-text-critical);
1647
1647
  }
1648
- ._page_1bhfq_2 {
1648
+ ._page_qj11j_2 {
1649
1649
  list-style: none;
1650
1650
  margin: 0;
1651
1651
  display: flex;
@@ -1653,14 +1653,14 @@
1653
1653
  gap: var(--space-12);
1654
1654
  padding: var(--space-16) var(--space-16) var(--space-24);
1655
1655
  }
1656
- ._empty_1bhfq_22 {
1656
+ ._empty_qj11j_22 {
1657
1657
  display: flex;
1658
1658
  align-items: center;
1659
1659
  justify-content: center;
1660
1660
  min-height: calc(100dvh - var(--header-height) - var(--space-32));
1661
1661
  padding-bottom: var(--space-32);
1662
1662
  }
1663
- ._cta_1bhfq_32 {
1663
+ ._cta_qj11j_32 {
1664
1664
  display: inline-flex;
1665
1665
  align-items: center;
1666
1666
  justify-content: center;
@@ -1677,11 +1677,11 @@
1677
1677
  line-height: 1;
1678
1678
  cursor: pointer;
1679
1679
  }
1680
- ._cta_1bhfq_32:focus-visible {
1680
+ ._cta_qj11j_32:focus-visible {
1681
1681
  outline: none;
1682
1682
  box-shadow: var(--focus-ring);
1683
1683
  }
1684
- ._card_1bhfq_55 {
1684
+ ._card_qj11j_55 {
1685
1685
  display: flex;
1686
1686
  flex-direction: column;
1687
1687
  gap: var(--space-24);
@@ -1695,21 +1695,21 @@
1695
1695
  text-align: left;
1696
1696
  overflow: hidden;
1697
1697
  }
1698
- ._tappable_1bhfq_70 {
1698
+ ._tappable_qj11j_70 {
1699
1699
  cursor: pointer;
1700
1700
  }
1701
- ._tappable_1bhfq_70:focus-visible {
1701
+ ._tappable_qj11j_70:focus-visible {
1702
1702
  outline: none;
1703
1703
  box-shadow: var(--focus-ring);
1704
1704
  }
1705
- ._head_1bhfq_79 {
1705
+ ._head_qj11j_79 {
1706
1706
  display: flex;
1707
1707
  align-items: flex-start;
1708
1708
  justify-content: space-between;
1709
1709
  gap: var(--space-8);
1710
1710
  width: 100%;
1711
1711
  }
1712
- ._heading_1bhfq_87 {
1712
+ ._heading_qj11j_87 {
1713
1713
  display: flex;
1714
1714
  flex: 1 1 auto;
1715
1715
  flex-direction: column;
@@ -1717,7 +1717,7 @@
1717
1717
  min-width: 0;
1718
1718
  color: var(--color-text-default);
1719
1719
  }
1720
- ._title_1bhfq_96 {
1720
+ ._title_qj11j_96 {
1721
1721
  font-size: var(--type-heading-md-size);
1722
1722
  font-weight: var(--font-weight-bold);
1723
1723
  line-height: 1.32;
@@ -1725,22 +1725,30 @@
1725
1725
  text-overflow: ellipsis;
1726
1726
  white-space: nowrap;
1727
1727
  }
1728
- ._date_1bhfq_115 {
1728
+ ._date_qj11j_115 {
1729
1729
  font-size: var(--type-trimmed-sm-size);
1730
1730
  line-height: 10px;
1731
1731
  }
1732
- ._bottom_1bhfq_120 {
1732
+ ._bottom_qj11j_120 {
1733
1733
  display: flex;
1734
1734
  align-items: center;
1735
1735
  justify-content: space-between;
1736
1736
  gap: var(--space-8);
1737
1737
  width: 100%;
1738
1738
  }
1739
- ._strip_1bhfq_128 {
1739
+ ._strip_qj11j_128 {
1740
1740
  display: flex;
1741
1741
  gap: var(--space-6);
1742
1742
  }
1743
- ._tile_1bhfq_133 {
1743
+ ._meta_qj11j_141 {
1744
+ flex: 1 1 auto;
1745
+ text-align: right;
1746
+ font-size: var(--type-trimmed-sm-size);
1747
+ color: var(--color-text-subtle);
1748
+ font-variant-numeric: tabular-nums;
1749
+ white-space: nowrap;
1750
+ }
1751
+ ._tile_qj11j_150 {
1744
1752
  position: relative;
1745
1753
  flex: 0 0 56px;
1746
1754
  width: 56px;
@@ -1749,14 +1757,14 @@
1749
1757
  overflow: hidden;
1750
1758
  background: var(--color-surface-subtle);
1751
1759
  }
1752
- ._image_1bhfq_143 {
1760
+ ._image_qj11j_160 {
1753
1761
  object-fit: cover;
1754
1762
  object-position: top;
1755
1763
  }
1756
- ._placeholder_1bhfq_150 {
1764
+ ._placeholder_qj11j_167 {
1757
1765
  background: var(--color-surface-subtle);
1758
1766
  }
1759
- ._more_1bhfq_157 {
1767
+ ._more_qj11j_174 {
1760
1768
  position: absolute;
1761
1769
  inset: 0;
1762
1770
  display: flex;
@@ -1768,7 +1776,7 @@
1768
1776
  font-weight: var(--font-weight-bold);
1769
1777
  line-height: 1;
1770
1778
  }
1771
- ._chevron_1bhfq_170 {
1779
+ ._chevron_qj11j_187 {
1772
1780
  display: inline-flex;
1773
1781
  flex: 0 0 24px;
1774
1782
  width: 24px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nok-integration/storefront-react",
3
- "version": "0.19.49",
3
+ "version": "0.19.50",
4
4
  "description": "Mountable React storefront components: catalogue, product detail and cart, mounted directly into a host DOM tree. No iframe.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",