@instockng/storefront-ui 1.0.22 → 1.0.24

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.
Files changed (105) hide show
  1. package/dist/components/Checkout.d.ts.map +1 -1
  2. package/dist/components/ShoppingCart.d.ts.map +1 -1
  3. package/dist/contexts/CartContext.d.ts.map +1 -1
  4. package/dist/index10.mjs +68 -64
  5. package/dist/index12.mjs +477 -456
  6. package/dist/index132.mjs +1 -1
  7. package/dist/index134.mjs +2 -21
  8. package/dist/index135.mjs +19 -54
  9. package/dist/index136.mjs +55 -28
  10. package/dist/index137.mjs +28 -6
  11. package/dist/index138.mjs +6 -51
  12. package/dist/index139.mjs +51 -5
  13. package/dist/index140.mjs +6 -12
  14. package/dist/index141.mjs +12 -7
  15. package/dist/index142.mjs +6 -27
  16. package/dist/index143.mjs +28 -2
  17. package/dist/index144.mjs +2 -70
  18. package/dist/index145.mjs +67 -164
  19. package/dist/index146.mjs +167 -2
  20. package/dist/index150.mjs +1 -1
  21. package/dist/index151.mjs +1 -1
  22. package/dist/index153.mjs +1 -1
  23. package/dist/index154.mjs +1 -1
  24. package/dist/index156.mjs +1 -1
  25. package/dist/index157.mjs +1 -1
  26. package/dist/index159.mjs +2 -2
  27. package/dist/index160.mjs +1 -1
  28. package/dist/index165.mjs +2 -2
  29. package/dist/index167.mjs +1 -1
  30. package/dist/index169.mjs +2 -2
  31. package/dist/index170.mjs +5 -5
  32. package/dist/index173.mjs +1 -1
  33. package/dist/index184.mjs +1 -1
  34. package/dist/index186.mjs +1 -1
  35. package/dist/index190.mjs +1 -1
  36. package/dist/index192.mjs +1 -1
  37. package/dist/index2.mjs +10 -10
  38. package/dist/index20.mjs +2 -2
  39. package/dist/index205.mjs +2 -2
  40. package/dist/index206.mjs +2 -2
  41. package/dist/index208.mjs +2 -2
  42. package/dist/index209.mjs +2 -2
  43. package/dist/index21.mjs +2 -2
  44. package/dist/index210.mjs +2 -2
  45. package/dist/index211.mjs +108 -2
  46. package/dist/index212.mjs +2 -2
  47. package/dist/index213.mjs +2 -108
  48. package/dist/index214.mjs +244 -2
  49. package/dist/index216.mjs +28 -32
  50. package/dist/index217.mjs +65 -2
  51. package/dist/index218.mjs +24 -243
  52. package/dist/index220.mjs +2 -33
  53. package/dist/index221.mjs +2 -65
  54. package/dist/index222.mjs +2 -25
  55. package/dist/index223.mjs +37 -2
  56. package/dist/index224.mjs +2 -2
  57. package/dist/index230.mjs +2 -2
  58. package/dist/index231.mjs +2 -2
  59. package/dist/index245.mjs +3 -3
  60. package/dist/index248.mjs +2 -2
  61. package/dist/index249.mjs +2 -18
  62. package/dist/index25.mjs +5 -0
  63. package/dist/index250.mjs +2 -47
  64. package/dist/index251.mjs +2 -2
  65. package/dist/index252.mjs +91 -2
  66. package/dist/index253.mjs +2 -2
  67. package/dist/index254.mjs +2 -2
  68. package/dist/index255.mjs +16 -89
  69. package/dist/index256.mjs +47 -2
  70. package/dist/index263.mjs +1 -1
  71. package/dist/index264.mjs +1 -1
  72. package/dist/index265.mjs +2 -2
  73. package/dist/index267.mjs +2 -2
  74. package/dist/index3.mjs +82 -82
  75. package/dist/index38.mjs +1 -1
  76. package/dist/index42.mjs +1 -1
  77. package/dist/index49.mjs +59 -59
  78. package/dist/index50.mjs +50 -50
  79. package/dist/index51.mjs +48 -48
  80. package/dist/index52.mjs +56 -56
  81. package/dist/index53.mjs +39 -39
  82. package/dist/index54.mjs +55 -55
  83. package/dist/index55.mjs +15 -15
  84. package/dist/index56.mjs +10 -10
  85. package/dist/index57.mjs +23 -23
  86. package/dist/index58.mjs +64 -64
  87. package/dist/index59.mjs +73 -73
  88. package/dist/index62.mjs +149 -19
  89. package/dist/index63.mjs +19 -149
  90. package/dist/index73.mjs +1 -1
  91. package/dist/index78.mjs +5 -5
  92. package/dist/index80.mjs +3 -3
  93. package/dist/index90.mjs +1 -1
  94. package/dist/index91.mjs +3 -3
  95. package/dist/providers/StorefrontProvider.d.ts.map +1 -1
  96. package/dist/styles.css +1 -1
  97. package/package.json +12 -11
  98. package/src/components/CartItem.stories.tsx +5 -5
  99. package/src/components/Checkout.stories.tsx +16 -15
  100. package/src/components/Checkout.tsx +93 -50
  101. package/src/components/ShoppingCart.stories.tsx +17 -16
  102. package/src/components/ShoppingCart.tsx +14 -12
  103. package/src/contexts/CartContext.tsx +2 -1
  104. package/src/providers/StorefrontProvider.tsx +4 -1
  105. package/src/test-utils/MockCartProvider.tsx +31 -25
@@ -281,9 +281,10 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
281
281
  if ('error' in updatedCart) return;
282
282
 
283
283
  // Find the newly added item (last item with matching SKU)
284
- const addedItem = updatedCart.items?.findLast(
284
+ const matchingItems = updatedCart.items?.filter(
285
285
  (item) => item.variant?.sku === sku
286
286
  );
287
+ const addedItem = matchingItems?.[matchingItems.length - 1];
287
288
 
288
289
  if (addedItem) {
289
290
  // Generate event ID matching backend format: cart_{cartId}_item_{itemId}
@@ -82,8 +82,11 @@ export function StorefrontProvider({
82
82
  initialCartId,
83
83
  shoppingCartProps,
84
84
  }: StorefrontProviderProps) {
85
+ // Storefront-ui doesn't use authenticated endpoints, so provide a no-op getAuthToken
86
+ const getAuthToken = async () => '';
87
+
85
88
  return (
86
- <ApiClientProvider {...(apiUrl && { baseURL: apiUrl })}>
89
+ <ApiClientProvider getAuthToken={getAuthToken} {...(apiUrl && { baseURL: apiUrl })}>
87
90
  <StorefrontProviderInner
88
91
  brandSlug={brandSlug}
89
92
  initialCartId={initialCartId}
@@ -23,19 +23,20 @@ const mockCart: Cart = {
23
23
  logoUrl: 'https://images.unsplash.com/photo-1599305445671-ac291c95aaa9?w=200&h=80&fit=crop',
24
24
  siteUrl: 'https://demo-store.com',
25
25
  domain: 'f',
26
+ metaPixelId: null as any,
26
27
  createdAt: new Date().toISOString(),
27
28
  updatedAt: new Date().toISOString(),
28
- deletedAt: null,
29
+ deletedAt: null as any,
29
30
  },
30
- customerPhone: null,
31
- customerEmail: null,
32
- customerFirstName: null,
33
- customerLastName: null,
34
- availablePaymentMethods: ['cod'],
35
- deliveryZone: null,
31
+ customerPhone: null as any,
32
+ customerEmail: null as any,
33
+ customerFirstName: null as any,
34
+ customerLastName: null as any,
35
+ availablePaymentMethods: ['cod'] as any,
36
+ deliveryZone: null as any,
36
37
  recoveryAttempts: 0,
37
- lastRecoveryAttemptAt: null,
38
- recoveryDiscountCode: null,
38
+ lastRecoveryAttemptAt: null as any,
39
+ recoveryDiscountCode: null as any,
39
40
  items: [
40
41
  {
41
42
  id: 'item-1',
@@ -51,7 +52,7 @@ const mockCart: Cart = {
51
52
  isActive: true,
52
53
  createdAt: new Date().toISOString(),
53
54
  updatedAt: new Date().toISOString(),
54
- deletedAt: null,
55
+ deletedAt: null as any,
55
56
  product: {
56
57
  id: 'product-1',
57
58
  name: 'Premium Cotton T-Shirt',
@@ -62,8 +63,8 @@ const mockCart: Cart = {
62
63
  thumbnailUrl: 'https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?w=400',
63
64
  createdAt: new Date().toISOString(),
64
65
  updatedAt: new Date().toISOString(),
65
- deletedAt: null,
66
- quantityDiscounts: null,
66
+ deletedAt: null as any,
67
+ quantityDiscounts: null as any,
67
68
  },
68
69
  },
69
70
  quantity: 2,
@@ -111,12 +112,12 @@ const mockCart: Cart = {
111
112
  pricing: {
112
113
  subtotal: 94.97,
113
114
  deliveryCharge: 0,
114
- discount: null,
115
+ discount: null as any,
115
116
  total: 94.97,
116
117
  },
117
118
  createdAt: new Date().toISOString(),
118
119
  updatedAt: new Date().toISOString(),
119
- convertedToOrderId: null,
120
+ convertedToOrderId: null as any,
120
121
  wasRecovered: false,
121
122
  recoveryUrl: 'https://demo-store.com?cartId=mock-cart-123',
122
123
  };
@@ -218,17 +219,17 @@ export function MockCartProvider({
218
219
  estimatedDays: 3,
219
220
  totalPrice: cart.pricing.total + 1500,
220
221
  discountCodeId: null,
221
- discountAmount: null,
222
+ discountAmount: null as any,
222
223
  paymentMethod: data.paymentMethod,
223
224
  paystackReference: null,
224
225
  status: 'pending' as const,
225
226
  cancellationReason: null,
226
227
  createdAt: new Date().toISOString(),
227
228
  updatedAt: new Date().toISOString(),
228
- deletedAt: null,
229
- lastRecoveryAttemptAt: null,
229
+ deletedAt: null as any,
230
+ lastRecoveryAttemptAt: null as any,
230
231
  prospectReason: null,
231
- prospectSince: null,
232
+ prospectSince: null as any,
232
233
  recoveryAttempts: 0,
233
234
  recoveryDiscountCodeId: null,
234
235
  userActionToken: 'mock-token-123',
@@ -242,21 +243,21 @@ export function MockCartProvider({
242
243
  name: cart.deliveryZone?.name || 'Mock Zone',
243
244
  brandId: cart.brand.id,
244
245
  deliveryCost: 1500,
245
- freeShippingThreshold: null,
246
+ freeShippingThreshold: null as any,
246
247
  allowCOD: true,
247
248
  allowOnline: true,
248
249
  waybillOnly: false,
249
250
  estimatedDays: 3,
250
251
  createdAt: new Date().toISOString(),
251
252
  updatedAt: new Date().toISOString(),
252
- deletedAt: null,
253
+ deletedAt: null as any,
253
254
  state: {
254
255
  id: 'mock-state-1',
255
256
  name: 'Mock State',
256
257
  isActive: true,
257
258
  createdAt: new Date().toISOString(),
258
259
  updatedAt: new Date().toISOString(),
259
- deletedAt: null,
260
+ deletedAt: null as any,
260
261
  },
261
262
  isActive: true,
262
263
  stateId: 'mock-state-1',
@@ -278,7 +279,7 @@ export function MockCartProvider({
278
279
  state: null,
279
280
  createdAt: new Date().toISOString(),
280
281
  updatedAt: new Date().toISOString(),
281
- deletedAt: null,
282
+ deletedAt: null as any,
282
283
  },
283
284
  })),
284
285
  } satisfies CheckoutResponse;
@@ -335,8 +336,8 @@ export function MockCartProvider({
335
336
  updateCartMutation: mockUpdateCartMutation as any,
336
337
  checkoutMutation: mockCheckoutMutation as any,
337
338
 
338
- addItem: async (variantId: string, quantity: number) => {
339
- console.log('Mock addItem:', { variantId, quantity });
339
+ addItem: async (productSlug: string, productName: string, price: number, sku: string, quantity: number) => {
340
+ console.log('Mock addItem:', { productSlug, productName, price, sku, quantity });
340
341
  },
341
342
 
342
343
  updateItem: async (itemId: string, quantity: number) => {
@@ -386,12 +387,17 @@ export function MockCartProvider({
386
387
  ...prev,
387
388
  pricing: {
388
389
  ...prev.pricing,
389
- discount: null,
390
+ discount: null as any,
390
391
  total: prev.pricing.subtotal,
391
392
  },
392
393
  }));
393
394
  },
394
395
 
396
+ trackCheckoutInitiated: () => {
397
+ console.log('Mock trackCheckoutInitiated');
398
+ // Mock implementation - in real context this tracks InitiateCheckout event
399
+ },
400
+
395
401
  clearCart: () => {
396
402
  console.log('Mock clearCart');
397
403
  setCart(prev => ({