@nok-integration/storefront-react 0.23.0 → 0.24.0

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
@@ -3014,6 +3014,7 @@ declare function createClient(options: ClientOptions): {
3014
3014
  returned_qty?: number | undefined;
3015
3015
  }[];
3016
3016
  headline: string;
3017
+ order_ref: string;
3017
3018
  totals: {
3018
3019
  shipping: {
3019
3020
  amount: number;
@@ -3036,7 +3037,6 @@ declare function createClient(options: ClientOptions): {
3036
3037
  currency: string;
3037
3038
  } | undefined;
3038
3039
  };
3039
- order_ref: string;
3040
3040
  placed_at: string;
3041
3041
  ship_to: {
3042
3042
  country: string;
@@ -3111,6 +3111,7 @@ declare function createClient(options: ClientOptions): {
3111
3111
  returned_qty?: number | undefined;
3112
3112
  }[];
3113
3113
  headline: string;
3114
+ order_ref: string;
3114
3115
  totals: {
3115
3116
  shipping: {
3116
3117
  amount: number;
@@ -3133,7 +3134,6 @@ declare function createClient(options: ClientOptions): {
3133
3134
  currency: string;
3134
3135
  } | undefined;
3135
3136
  };
3136
- order_ref: string;
3137
3137
  placed_at: string;
3138
3138
  ship_to: {
3139
3139
  country: string;
@@ -3266,13 +3266,13 @@ declare function createClient(options: ClientOptions): {
3266
3266
  }>;
3267
3267
  };
3268
3268
  vip: {
3269
- resolve: (token: string, query?: CartMarketQuery) => Promise<{
3269
+ resolve: (locator: string | VipInviteResolveRequest, query?: CartMarketQuery) => Promise<{
3270
3270
  items: {
3271
3271
  product_sku: string;
3272
3272
  quantity: number;
3273
3273
  }[];
3274
- state: "active";
3275
3274
  invite_ref: string;
3275
+ state: "active";
3276
3276
  recipient_name: string;
3277
3277
  personal_message: string | null;
3278
3278
  delivery_rule: "both_free" | "standard_free" | "both_paid";
@@ -3290,6 +3290,7 @@ declare function createClient(options: ClientOptions): {
3290
3290
  opens_at: string;
3291
3291
  } | {
3292
3292
  state: "claimed";
3293
+ order_ref?: string | undefined;
3293
3294
  } | {
3294
3295
  state: "expired";
3295
3296
  } | {
@@ -4296,6 +4297,7 @@ declare const OrderDetail: z.ZodObject<{
4296
4297
  attributes?: Record<string, string> | undefined;
4297
4298
  returned_qty?: number | undefined;
4298
4299
  }[];
4300
+ order_ref: string & z.BRAND<"OrderRef">;
4299
4301
  totals: {
4300
4302
  shipping: {
4301
4303
  amount: number;
@@ -4318,7 +4320,6 @@ declare const OrderDetail: z.ZodObject<{
4318
4320
  currency: string;
4319
4321
  } | undefined;
4320
4322
  };
4321
- order_ref: string & z.BRAND<"OrderRef">;
4322
4323
  placed_at: string;
4323
4324
  ship_to: {
4324
4325
  country: string;
@@ -4386,6 +4387,7 @@ declare const OrderDetail: z.ZodObject<{
4386
4387
  attributes?: Record<string, string> | undefined;
4387
4388
  returned_qty?: number | undefined;
4388
4389
  }[];
4390
+ order_ref: string;
4389
4391
  totals: {
4390
4392
  shipping: {
4391
4393
  amount: number;
@@ -4408,7 +4410,6 @@ declare const OrderDetail: z.ZodObject<{
4408
4410
  currency: string;
4409
4411
  } | undefined;
4410
4412
  };
4411
- order_ref: string;
4412
4413
  placed_at: string;
4413
4414
  ship_to: {
4414
4415
  country: string;
@@ -6166,7 +6167,7 @@ export declare interface ShopMenuSheetProps {
6166
6167
  * implementation detail — see the versioning policy in the component SDK specification.
6167
6168
  */
6168
6169
  /** A storefront-relative identifier. NOT a URL expected to resolve on the host. */
6169
- export declare type ShopRoute = '/' | `/category/${string}` | `/product/${string}` | '/cart';
6170
+ export declare type ShopRoute = '/' | `/category/${string}` | `/product/${string}` | '/cart' | `/vip/${string}`;
6170
6171
 
6171
6172
  /**
6172
6173
  * Request: the shopping session id and the one-time code, exactly as they arrive on the
@@ -6821,10 +6822,10 @@ export declare interface VariantSelectorProps {
6821
6822
  labelAttribute?: string;
6822
6823
  }
6823
6824
 
6824
- declare const VipCartItemRequest: z.ZodObject<{
6825
- token: z.ZodString;
6825
+ declare const VipCartItemRequest: z.ZodUnion<[z.ZodObject<{
6826
6826
  sku: z.ZodString;
6827
6827
  qty: z.ZodNumber;
6828
+ token: z.ZodString;
6828
6829
  }, "strict", z.ZodTypeAny, {
6829
6830
  sku: string;
6830
6831
  token: string;
@@ -6833,7 +6834,19 @@ declare const VipCartItemRequest: z.ZodObject<{
6833
6834
  sku: string;
6834
6835
  token: string;
6835
6836
  qty: number;
6836
- }>;
6837
+ }>, z.ZodObject<{
6838
+ sku: z.ZodString;
6839
+ qty: z.ZodNumber;
6840
+ invite_ref: z.ZodBranded<z.ZodString, "VipInviteRef">;
6841
+ }, "strict", z.ZodTypeAny, {
6842
+ sku: string;
6843
+ invite_ref: string & z.BRAND<"VipInviteRef">;
6844
+ qty: number;
6845
+ }, {
6846
+ sku: string;
6847
+ invite_ref: string;
6848
+ qty: number;
6849
+ }>]>;
6837
6850
 
6838
6851
  declare type VipCartItemRequest = z.infer<typeof VipCartItemRequest>;
6839
6852
 
@@ -6869,6 +6882,22 @@ export declare interface VipHeroProps {
6869
6882
  onContinue: () => void;
6870
6883
  }
6871
6884
 
6885
+ declare const VipInviteResolveRequest: z.ZodUnion<[z.ZodObject<{
6886
+ token: z.ZodString;
6887
+ }, "strict", z.ZodTypeAny, {
6888
+ token: string;
6889
+ }, {
6890
+ token: string;
6891
+ }>, z.ZodObject<{
6892
+ invite_ref: z.ZodBranded<z.ZodString, "VipInviteRef">;
6893
+ }, "strict", z.ZodTypeAny, {
6894
+ invite_ref: string & z.BRAND<"VipInviteRef">;
6895
+ }, {
6896
+ invite_ref: string;
6897
+ }>]>;
6898
+
6899
+ declare type VipInviteResolveRequest = z.infer<typeof VipInviteResolveRequest>;
6900
+
6872
6901
  export declare type VipInviteUnavailableState = Exclude<VipInviteView['state'], 'active'>;
6873
6902
 
6874
6903
  declare const VipInviteView: z.ZodDiscriminatedUnion<"state", [z.ZodObject<{
@@ -6911,8 +6940,8 @@ declare const VipInviteView: z.ZodDiscriminatedUnion<"state", [z.ZodObject<{
6911
6940
  desktop_video?: string | null | undefined;
6912
6941
  }>>>;
6913
6942
  }, "strip", z.ZodTypeAny, {
6914
- state: "active";
6915
6943
  invite_ref: string & z.BRAND<"VipInviteRef">;
6944
+ state: "active";
6916
6945
  recipient_name: string;
6917
6946
  personal_message: string | null;
6918
6947
  delivery_rule: "both_free" | "standard_free" | "both_paid";
@@ -6930,8 +6959,8 @@ declare const VipInviteView: z.ZodDiscriminatedUnion<"state", [z.ZodObject<{
6930
6959
  desktop_video?: string | null | undefined;
6931
6960
  } | null | undefined;
6932
6961
  }, {
6933
- state: "active";
6934
6962
  invite_ref: string;
6963
+ state: "active";
6935
6964
  recipient_name: string;
6936
6965
  personal_message: string | null;
6937
6966
  delivery_rule: "both_free" | "standard_free" | "both_paid";
@@ -6959,10 +6988,13 @@ declare const VipInviteView: z.ZodDiscriminatedUnion<"state", [z.ZodObject<{
6959
6988
  opens_at: string;
6960
6989
  }>, z.ZodObject<{
6961
6990
  state: z.ZodLiteral<"claimed">;
6991
+ order_ref: z.ZodOptional<z.ZodBranded<z.ZodString, "OrderRef">>;
6962
6992
  }, "strip", z.ZodTypeAny, {
6963
6993
  state: "claimed";
6994
+ order_ref?: (string & z.BRAND<"OrderRef">) | undefined;
6964
6995
  }, {
6965
6996
  state: "claimed";
6997
+ order_ref?: string | undefined;
6966
6998
  }>, z.ZodObject<{
6967
6999
  state: z.ZodLiteral<"expired">;
6968
7000
  }, "strip", z.ZodTypeAny, {
@@ -6982,7 +7014,10 @@ declare type VipInviteView = z.infer<typeof VipInviteView>;
6982
7014
  export declare function VipLandingView({ token, onUnavailable }: VipLandingViewProps): JSX.Element;
6983
7015
 
6984
7016
  export declare interface VipLandingViewProps {
6985
- /** The token from the invite link: the last path segment of the URL the recipient opened. */
7017
+ /**
7018
+ * The last path segment of the URL the recipient opened: the token from the invite link,
7019
+ * or the invite reference that Reorder on a cancelled VIP order navigates to.
7020
+ */
6986
7021
  token: string;
6987
7022
  /** Replaces the built-in screen for an invite that cannot be claimed. */
6988
7023
  onUnavailable?: (state: VipInviteUnavailableState) => ReactNode;
package/dist/index.mjs CHANGED
@@ -4507,9 +4507,11 @@ function requireVip() {
4507
4507
  exports.VipInviteRef = (0, ids_1.prefixedId)("vip_", "VipInviteRef");
4508
4508
  exports.VIP_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
4509
4509
  exports.VipDeliveryRule = zod_1.z.enum(["both_free", "standard_free", "both_paid"]);
4510
- exports.VipInviteResolveRequest = zod_1.z.object({
4510
+ exports.VipInviteResolveRequest = zod_1.z.union([zod_1.z.object({
4511
4511
  token: zod_1.z.string().regex(exports.VIP_TOKEN_PATTERN)
4512
- }).strict();
4512
+ }).strict(), zod_1.z.object({
4513
+ invite_ref: exports.VipInviteRef
4514
+ }).strict()]);
4513
4515
  exports.VipInviteOffer = zod_1.z.object({
4514
4516
  product_sku: common_1.Sku,
4515
4517
  quantity: zod_1.z.number().int().positive()
@@ -4535,17 +4537,24 @@ function requireVip() {
4535
4537
  state: zod_1.z.literal("scheduled"),
4536
4538
  opens_at: common_1.Timestamp
4537
4539
  }), zod_1.z.object({
4538
- state: zod_1.z.literal("claimed")
4540
+ state: zod_1.z.literal("claimed"),
4541
+ order_ref: ids_1.OrderRef.optional()
4539
4542
  }), zod_1.z.object({
4540
4543
  state: zod_1.z.literal("expired")
4541
4544
  }), zod_1.z.object({
4542
4545
  state: zod_1.z.literal("revoked")
4543
4546
  })]);
4544
- exports.VipCartItemRequest = zod_1.z.object({
4545
- token: zod_1.z.string().regex(exports.VIP_TOKEN_PATTERN),
4547
+ const VipCartLine = {
4546
4548
  sku: common_1.Sku,
4547
4549
  qty: zod_1.z.number().int().positive().max(99)
4548
- }).strict();
4550
+ };
4551
+ exports.VipCartItemRequest = zod_1.z.union([zod_1.z.object({
4552
+ token: zod_1.z.string().regex(exports.VIP_TOKEN_PATTERN),
4553
+ ...VipCartLine
4554
+ }).strict(), zod_1.z.object({
4555
+ invite_ref: exports.VipInviteRef,
4556
+ ...VipCartLine
4557
+ }).strict()]);
4549
4558
  exports.VipClaimLine = zod_1.z.object({
4550
4559
  sku: common_1.Sku,
4551
4560
  qty: zod_1.z.number().int().positive()
@@ -5262,12 +5271,12 @@ function requireClient() {
5262
5271
  })
5263
5272
  },
5264
5273
  vip: {
5265
- resolve: (token, query = {}) => request({
5274
+ resolve: (locator, query = {}) => request({
5266
5275
  method: "POST",
5267
5276
  path: "/vip/resolve",
5268
- body: {
5269
- token
5270
- },
5277
+ body: typeof locator === "string" ? {
5278
+ token: locator
5279
+ } : locator,
5271
5280
  query: market(query),
5272
5281
  schema: vip_1.VipInviteView
5273
5282
  }),
@@ -8819,6 +8828,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
8819
8828
  const emit = useShopEvent();
8820
8829
  const navigate = useNavigate();
8821
8830
  const toast2 = useToast();
8831
+ useSetScreenTitle(order?.vip ? t("DAZN Shop") : void 0, "none");
8822
8832
  const load = useCallback(async () => {
8823
8833
  setState("loading");
8824
8834
  try {
@@ -8898,6 +8908,10 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
8898
8908
  onReorder();
8899
8909
  return;
8900
8910
  }
8911
+ if (current2.vip) {
8912
+ navigate?.(`/vip/${encodeURIComponent(current2.vip.invite_ref)}`);
8913
+ return;
8914
+ }
8901
8915
  setReordering(true);
8902
8916
  try {
8903
8917
  let added = 0;
@@ -9156,6 +9170,7 @@ function OrderConfirmationContent({ orderRef, locale: localeProp, onDone, onCont
9156
9170
  const { api } = useShop();
9157
9171
  const locale = useLocale(localeProp);
9158
9172
  const [order, setOrder] = useState(null);
9173
+ useSetScreenTitle(order?.vip ? t("DAZN Shop") : void 0, "none");
9159
9174
  const [state, setState] = useState("loading");
9160
9175
  const [errorCode, setErrorCode] = useState(void 0);
9161
9176
  const load = useCallback(async () => {
@@ -12477,6 +12492,14 @@ function VipHero({ hero: hero2, onContinue }) {
12477
12492
  })
12478
12493
  });
12479
12494
  }
12495
+ const INVITE_REF = /^vip_[A-Za-z0-9._-]+$/;
12496
+ function locatorOf(segment) {
12497
+ return INVITE_REF.test(segment) && segment.length !== 43 ? {
12498
+ invite_ref: segment
12499
+ } : {
12500
+ token: segment
12501
+ };
12502
+ }
12480
12503
  function VipLandingView({ token, onUnavailable }) {
12481
12504
  const t = useT();
12482
12505
  const { api, emit } = useShop();
@@ -12485,12 +12508,13 @@ function VipLandingView({ token, onUnavailable }) {
12485
12508
  });
12486
12509
  const emitRef = useRef(emit);
12487
12510
  emitRef.current = emit;
12511
+ useSetScreenTitle(t("DAZN Shop"), "none");
12488
12512
  useEffect(() => {
12489
12513
  let live = true;
12490
12514
  setLoad({
12491
12515
  status: "loading"
12492
12516
  });
12493
- api.vip.resolve(token).then((invite2) => {
12517
+ api.vip.resolve(locatorOf(token)).then((invite2) => {
12494
12518
  if (live) setLoad({
12495
12519
  status: "done",
12496
12520
  invite: invite2
@@ -12525,6 +12549,11 @@ function VipLandingView({ token, onUnavailable }) {
12525
12549
  });
12526
12550
  }
12527
12551
  const { invite } = load;
12552
+ if (invite.state === "claimed" && invite.order_ref) {
12553
+ return jsx(OrderTrackingView, {
12554
+ orderRef: invite.order_ref
12555
+ });
12556
+ }
12528
12557
  if (invite.state !== "active") {
12529
12558
  if (onUnavailable) return jsx(Fragment, {
12530
12559
  children: onUnavailable(invite.state)
@@ -12559,7 +12588,7 @@ function ActiveLanding({ token, invite }) {
12559
12588
  for (const line2 of current2.items) await api.cart.removeItem(line2.sku);
12560
12589
  }
12561
12590
  const cart2 = await api.vip.addToCart({
12562
- token,
12591
+ ...locatorOf(token),
12563
12592
  sku: variantSku,
12564
12593
  qty: 1
12565
12594
  });
@@ -4507,9 +4507,11 @@ function requireVip() {
4507
4507
  exports.VipInviteRef = (0, ids_1.prefixedId)("vip_", "VipInviteRef");
4508
4508
  exports.VIP_TOKEN_PATTERN = /^[A-Za-z0-9_-]{43}$/;
4509
4509
  exports.VipDeliveryRule = zod_1.z.enum(["both_free", "standard_free", "both_paid"]);
4510
- exports.VipInviteResolveRequest = zod_1.z.object({
4510
+ exports.VipInviteResolveRequest = zod_1.z.union([zod_1.z.object({
4511
4511
  token: zod_1.z.string().regex(exports.VIP_TOKEN_PATTERN)
4512
- }).strict();
4512
+ }).strict(), zod_1.z.object({
4513
+ invite_ref: exports.VipInviteRef
4514
+ }).strict()]);
4513
4515
  exports.VipInviteOffer = zod_1.z.object({
4514
4516
  product_sku: common_1.Sku,
4515
4517
  quantity: zod_1.z.number().int().positive()
@@ -4535,17 +4537,24 @@ function requireVip() {
4535
4537
  state: zod_1.z.literal("scheduled"),
4536
4538
  opens_at: common_1.Timestamp
4537
4539
  }), zod_1.z.object({
4538
- state: zod_1.z.literal("claimed")
4540
+ state: zod_1.z.literal("claimed"),
4541
+ order_ref: ids_1.OrderRef.optional()
4539
4542
  }), zod_1.z.object({
4540
4543
  state: zod_1.z.literal("expired")
4541
4544
  }), zod_1.z.object({
4542
4545
  state: zod_1.z.literal("revoked")
4543
4546
  })]);
4544
- exports.VipCartItemRequest = zod_1.z.object({
4545
- token: zod_1.z.string().regex(exports.VIP_TOKEN_PATTERN),
4547
+ const VipCartLine = {
4546
4548
  sku: common_1.Sku,
4547
4549
  qty: zod_1.z.number().int().positive().max(99)
4548
- }).strict();
4550
+ };
4551
+ exports.VipCartItemRequest = zod_1.z.union([zod_1.z.object({
4552
+ token: zod_1.z.string().regex(exports.VIP_TOKEN_PATTERN),
4553
+ ...VipCartLine
4554
+ }).strict(), zod_1.z.object({
4555
+ invite_ref: exports.VipInviteRef,
4556
+ ...VipCartLine
4557
+ }).strict()]);
4549
4558
  exports.VipClaimLine = zod_1.z.object({
4550
4559
  sku: common_1.Sku,
4551
4560
  qty: zod_1.z.number().int().positive()
@@ -5262,12 +5271,12 @@ function requireClient() {
5262
5271
  })
5263
5272
  },
5264
5273
  vip: {
5265
- resolve: (token, query = {}) => request({
5274
+ resolve: (locator, query = {}) => request({
5266
5275
  method: "POST",
5267
5276
  path: "/vip/resolve",
5268
- body: {
5269
- token
5270
- },
5277
+ body: typeof locator === "string" ? {
5278
+ token: locator
5279
+ } : locator,
5271
5280
  query: market(query),
5272
5281
  schema: vip_1.VipInviteView
5273
5282
  }),
@@ -8819,6 +8828,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
8819
8828
  const emit = useShopEvent();
8820
8829
  const navigate = useNavigate();
8821
8830
  const toast2 = useToast();
8831
+ useSetScreenTitle(order?.vip ? t("DAZN Shop") : void 0, "none");
8822
8832
  const load = useCallback(async () => {
8823
8833
  setState("loading");
8824
8834
  try {
@@ -8898,6 +8908,10 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
8898
8908
  onReorder();
8899
8909
  return;
8900
8910
  }
8911
+ if (current2.vip) {
8912
+ navigate?.(`/vip/${encodeURIComponent(current2.vip.invite_ref)}`);
8913
+ return;
8914
+ }
8901
8915
  setReordering(true);
8902
8916
  try {
8903
8917
  let added = 0;
@@ -9156,6 +9170,7 @@ function OrderConfirmationContent({ orderRef, locale: localeProp, onDone, onCont
9156
9170
  const { api } = useShop();
9157
9171
  const locale = useLocale(localeProp);
9158
9172
  const [order, setOrder] = useState(null);
9173
+ useSetScreenTitle(order?.vip ? t("DAZN Shop") : void 0, "none");
9159
9174
  const [state, setState] = useState("loading");
9160
9175
  const [errorCode, setErrorCode] = useState(void 0);
9161
9176
  const load = useCallback(async () => {
@@ -12477,6 +12492,14 @@ function VipHero({ hero: hero2, onContinue }) {
12477
12492
  })
12478
12493
  });
12479
12494
  }
12495
+ const INVITE_REF = /^vip_[A-Za-z0-9._-]+$/;
12496
+ function locatorOf(segment) {
12497
+ return INVITE_REF.test(segment) && segment.length !== 43 ? {
12498
+ invite_ref: segment
12499
+ } : {
12500
+ token: segment
12501
+ };
12502
+ }
12480
12503
  function VipLandingView({ token, onUnavailable }) {
12481
12504
  const t = useT();
12482
12505
  const { api, emit } = useShop();
@@ -12485,12 +12508,13 @@ function VipLandingView({ token, onUnavailable }) {
12485
12508
  });
12486
12509
  const emitRef = useRef(emit);
12487
12510
  emitRef.current = emit;
12511
+ useSetScreenTitle(t("DAZN Shop"), "none");
12488
12512
  useEffect(() => {
12489
12513
  let live = true;
12490
12514
  setLoad({
12491
12515
  status: "loading"
12492
12516
  });
12493
- api.vip.resolve(token).then((invite2) => {
12517
+ api.vip.resolve(locatorOf(token)).then((invite2) => {
12494
12518
  if (live) setLoad({
12495
12519
  status: "done",
12496
12520
  invite: invite2
@@ -12525,6 +12549,11 @@ function VipLandingView({ token, onUnavailable }) {
12525
12549
  });
12526
12550
  }
12527
12551
  const { invite } = load;
12552
+ if (invite.state === "claimed" && invite.order_ref) {
12553
+ return jsx(OrderTrackingView, {
12554
+ orderRef: invite.order_ref
12555
+ });
12556
+ }
12528
12557
  if (invite.state !== "active") {
12529
12558
  if (onUnavailable) return jsx(Fragment, {
12530
12559
  children: onUnavailable(invite.state)
@@ -12559,7 +12588,7 @@ function ActiveLanding({ token, invite }) {
12559
12588
  for (const line2 of current2.items) await api.cart.removeItem(line2.sku);
12560
12589
  }
12561
12590
  const cart2 = await api.vip.addToCart({
12562
- token,
12591
+ ...locatorOf(token),
12563
12592
  sku: variantSku,
12564
12593
  qty: 1
12565
12594
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nok-integration/storefront-react",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
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",