@nok-integration/storefront-react 0.19.48 → 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,
@@ -10969,24 +11101,24 @@ function ProductView({ sku, initialData, showRecommendations = true, onNotFound
10969
11101
  })
10970
11102
  });
10971
11103
  }
10972
- const showcase = "_showcase_12gts_14";
10973
- const panel = "_panel_12gts_19";
10974
- const image = "_image_12gts_65";
10975
- const hero = "_hero_12gts_105";
10976
- const heroContent = "_heroContent_12gts_190";
10977
- const heroText = "_heroText_12gts_214";
10978
- const logo = "_logo_12gts_223";
10979
- const heroTitle = "_heroTitle_12gts_243";
10980
- const heroSub = "_heroSub_12gts_267";
10981
- const swipe = "_swipe_12gts_286";
10982
- const swipeLabel = "_swipeLabel_12gts_293";
10983
- const chevron$1 = "_chevron_12gts_299";
10984
- const overlay$1 = "_overlay_12gts_11";
10985
- const copy = "_copy_12gts_334";
10986
- const title$2 = "_title_12gts_339";
10987
- const subtitle$1 = "_subtitle_12gts_346";
10988
- const cta = "_cta_12gts_352";
10989
- const mosaic = "_mosaic_12gts_396";
11104
+ const showcase = "_showcase_jukpz_14";
11105
+ const panel = "_panel_jukpz_19";
11106
+ const image = "_image_jukpz_80";
11107
+ const hero = "_hero_jukpz_120";
11108
+ const heroContent = "_heroContent_jukpz_205";
11109
+ const heroText = "_heroText_jukpz_229";
11110
+ const logo = "_logo_jukpz_238";
11111
+ const heroTitle = "_heroTitle_jukpz_258";
11112
+ const heroSub = "_heroSub_jukpz_282";
11113
+ const swipe = "_swipe_jukpz_301";
11114
+ const swipeLabel = "_swipeLabel_jukpz_308";
11115
+ const chevron$1 = "_chevron_jukpz_314";
11116
+ const overlay$1 = "_overlay_jukpz_11";
11117
+ const copy = "_copy_jukpz_349";
11118
+ const title$2 = "_title_jukpz_354";
11119
+ const subtitle$1 = "_subtitle_jukpz_361";
11120
+ const cta = "_cta_jukpz_367";
11121
+ const mosaic = "_mosaic_jukpz_411";
10990
11122
  const styles$2 = {
10991
11123
  showcase,
10992
11124
  panel,
@@ -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,