@mohasinac/appkit 4.62.0 → 4.62.1

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 (204) hide show
  1. package/dist/.build-stamp.json +3 -3
  2. package/dist/_internal/server/features/checkout/actions.d.ts +80 -0
  3. package/dist/_internal/server/features/checkout/actions.js +542 -26
  4. package/dist/_internal/server/features/invoicing/allocate.d.ts +63 -0
  5. package/dist/_internal/server/features/invoicing/allocate.js +162 -0
  6. package/dist/_internal/server/features/invoicing/credit-note.d.ts +57 -0
  7. package/dist/_internal/server/features/invoicing/credit-note.js +126 -0
  8. package/dist/_internal/server/features/invoicing/gstr1.d.ts +74 -0
  9. package/dist/_internal/server/features/invoicing/gstr1.js +251 -0
  10. package/dist/_internal/server/features/invoicing/issue.d.ts +96 -0
  11. package/dist/_internal/server/features/invoicing/issue.js +202 -0
  12. package/dist/_internal/server/features/orders/actions.d.ts +8 -1
  13. package/dist/_internal/server/features/orders/actions.js +81 -8
  14. package/dist/_internal/server/features/orders/adapters.js +33 -0
  15. package/dist/_internal/server/features/orders/cancellation-refund.d.ts +15 -9
  16. package/dist/_internal/server/features/orders/cancellation-refund.js +15 -9
  17. package/dist/_internal/server/features/points/award.js +46 -4
  18. package/dist/_internal/server/features/refunds/actions.js +26 -0
  19. package/dist/_internal/server/features/shipping/courier-block.d.ts +69 -0
  20. package/dist/_internal/server/features/shipping/courier-block.js +239 -0
  21. package/dist/_internal/server/features/site-settings/adapters.d.ts +1 -1
  22. package/dist/_internal/server/features/site-settings/adapters.js +15 -0
  23. package/dist/_internal/server/features/stores/adapters.d.ts +2 -2
  24. package/dist/_internal/server/features/stores/adapters.js +51 -0
  25. package/dist/_internal/server/functions/scheduled.js +38 -1
  26. package/dist/_internal/server/jobs/core/autoPayoutEligibility.js +9 -2
  27. package/dist/_internal/server/jobs/core/dailyStatusDigest.d.ts +4 -0
  28. package/dist/_internal/server/jobs/core/dailyStatusDigest.js +19 -2
  29. package/dist/_internal/server/jobs/core/index.d.ts +2 -1
  30. package/dist/_internal/server/jobs/core/index.js +2 -1
  31. package/dist/_internal/server/jobs/core/onJobCreated.d.ts +30 -7
  32. package/dist/_internal/server/jobs/core/onJobCreated.js +78 -45
  33. package/dist/_internal/server/jobs/core/onOrderStatusChange.d.ts +7 -0
  34. package/dist/_internal/server/jobs/core/onOrderStatusChange.js +62 -0
  35. package/dist/_internal/server/jobs/core/paymentWindowTimeout.js +33 -0
  36. package/dist/_internal/server/jobs/core/runJobOnce.d.ts +48 -0
  37. package/dist/_internal/server/jobs/core/runJobOnce.js +195 -0
  38. package/dist/_internal/server/jobs/core/weeklyPayoutEligibility.js +10 -2
  39. package/dist/_internal/server/jobs/handlers/onOrderStatusChange.js +17 -0
  40. package/dist/_internal/server/notifications/channel-health.d.ts +26 -3
  41. package/dist/_internal/shared/actions/action-registry.js +28 -0
  42. package/dist/_internal/shared/checkout/coupon-discount.d.ts +43 -1
  43. package/dist/_internal/shared/checkout/coupon-discount.js +26 -1
  44. package/dist/_internal/shared/checkout/order-math.d.ts +145 -0
  45. package/dist/_internal/shared/checkout/order-math.js +173 -0
  46. package/dist/_internal/shared/checkout/refundable-base.d.ts +25 -0
  47. package/dist/_internal/shared/checkout/refundable-base.js +13 -1
  48. package/dist/_internal/shared/checkout/split.d.ts +87 -0
  49. package/dist/_internal/shared/checkout/split.js +100 -0
  50. package/dist/_internal/shared/content/disclaimers.d.ts +88 -0
  51. package/dist/_internal/shared/content/disclaimers.js +217 -0
  52. package/dist/_internal/shared/content/published-values.d.ts +88 -0
  53. package/dist/_internal/shared/content/published-values.js +198 -0
  54. package/dist/_internal/shared/features/admin/integrations.d.ts +109 -0
  55. package/dist/_internal/shared/features/admin/integrations.js +253 -0
  56. package/dist/_internal/shared/features/orders/dispute-reasons.d.ts +113 -0
  57. package/dist/_internal/shared/features/orders/dispute-reasons.js +181 -0
  58. package/dist/_internal/shared/features/orders/refund-copy.d.ts +1 -1
  59. package/dist/_internal/shared/features/orders/refund-copy.js +18 -1
  60. package/dist/_internal/shared/features/points/accepts.d.ts +36 -0
  61. package/dist/_internal/shared/features/points/accepts.js +43 -0
  62. package/dist/_internal/shared/features/shipping/shared-purchase.d.ts +91 -0
  63. package/dist/_internal/shared/features/shipping/shared-purchase.js +108 -0
  64. package/dist/_internal/shared/features/site-settings/types.d.ts +11 -0
  65. package/dist/_internal/shared/fees/calculator.d.ts +33 -1
  66. package/dist/_internal/shared/fees/calculator.js +32 -2
  67. package/dist/client.d.ts +11 -0
  68. package/dist/client.js +30 -0
  69. package/dist/constants/api-endpoints.d.ts +42 -0
  70. package/dist/constants/api-endpoints.js +14 -0
  71. package/dist/constants/field-names.d.ts +1 -0
  72. package/dist/constants/field-names.js +5 -0
  73. package/dist/contracts/index.d.ts +1 -1
  74. package/dist/contracts/shipping.d.ts +45 -0
  75. package/dist/contracts/shipping.js +15 -0
  76. package/dist/features/about/components/AboutView.js +1 -1
  77. package/dist/features/account/components/BuyerAuctionsGuideView.js +4 -1
  78. package/dist/features/account/components/UserOrdersView.js +19 -33
  79. package/dist/features/admin/components/AdminCouponEditorView.js +17 -0
  80. package/dist/features/admin/components/AdminInvoicingView.d.ts +2 -0
  81. package/dist/features/admin/components/AdminInvoicingView.js +65 -0
  82. package/dist/features/admin/components/AdminOrderEditorView.d.ts +18 -1
  83. package/dist/features/admin/components/AdminOrderEditorView.js +11 -2
  84. package/dist/features/admin/components/AdminOrdersGuideView.js +23 -2
  85. package/dist/features/admin/components/AdminOrdersView.js +67 -5
  86. package/dist/features/admin/components/OwnerQuickActions.js +24 -2
  87. package/dist/features/admin/constants/filter-tabs.d.ts +6 -0
  88. package/dist/features/admin/constants/filter-tabs.js +6 -0
  89. package/dist/features/admin/constants/site-settings-tabs.d.ts +1 -1
  90. package/dist/features/admin/hooks/useAdminListingData.js +16 -0
  91. package/dist/features/admin/schemas/admin-user-form.d.ts +2 -2
  92. package/dist/features/admin/schemas/firestore.d.ts +30 -0
  93. package/dist/features/admin/schemas/firestore.js +5 -0
  94. package/dist/features/audit-log/schemas/firestore.d.ts +30 -0
  95. package/dist/features/audit-log/schemas/firestore.js +15 -0
  96. package/dist/features/auth/permissions/constants.js +13 -0
  97. package/dist/features/cart/components/CartPriceBreakdown.d.ts +13 -0
  98. package/dist/features/cart/components/CartPriceBreakdown.js +6 -2
  99. package/dist/features/cart/components/PointsTenderPicker.d.ts +61 -0
  100. package/dist/features/cart/components/PointsTenderPicker.js +15 -0
  101. package/dist/features/cart/components/StoreAddonsPicker.js +2 -1
  102. package/dist/features/cart/components/index.d.ts +2 -0
  103. package/dist/features/cart/components/index.js +1 -0
  104. package/dist/features/cart/repository/cart.repository.d.ts +19 -0
  105. package/dist/features/cart/repository/cart.repository.js +27 -0
  106. package/dist/features/cart/schemas/firestore.d.ts +92 -0
  107. package/dist/features/contact/email.d.ts +27 -10
  108. package/dist/features/contact/email.js +20 -3
  109. package/dist/features/dispute-reasons/repository/dispute-reasons.repository.d.ts +38 -0
  110. package/dist/features/dispute-reasons/repository/dispute-reasons.repository.js +80 -0
  111. package/dist/features/dispute-reasons/schemas/firestore.d.ts +64 -0
  112. package/dist/features/dispute-reasons/schemas/firestore.js +40 -0
  113. package/dist/features/faq/components/FAQAccordion.d.ts +13 -1
  114. package/dist/features/faq/components/FAQAccordion.js +29 -4
  115. package/dist/features/invoicing/schemas/firestore.d.ts +112 -0
  116. package/dist/features/invoicing/schemas/firestore.js +45 -0
  117. package/dist/features/invoicing/utils/financial-year.d.ts +43 -0
  118. package/dist/features/invoicing/utils/financial-year.js +53 -0
  119. package/dist/features/jobs/actions/enqueue-job.js +18 -1
  120. package/dist/features/jobs/repository/jobs.repository.d.ts +62 -1
  121. package/dist/features/jobs/repository/jobs.repository.js +84 -1
  122. package/dist/features/jobs/schemas/firestore.d.ts +80 -0
  123. package/dist/features/jobs/schemas/firestore.js +37 -0
  124. package/dist/features/lottery/schemas/zod.d.ts +6 -6
  125. package/dist/features/media/MediaImage.js +22 -1
  126. package/dist/features/media/upload/ImageUpload.js +1 -1
  127. package/dist/features/obligations/constants/policies.js +24 -1
  128. package/dist/features/orders/components/OrderPaymentSummary.js +10 -1
  129. package/dist/features/orders/components/OrderProvenanceCard.d.ts +8 -0
  130. package/dist/features/orders/components/OrderProvenanceCard.js +185 -0
  131. package/dist/features/orders/components/RaiseDisputeForm.d.ts +14 -0
  132. package/dist/features/orders/components/RaiseDisputeForm.js +111 -0
  133. package/dist/features/orders/components/RefundRequestView.js +19 -1
  134. package/dist/features/orders/components/index.d.ts +4 -0
  135. package/dist/features/orders/components/index.js +2 -0
  136. package/dist/features/orders/constants/order-lane-tabs.d.ts +69 -0
  137. package/dist/features/orders/constants/order-lane-tabs.js +88 -0
  138. package/dist/features/orders/repository/orders.repository.d.ts +57 -0
  139. package/dist/features/orders/repository/orders.repository.js +145 -0
  140. package/dist/features/orders/schemas/firestore.d.ts +196 -1
  141. package/dist/features/orders/schemas/index.d.ts +54 -6
  142. package/dist/features/orders/schemas/index.js +12 -0
  143. package/dist/features/orders/types/index.d.ts +26 -0
  144. package/dist/features/orders/utils/courier-block.d.ts +25 -0
  145. package/dist/features/orders/utils/courier-block.js +23 -0
  146. package/dist/features/payment-cases/schemas/firestore.d.ts +26 -1
  147. package/dist/features/payment-cases/schemas/firestore.js +1 -0
  148. package/dist/features/products/components/PrizeDrawDetailPageView.js +2 -2
  149. package/dist/features/products/components/ProductDetailPageView.d.ts +17 -1
  150. package/dist/features/products/components/ProductDetailPageView.js +2 -2
  151. package/dist/features/products/schemas/product-features.validators.d.ts +10 -10
  152. package/dist/features/promotions/actions/coupon-stacking.d.ts +30 -3
  153. package/dist/features/promotions/actions/coupon-stacking.js +21 -2
  154. package/dist/features/promotions/components/CouponCard.js +13 -0
  155. package/dist/features/promotions/constants/coupon-help.d.ts +2 -2
  156. package/dist/features/promotions/constants/coupon-help.js +9 -1
  157. package/dist/features/promotions/schemas/firestore.d.ts +24 -0
  158. package/dist/features/promotions/schemas/firestore.js +4 -0
  159. package/dist/features/promotions/types/index.d.ts +19 -1
  160. package/dist/features/scams/components/ScamProfileView.js +2 -2
  161. package/dist/features/scams/components/ScamRegistryView.js +2 -2
  162. package/dist/features/search/action-index/tab-entries.js +1 -1
  163. package/dist/features/seller/actions/seller-actions.js +33 -3
  164. package/dist/features/seller/components/SellerOrdersView.js +129 -27
  165. package/dist/features/seller/hooks/useSellerListingData.js +25 -0
  166. package/dist/features/shipments/schemas/validation.d.ts +4 -4
  167. package/dist/features/shipping-boxes/repository/shipping-boxes.repository.d.ts +43 -0
  168. package/dist/features/shipping-boxes/repository/shipping-boxes.repository.js +90 -0
  169. package/dist/features/shipping-boxes/schemas/firestore.d.ts +82 -0
  170. package/dist/features/shipping-boxes/schemas/firestore.js +53 -0
  171. package/dist/features/store-extensions/schemas/report-create-form.d.ts +2 -2
  172. package/dist/features/store-extensions/schemas/shipping-config-form.d.ts +2 -2
  173. package/dist/features/stores/components/StoreOrdersGuideView.js +6 -1
  174. package/dist/features/stores/schemas/firestore.d.ts +71 -0
  175. package/dist/features/stores/types/index.d.ts +19 -0
  176. package/dist/features/support/schemas/index.d.ts +6 -6
  177. package/dist/features/wishlist/hooks/useWishlistWithGuest.d.ts +1 -1
  178. package/dist/index.d.ts +6 -1
  179. package/dist/index.js +14 -1
  180. package/dist/next/routing/route-map.d.ts +20 -0
  181. package/dist/next/routing/route-map.js +10 -0
  182. package/dist/providers/shipping-shiprocket/index.d.ts +27 -1
  183. package/dist/providers/shipping-shiprocket/index.js +84 -1
  184. package/dist/schemas/registry.d.ts +47 -18
  185. package/dist/schemas/sieve.d.ts +2 -2
  186. package/dist/server-entry.d.ts +2 -2
  187. package/dist/server-entry.js +8 -1
  188. package/dist/server.d.ts +10 -1
  189. package/dist/server.js +39 -1
  190. package/dist/styles.css +64 -80
  191. package/dist/tailwind-utilities.css +1 -1
  192. package/dist/tokens/themes/default-dark.js +1 -0
  193. package/dist/tokens/themes/default-light.js +1 -0
  194. package/dist/tokens/themes/required.d.ts +1 -1
  195. package/dist/tokens/themes/required.js +1 -0
  196. package/dist/tokens/tokens.css +15 -0
  197. package/dist/ui/components/Disclaimer.d.ts +19 -0
  198. package/dist/ui/components/Disclaimer.js +74 -0
  199. package/dist/ui/components/tabs-overflow.js +64 -11
  200. package/dist/ui/index.d.ts +2 -0
  201. package/dist/ui/index.js +6 -0
  202. package/dist/ui/rich-text/RichText.style.css +48 -79
  203. package/package.json +1 -1
  204. package/scripts/seed-cli.mjs +1831 -1822
@@ -145,6 +145,15 @@ export declare const orderRefundEventSchema: z.ZodObject<{
145
145
  proofDocumentUrl: z.ZodOptional<z.ZodString>;
146
146
  proofDocumentMimeType: z.ZodOptional<z.ZodString>;
147
147
  overrideReason: z.ZodOptional<z.ZodString>;
148
+ creditNoteNumber: z.ZodOptional<z.ZodString>;
149
+ creditNoteIssuedAt: z.ZodOptional<z.ZodUnion<[z.ZodDate, z.ZodString, z.ZodObject<{
150
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
151
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
152
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
153
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
154
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
155
+ }, z.ZodTypeAny, "passthrough">>]>>;
156
+ creditNoteStoragePath: z.ZodOptional<z.ZodString>;
148
157
  }, "strip", z.ZodTypeAny, {
149
158
  type: "full" | "partial";
150
159
  amount: number;
@@ -155,8 +164,8 @@ export declare const orderRefundEventSchema: z.ZodObject<{
155
164
  }, z.ZodTypeAny, "passthrough">;
156
165
  refundedBy: string;
157
166
  status?: "failed" | "processed" | "reserved" | undefined;
158
- failureReason?: string | undefined;
159
167
  gateway?: string | undefined;
168
+ failureReason?: string | undefined;
160
169
  itemIds?: string[] | undefined;
161
170
  reasonCode?: string | undefined;
162
171
  gatewayRefundId?: string | undefined;
@@ -166,6 +175,11 @@ export declare const orderRefundEventSchema: z.ZodObject<{
166
175
  proofDocumentUrl?: string | undefined;
167
176
  proofDocumentMimeType?: string | undefined;
168
177
  overrideReason?: string | undefined;
178
+ creditNoteNumber?: string | undefined;
179
+ creditNoteIssuedAt?: string | Date | z.objectOutputType<{
180
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
181
+ }, z.ZodTypeAny, "passthrough"> | undefined;
182
+ creditNoteStoragePath?: string | undefined;
169
183
  }, {
170
184
  type: "full" | "partial";
171
185
  amount: number;
@@ -176,8 +190,8 @@ export declare const orderRefundEventSchema: z.ZodObject<{
176
190
  }, z.ZodTypeAny, "passthrough">;
177
191
  refundedBy: string;
178
192
  status?: "failed" | "processed" | "reserved" | undefined;
179
- failureReason?: string | undefined;
180
193
  gateway?: string | undefined;
194
+ failureReason?: string | undefined;
181
195
  itemIds?: string[] | undefined;
182
196
  reasonCode?: string | undefined;
183
197
  gatewayRefundId?: string | undefined;
@@ -187,6 +201,11 @@ export declare const orderRefundEventSchema: z.ZodObject<{
187
201
  proofDocumentUrl?: string | undefined;
188
202
  proofDocumentMimeType?: string | undefined;
189
203
  overrideReason?: string | undefined;
204
+ creditNoteNumber?: string | undefined;
205
+ creditNoteIssuedAt?: string | Date | z.objectInputType<{
206
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
207
+ }, z.ZodTypeAny, "passthrough"> | undefined;
208
+ creditNoteStoragePath?: string | undefined;
190
209
  }>;
191
210
  export declare const appliedOrderDiscountSchema: z.ZodObject<{
192
211
  code: z.ZodString;
@@ -499,6 +518,15 @@ export declare const orderFirestoreSchema: z.ZodObject<{
499
518
  proofDocumentUrl: z.ZodOptional<z.ZodString>;
500
519
  proofDocumentMimeType: z.ZodOptional<z.ZodString>;
501
520
  overrideReason: z.ZodOptional<z.ZodString>;
521
+ creditNoteNumber: z.ZodOptional<z.ZodString>;
522
+ creditNoteIssuedAt: z.ZodOptional<z.ZodUnion<[z.ZodDate, z.ZodString, z.ZodObject<{
523
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
524
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
525
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
526
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
527
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
528
+ }, z.ZodTypeAny, "passthrough">>]>>;
529
+ creditNoteStoragePath: z.ZodOptional<z.ZodString>;
502
530
  }, "strip", z.ZodTypeAny, {
503
531
  type: "full" | "partial";
504
532
  amount: number;
@@ -509,8 +537,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
509
537
  }, z.ZodTypeAny, "passthrough">;
510
538
  refundedBy: string;
511
539
  status?: "failed" | "processed" | "reserved" | undefined;
512
- failureReason?: string | undefined;
513
540
  gateway?: string | undefined;
541
+ failureReason?: string | undefined;
514
542
  itemIds?: string[] | undefined;
515
543
  reasonCode?: string | undefined;
516
544
  gatewayRefundId?: string | undefined;
@@ -520,6 +548,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
520
548
  proofDocumentUrl?: string | undefined;
521
549
  proofDocumentMimeType?: string | undefined;
522
550
  overrideReason?: string | undefined;
551
+ creditNoteNumber?: string | undefined;
552
+ creditNoteIssuedAt?: string | Date | z.objectOutputType<{
553
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
554
+ }, z.ZodTypeAny, "passthrough"> | undefined;
555
+ creditNoteStoragePath?: string | undefined;
523
556
  }, {
524
557
  type: "full" | "partial";
525
558
  amount: number;
@@ -530,8 +563,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
530
563
  }, z.ZodTypeAny, "passthrough">;
531
564
  refundedBy: string;
532
565
  status?: "failed" | "processed" | "reserved" | undefined;
533
- failureReason?: string | undefined;
534
566
  gateway?: string | undefined;
567
+ failureReason?: string | undefined;
535
568
  itemIds?: string[] | undefined;
536
569
  reasonCode?: string | undefined;
537
570
  gatewayRefundId?: string | undefined;
@@ -541,6 +574,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
541
574
  proofDocumentUrl?: string | undefined;
542
575
  proofDocumentMimeType?: string | undefined;
543
576
  overrideReason?: string | undefined;
577
+ creditNoteNumber?: string | undefined;
578
+ creditNoteIssuedAt?: string | Date | z.objectInputType<{
579
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
580
+ }, z.ZodTypeAny, "passthrough"> | undefined;
581
+ creditNoteStoragePath?: string | undefined;
544
582
  }>, "many">>;
545
583
  contestable: z.ZodOptional<z.ZodBoolean>;
546
584
  adminBypassBy: z.ZodOptional<z.ZodString>;
@@ -711,8 +749,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
711
749
  }, z.ZodTypeAny, "passthrough">;
712
750
  refundedBy: string;
713
751
  status?: "failed" | "processed" | "reserved" | undefined;
714
- failureReason?: string | undefined;
715
752
  gateway?: string | undefined;
753
+ failureReason?: string | undefined;
716
754
  itemIds?: string[] | undefined;
717
755
  reasonCode?: string | undefined;
718
756
  gatewayRefundId?: string | undefined;
@@ -722,6 +760,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
722
760
  proofDocumentUrl?: string | undefined;
723
761
  proofDocumentMimeType?: string | undefined;
724
762
  overrideReason?: string | undefined;
763
+ creditNoteNumber?: string | undefined;
764
+ creditNoteIssuedAt?: string | Date | z.objectOutputType<{
765
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
766
+ }, z.ZodTypeAny, "passthrough"> | undefined;
767
+ creditNoteStoragePath?: string | undefined;
725
768
  }[] | undefined;
726
769
  contestable?: boolean | undefined;
727
770
  adminBypassBy?: string | undefined;
@@ -865,8 +908,8 @@ export declare const orderFirestoreSchema: z.ZodObject<{
865
908
  }, z.ZodTypeAny, "passthrough">;
866
909
  refundedBy: string;
867
910
  status?: "failed" | "processed" | "reserved" | undefined;
868
- failureReason?: string | undefined;
869
911
  gateway?: string | undefined;
912
+ failureReason?: string | undefined;
870
913
  itemIds?: string[] | undefined;
871
914
  reasonCode?: string | undefined;
872
915
  gatewayRefundId?: string | undefined;
@@ -876,6 +919,11 @@ export declare const orderFirestoreSchema: z.ZodObject<{
876
919
  proofDocumentUrl?: string | undefined;
877
920
  proofDocumentMimeType?: string | undefined;
878
921
  overrideReason?: string | undefined;
922
+ creditNoteNumber?: string | undefined;
923
+ creditNoteIssuedAt?: string | Date | z.objectInputType<{
924
+ toDate: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodDate>;
925
+ }, z.ZodTypeAny, "passthrough"> | undefined;
926
+ creditNoteStoragePath?: string | undefined;
879
927
  }[] | undefined;
880
928
  contestable?: boolean | undefined;
881
929
  adminBypassBy?: string | undefined;
@@ -87,6 +87,18 @@ export const orderRefundEventSchema = z.object({
87
87
  proofDocumentUrl: z.string().optional(),
88
88
  proofDocumentMimeType: z.string().optional(),
89
89
  overrideReason: z.string().optional(),
90
+ /*
91
+ * Phase 7 credit note. Added HERE in the same change as the interface, per
92
+ * the 🛑 above: `z.object()` STRIPS unknown keys, so a field present on the
93
+ * interface and absent here is REMOVED on parse — it does not error, it
94
+ * vanishes. That is exactly how this schema silently discarded
95
+ * `razorpayRefundId`, and a credit-note number discarded on parse is a
96
+ * numbered document with nothing pointing at it: the number is consumed, the
97
+ * series has no gap, and no refund claims it.
98
+ */
99
+ creditNoteNumber: z.string().optional(),
100
+ creditNoteIssuedAt: firestoreDateSchema.optional(),
101
+ creditNoteStoragePath: z.string().optional(),
90
102
  });
91
103
  export const appliedOrderDiscountSchema = z.object({
92
104
  code: z.string(),
@@ -250,6 +250,32 @@ export interface Order {
250
250
  platformFee?: number;
251
251
  /** COD handling fee, charged only on cash-on-delivery orders. */
252
252
  codHandlingFee?: number;
253
+ /**
254
+ * D46/D47 — points spent on this order, in points (1 point = ₹1).
255
+ *
256
+ * Absent on every order placed before the tender existed, and absent on any
257
+ * order that used none.
258
+ */
259
+ pointsApplied?: number;
260
+ /**
261
+ * What was actually COLLECTED: `total − pointsApplied`.
262
+ *
263
+ * 🛑 Read it as **`amountDue ?? total`**, never `amountDue ?? 0`. Absent means
264
+ * "no points were used, so the whole total was collected"; zero would mean
265
+ * the order was free. The two are a long way apart on a receipt, and the
266
+ * wrong default turns every historical order into a ₹0 one.
267
+ */
268
+ amountDue?: number;
269
+ /**
270
+ * The invoice number from the gapless FY series, e.g. `LIR/26-27/0001`
271
+ * (Phase 7).
272
+ *
273
+ * Absent until the order is paid, and absent on every order placed before
274
+ * the series existed — so the invoice page must render its own fallback
275
+ * rather than printing "undefined" where a statutory field belongs.
276
+ */
277
+ invoiceNumber?: string;
278
+ invoiceIssuedAt?: string;
253
279
  trackingNumber?: string;
254
280
  shippingCarrier?: string;
255
281
  /** Carrier tracking page URL — rendered as an external link that opens in a new tab. No live-tracking API integration; this is just the passthrough URL a seller/admin entered. */
@@ -0,0 +1,25 @@
1
+ /**
2
+ * "Is this order waiting on OUR courier problem?" — one predicate, so the
3
+ * obligation engine, the seller's UI and the admin digest cannot disagree.
4
+ *
5
+ * Deliberately a function over the document rather than a stored boolean: a
6
+ * denormalised `isCourierBlocked` mirror drifts the first time a write path
7
+ * forgets it (Root Cause #42), and the field it derives from is right there.
8
+ */
9
+ import type { OrderDocument } from "../schemas/firestore";
10
+ /** The subset actually read, so callers need not hold a whole order. */
11
+ export interface CourierBlockBearing {
12
+ courierBlock?: OrderDocument["courierBlock"];
13
+ shippingDate?: Date | null;
14
+ }
15
+ /**
16
+ * True while a courier booking we attempted is still unresolved.
17
+ *
18
+ * 🛑 A block is CLEARED by the parcel actually going out, not by anything
19
+ * clearing the field. So a `shippingDate` wins over a stale `courierBlock`:
20
+ * if the seller gave up waiting and posted it themselves, the order is
21
+ * dispatched and the block is history, even if nobody deleted it. Reading the
22
+ * field alone would pause the dispatch clock forever on an order that had in
23
+ * fact shipped.
24
+ */
25
+ export declare function hasOpenCourierBlock(order: CourierBlockBearing): boolean;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * "Is this order waiting on OUR courier problem?" — one predicate, so the
3
+ * obligation engine, the seller's UI and the admin digest cannot disagree.
4
+ *
5
+ * Deliberately a function over the document rather than a stored boolean: a
6
+ * denormalised `isCourierBlocked` mirror drifts the first time a write path
7
+ * forgets it (Root Cause #42), and the field it derives from is right there.
8
+ */
9
+ /**
10
+ * True while a courier booking we attempted is still unresolved.
11
+ *
12
+ * 🛑 A block is CLEARED by the parcel actually going out, not by anything
13
+ * clearing the field. So a `shippingDate` wins over a stale `courierBlock`:
14
+ * if the seller gave up waiting and posted it themselves, the order is
15
+ * dispatched and the block is history, even if nobody deleted it. Reading the
16
+ * field alone would pause the dispatch clock forever on an order that had in
17
+ * fact shipped.
18
+ */
19
+ export function hasOpenCourierBlock(order) {
20
+ if (!order.courierBlock)
21
+ return false;
22
+ return !order.shippingDate;
23
+ }
@@ -107,7 +107,32 @@ export type PaymentCaseKind = "missing_order" | "unprocessed_event" | "status_co
107
107
  * Keyed on the USER, so a persistently broken mirror is one case with a
108
108
  * rising `observedCount` rather than a new row every night.
109
109
  */
110
- | "ledger_drift";
110
+ | "ledger_drift"
111
+ /**
112
+ * We could not book a courier, so one or more PAID orders cannot be
113
+ * dispatched by us.
114
+ *
115
+ * The commonest cause is our own prepaid courier wallet running dry —
116
+ * Shiprocket has no recharge API, so the top-up is irreducibly a human
117
+ * action, which is exactly what a case is for.
118
+ *
119
+ * 🛑 KEYED ON THE WALLET (the provider), NOT ON THE ORDER. Fifty blocked
120
+ * orders are ONE problem with one fix, and the daily email ceiling applies
121
+ * to staff mail too (`send-guard.ts:92`) — so a per-order case would open
122
+ * fifty rows and spend the whole 80/day budget telling an operator the same
123
+ * thing fifty times, leaving them blind to everything else. `openOrObserve`
124
+ * raises `observedCount` instead, which also makes "how many orders are
125
+ * stuck behind this" readable at a glance.
126
+ *
127
+ * 🛑 Its own kind rather than `shipping_unpriced`, which means we could not
128
+ * work out what shipping COSTS. Here the price is known and the money to pay
129
+ * it is not there. The kind chips are what an operator triages by, and this
130
+ * is the fourth time this file has had to say so — the shortcut is always
131
+ * attractive because a plausible kind already exists.
132
+ *
133
+ * `severity: "error"`: a buyer has paid and their parcel is not moving.
134
+ */
135
+ | "courier_unavailable";
111
136
  /**
112
137
  * Identical to `ReportStatus`, deliberately — see the header. `actioned` means
113
138
  * a human did something; `dismissed` means a human decided nothing was wrong.
@@ -81,6 +81,7 @@ const PAYMENT_CASE_KIND_MAP = {
81
81
  protection_claim: true,
82
82
  manual_refund_due: true,
83
83
  ledger_drift: true,
84
+ courier_unavailable: true,
84
85
  };
85
86
  export const PAYMENT_CASE_KINDS = Object.keys(PAYMENT_CASE_KIND_MAP);
86
87
  const PAYMENT_CASE_STATUS_MAP = {
@@ -11,7 +11,7 @@ import { ROUTES } from "../../../next/routing/route-map.js";
11
11
  import { getDefaultCurrency } from "../../../core/baseline-resolver.js";
12
12
  import { normalizeRichTextHtml } from "../../../utils/string.formatter.js";
13
13
  import { safeDisplayName } from "../../../security/index.js";
14
- import { Container, Div, Heading, Main, RichText, Row, Section, Span, Stack, Text, } from "../../../ui/index.js";
14
+ import { Container, Disclaimer, Div, Heading, Main, RichText, Row, Section, Span, Stack, Text, } from "../../../ui/index.js";
15
15
  import { PreOrderDetailView } from "./PreOrderDetailView.js";
16
16
  import { PrizeDrawBottomActions } from "./PrizeDrawBottomActions.js";
17
17
  import { ProductTabsShell } from "./ProductTabsShell.js";
@@ -133,5 +133,5 @@ export async function PrizeDrawDetailPageView({ id, initialPrizeDraw, currentUse
133
133
  price: pricePerEntry,
134
134
  storeId: typeof p.storeId === "string" ? p.storeId : undefined,
135
135
  storeName: storeName ?? undefined,
136
- } }), _jsxs(Container, { size: "xl", padding: "y-lg", children: [_jsxs(Row, { className: "mb-4", align: "center", justify: "between", gap: "sm", wrap: true, children: [_jsxs("nav", { "aria-label": "Breadcrumb", className: "flex items-center gap-[var(--appkit-space-1-5)] text-[length:var(--appkit-text-xs)] text-[var(--appkit-color-text-muted)] flex-wrap", children: [_jsx(Link, { href: String(ROUTES.HOME), className: "hover:text-primary-600 dark:hover:text-primary-400 transition-colors", children: "Home" }), _jsx(Span, { "aria-hidden": true, children: "/" }), _jsx(Link, { href: String(ROUTES.PUBLIC.PRIZE_DRAWS), className: "hover:text-primary-600 dark:hover:text-primary-400 transition-colors", children: "Prize Draws" }), _jsx(Span, { "aria-hidden": true, children: "/" }), _jsx(Span, { className: "truncate max-w-[200px]", color: "muted", children: title })] }), _jsx(ShareButton, { title: title })] }), _jsx(PreOrderDetailView, { renderGallery: () => (_jsx(PrizeDrawCollage, { items: items, hideWonState: true })), renderInfo: () => (_jsxs(Stack, { gap: "md", children: [_jsx(OwnerQuickActions, { resource: "PRODUCT", placement: "detail", recordLabel: String(product.title ?? product.id), storeId: product.storeId ? String(product.storeId) : undefined, editHref: String(ROUTES.STORE.PRODUCTS_EDIT(String(product.id))) }), _jsxs(Div, { children: [_jsxs(Row, { gap: "xs", wrap: true, className: "mb-2", children: [_jsx(Span, { size: "xs", weight: "semibold", className: CLS_PRIZE_BADGE, children: "Prize Draw" }), _jsx(Span, { size: "xs", weight: "semibold", className: `inline-block ${statusClass(revealStatus)}`, padding: "pill-sm", rounded: "full", children: statusLabel(revealStatus) }), maxPerUser !== null && (_jsxs(Span, { size: "xs", weight: "medium", className: "inline-block", padding: "pill-sm", rounded: "full", surface: "subtle", color: "muted", children: ["Limit: ", maxPerUser, " entries per customer"] })), maxPerUser !== null && userEntriesUsed !== null && (_jsxs(Span, { size: "xs", weight: "semibold", className: CLS_PRIZE_BADGE, children: ["You have used ", userEntriesUsed, "/", maxPerUser] }))] }), _jsx(Heading, { level: 1, className: "leading-snug", smSize: "2xl", color: "primary", size: "xl", weight: "bold", children: title })] }), _jsx(Div, { className: `${__P.p4}`, border: "subtle", rounded: "xl", surface: "muted", children: _jsxs(Stack, { gap: "sm", children: [_jsxs(Row, { justify: "between", align: "center", children: [_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Entries" }), _jsxs(Text, { size: "sm", weight: "semibold", children: [current, " / ", max, " (", remaining, " left)"] })] }), revealStart && (_jsxs(Row, { justify: "between", align: "center", children: [_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Reveal window opens" }), _jsx(Text, { size: "sm", weight: "medium", children: revealStart.toLocaleString() })] })), revealEnd && (_jsxs(Row, { justify: "between", align: "center", children: [_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Reveal window closes" }), _jsx(Text, { size: "sm", weight: "medium", children: revealEnd.toLocaleString() })] }))] }) }), descriptionHtml && (_jsx(RichText, { html: descriptionHtml, proseClass: "prose prose-sm max-w-none dark:prose-invert prose-p:my-0", className: "text-[length:var(--appkit-text-sm)] leading-relaxed text-[var(--appkit-color-text-muted)] line-clamp-4" })), safeSeller && (_jsx(Div, { className: `${__P.p3}`, border: "subtle", rounded: "xl", surface: "muted", children: _jsxs(Row, { justify: "between", align: "center", children: [_jsxs(Div, { children: [_jsx(Text, { className: "text-[10px] tracking-wide mb-0.5", color: "faint", transform: "uppercase", children: "Sold by" }), _jsx(Text, { size: "sm", weight: "semibold", color: "primary", children: safeSeller })] }), storeHref && (_jsx(Link, { href: storeHref, className: "shrink-0 rounded-lg bg-primary/10 dark:bg-primary/20 px-[var(--appkit-space-3)] py-[var(--appkit-space-1-5)] text-[length:var(--appkit-text-xs)] font-semibold text-primary-700 dark:text-primary-300 hover:bg-primary/20 dark:hover:bg-primary/30 transition-colors", children: "Visit Store \u2192" }))] }) }))] })), renderTabs: () => (_jsx(ProductTabsShell, { descriptionContent: descriptionHtml ? (_jsx(RichText, { html: descriptionHtml, proseClass: "prose prose-sm sm:prose max-w-none dark:prose-invert", className: "text-[var(--appkit-color-text-muted)]" })) : undefined })), renderBuyBar: () => (_jsx(Div, { padding: "5", id: "prize-draw-buy-bar", border: "subtle", surface: "muted", rounded: "xl", children: _jsx(PrizeDrawEntryActions, { productId: String(product.id), productSlug: slug, title: title, pricePerEntry: pricePerEntry, currency: currency, remainingEntries: remaining, revealStatus: revealStatus, prizeGithubFileUrl: githubUrl }) })), renderRelated: () => (_jsxs(Stack, { gap: "xl", children: [_jsx(PurchaseReviewAffordance, { productId: String(product.id), storeId: product.storeId ? String(product.storeId) : undefined }), _jsx(GroupedListingsCarousel, { groups: groups }), _jsx(RelatedItemsSection, { relatedItems: relatedItems, relatedByBrand: relatedByBrand, relatedByTags: relatedByTags, relatedByStore: relatedByStore, categoryLabel: categoryName, brandLabel: brand, storeLabel: storeName ?? undefined })] })) }), _jsx(PrizeDrawBottomActions, { pricePerEntry: pricePerEntry, currency: currency, closed: revealStatus === "closed" || remaining === 0 })] })] }));
136
+ } }), _jsxs(Container, { size: "xl", padding: "y-lg", children: [_jsxs(Row, { className: "mb-4", align: "center", justify: "between", gap: "sm", wrap: true, children: [_jsxs("nav", { "aria-label": "Breadcrumb", className: "flex items-center gap-[var(--appkit-space-1-5)] text-[length:var(--appkit-text-xs)] text-[var(--appkit-color-text-muted)] flex-wrap", children: [_jsx(Link, { href: String(ROUTES.HOME), className: "hover:text-primary-600 dark:hover:text-primary-400 transition-colors", children: "Home" }), _jsx(Span, { "aria-hidden": true, children: "/" }), _jsx(Link, { href: String(ROUTES.PUBLIC.PRIZE_DRAWS), className: "hover:text-primary-600 dark:hover:text-primary-400 transition-colors", children: "Prize Draws" }), _jsx(Span, { "aria-hidden": true, children: "/" }), _jsx(Span, { className: "truncate max-w-[200px]", color: "muted", children: title })] }), _jsx(ShareButton, { title: title })] }), _jsx(PreOrderDetailView, { renderGallery: () => (_jsx(PrizeDrawCollage, { items: items, hideWonState: true })), renderInfo: () => (_jsxs(Stack, { gap: "md", children: [_jsx(OwnerQuickActions, { resource: "PRODUCT", placement: "detail", recordLabel: String(product.title ?? product.id), storeId: product.storeId ? String(product.storeId) : undefined, editHref: String(ROUTES.STORE.PRODUCTS_EDIT(String(product.id))) }), _jsxs(Div, { children: [_jsxs(Row, { gap: "xs", wrap: true, className: "mb-2", children: [_jsx(Span, { size: "xs", weight: "semibold", className: CLS_PRIZE_BADGE, children: "Prize Draw" }), _jsx(Span, { size: "xs", weight: "semibold", className: `inline-block ${statusClass(revealStatus)}`, padding: "pill-sm", rounded: "full", children: statusLabel(revealStatus) }), maxPerUser !== null && (_jsxs(Span, { size: "xs", weight: "medium", className: "inline-block", padding: "pill-sm", rounded: "full", surface: "subtle", color: "muted", children: ["Limit: ", maxPerUser, " entries per customer"] })), maxPerUser !== null && userEntriesUsed !== null && (_jsxs(Span, { size: "xs", weight: "semibold", className: CLS_PRIZE_BADGE, children: ["You have used ", userEntriesUsed, "/", maxPerUser] }))] }), _jsx(Heading, { level: 1, className: "leading-snug", smSize: "2xl", color: "primary", size: "xl", weight: "bold", children: title })] }), _jsx(Div, { className: `${__P.p4}`, border: "subtle", rounded: "xl", surface: "muted", children: _jsxs(Stack, { gap: "sm", children: [_jsxs(Row, { justify: "between", align: "center", children: [_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Entries" }), _jsxs(Text, { size: "sm", weight: "semibold", children: [current, " / ", max, " (", remaining, " left)"] })] }), revealStart && (_jsxs(Row, { justify: "between", align: "center", children: [_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Reveal window opens" }), _jsx(Text, { size: "sm", weight: "medium", children: revealStart.toLocaleString() })] })), revealEnd && (_jsxs(Row, { justify: "between", align: "center", children: [_jsx(Text, { className: "text-[var(--appkit-color-text-muted)]", size: "sm", children: "Reveal window closes" }), _jsx(Text, { size: "sm", weight: "medium", children: revealEnd.toLocaleString() })] }))] }) }), descriptionHtml && (_jsx(RichText, { html: descriptionHtml, proseClass: "prose prose-sm max-w-none dark:prose-invert prose-p:my-0", className: "text-[length:var(--appkit-text-sm)] leading-relaxed text-[var(--appkit-color-text-muted)] line-clamp-4" })), safeSeller && (_jsx(Div, { className: `${__P.p3}`, border: "subtle", rounded: "xl", surface: "muted", children: _jsxs(Row, { justify: "between", align: "center", children: [_jsxs(Div, { children: [_jsx(Text, { className: "text-[10px] tracking-wide mb-0.5", color: "faint", transform: "uppercase", children: "Sold by" }), _jsx(Text, { size: "sm", weight: "semibold", color: "primary", children: safeSeller })] }), storeHref && (_jsx(Link, { href: storeHref, className: "shrink-0 rounded-lg bg-primary/10 dark:bg-primary/20 px-[var(--appkit-space-3)] py-[var(--appkit-space-1-5)] text-[length:var(--appkit-text-xs)] font-semibold text-primary-700 dark:text-primary-300 hover:bg-primary/20 dark:hover:bg-primary/30 transition-colors", children: "Visit Store \u2192" }))] }) })), _jsx(Disclaimer, { id: "prize-draw" })] })), renderTabs: () => (_jsx(ProductTabsShell, { descriptionContent: descriptionHtml ? (_jsx(RichText, { html: descriptionHtml, proseClass: "prose prose-sm sm:prose max-w-none dark:prose-invert", className: "text-[var(--appkit-color-text-muted)]" })) : undefined })), renderBuyBar: () => (_jsx(Div, { padding: "5", id: "prize-draw-buy-bar", border: "subtle", surface: "muted", rounded: "xl", children: _jsx(PrizeDrawEntryActions, { productId: String(product.id), productSlug: slug, title: title, pricePerEntry: pricePerEntry, currency: currency, remainingEntries: remaining, revealStatus: revealStatus, prizeGithubFileUrl: githubUrl }) })), renderRelated: () => (_jsxs(Stack, { gap: "xl", children: [_jsx(PurchaseReviewAffordance, { productId: String(product.id), storeId: product.storeId ? String(product.storeId) : undefined }), _jsx(GroupedListingsCarousel, { groups: groups }), _jsx(RelatedItemsSection, { relatedItems: relatedItems, relatedByBrand: relatedByBrand, relatedByTags: relatedByTags, relatedByStore: relatedByStore, categoryLabel: categoryName, brandLabel: brand, storeLabel: storeName ?? undefined })] })) }), _jsx(PrizeDrawBottomActions, { pricePerEntry: pricePerEntry, currency: currency, closed: revealStatus === "closed" || remaining === 0 })] })] }));
137
137
  }
@@ -77,5 +77,21 @@ export interface ProductDetailPageViewProps {
77
77
  * Available" feature badge.
78
78
  */
79
79
  emiEnabled?: boolean;
80
+ /**
81
+ * Site-wide returns availability (`siteSettings.returns.windowDays > 0`),
82
+ * threaded from the page's data layer. Drives the "Returnable" badge.
83
+ *
84
+ * 🛑 A SITE feature gate, not a product attribute. The badge used to read
85
+ * `returnable={!finalSale}` — purely the product's own flag — so a platform
86
+ * with returns switched off still promised "Returnable" on every listing
87
+ * that was not a final sale. Same shape as the COD gate beside it: the
88
+ * product may carry the attribute, and we simply do not advertise it while
89
+ * the feature is off. Nothing is written to the product.
90
+ *
91
+ * Defaults to `true` when omitted so the two detail views that do not thread
92
+ * site settings keep their current behaviour rather than silently losing a
93
+ * badge they were correctly showing.
94
+ */
95
+ returnsEnabled?: boolean;
80
96
  }
81
- export declare function ProductDetailPageView({ slug, initialProduct, renderOfferAction, renderPrimaryActions, compositionContent, productFeatures, codEnabled, emiEnabled, }: ProductDetailPageViewProps): Promise<import("react").JSX.Element>;
97
+ export declare function ProductDetailPageView({ slug, initialProduct, renderOfferAction, renderPrimaryActions, compositionContent, productFeatures, codEnabled, emiEnabled, returnsEnabled, }: ProductDetailPageViewProps): Promise<import("react").JSX.Element>;
@@ -79,7 +79,7 @@ function StarRating({ value }) {
79
79
  // ---------------------------------------------------------------------------
80
80
  // Component
81
81
  // ---------------------------------------------------------------------------
82
- export async function ProductDetailPageView({ slug, initialProduct, renderOfferAction, renderPrimaryActions, compositionContent, productFeatures, codEnabled, emiEnabled, }) {
82
+ export async function ProductDetailPageView({ slug, initialProduct, renderOfferAction, renderPrimaryActions, compositionContent, productFeatures, codEnabled, emiEnabled, returnsEnabled = true, }) {
83
83
  // Use pre-fetched data when available to avoid a redundant repository call.
84
84
  // The page layer wraps getProductForDetail in React.cache(), so both
85
85
  // generateMetadata() and this component share the same in-flight promise.
@@ -386,7 +386,7 @@ export async function ProductDetailPageView({ slug, initialProduct, renderOfferA
386
386
  ? "✓ In Stock"
387
387
  : "✗ Out of Stock", inStock && effectiveStock !== null && effectiveStock <= 10
388
388
  ? ` — only ${effectiveStock} left`
389
- : ""] })), (categorySlugs.length > 0 || subcategory || brand) && (_jsxs(Row, { gap: "sm", wrap: true, children: [categorySlugs.map((slug, i) => (_jsx(Link, { href: String(ROUTES.PUBLIC.CATEGORY_DETAIL(slug)), className: "inline-flex items-center rounded-full border border-[var(--appkit-color-border)] bg-[var(--appkit-color-surface)] px-[var(--appkit-space-2-5)] py-[var(--appkit-space-1)] text-[length:var(--appkit-text-xs)] font-medium text-[var(--appkit-color-text-muted)] transition-colors hover:border-primary-300 hover:bg-primary-surface hover:text-primary-700 dark:hover:border-primary-700/60 dark:hover:text-primary-400", children: categoryNames[i] ?? slug }, slug))), subcategory && (_jsx(Span, { layout: "inline-flex", size: "xs", weight: "medium", border: "subtle", rounded: "full", padding: "pill-sm-tall", surface: "muted", color: "muted", transform: "capitalize", children: subcategory })), brand && brandSlug && (_jsx(Link, { href: String(ROUTES.PUBLIC.BRAND_DETAIL(brandSlug)), className: "inline-flex items-center rounded-full border border-[var(--appkit-color-border)] bg-[var(--appkit-color-surface)] px-[var(--appkit-space-2-5)] py-[var(--appkit-space-1)] text-[length:var(--appkit-text-xs)] font-medium text-[var(--appkit-color-text-muted)] transition-colors hover:border-primary-300 hover:bg-primary-surface hover:text-primary-700 dark:hover:border-primary-700/60 dark:hover:text-primary-400", children: brand })), brand && !brandSlug && (_jsx(Span, { layout: "inline-flex", size: "xs", weight: "medium", border: "subtle", rounded: "full", padding: "pill-sm-tall", surface: "muted", color: "muted", children: brand }))] })), bundleMemberships.length > 0 && (_jsx(Row, { gap: "sm", wrap: true, children: bundleMemberships.map((b) => (_jsxs(Link, { href: String(ROUTES.PUBLIC.BUNDLE_DETAIL(b.id)), className: CLS_BUNDLE_PILL, children: [_jsx(Span, { "aria-hidden": "true", children: "\uD83D\uDCE6" }), "In bundle: ", b.title] }, b.id))) })), _jsx(ProductFeatureBadges, { featured: featured, freeShipping: freeShipping, codAvailable: codEnabled === true, codHref: String(ROUTES.PUBLIC.HOW_CHECKOUT_WORKS), emiAvailable: emiEnabled === true, emiHref: String(ROUTES.PUBLIC.HOW_EMI_WORKS), condition: condition ?? undefined, returnable: !finalSale, finalSale: finalSale, labels: {
389
+ : ""] })), (categorySlugs.length > 0 || subcategory || brand) && (_jsxs(Row, { gap: "sm", wrap: true, children: [categorySlugs.map((slug, i) => (_jsx(Link, { href: String(ROUTES.PUBLIC.CATEGORY_DETAIL(slug)), className: "inline-flex items-center rounded-full border border-[var(--appkit-color-border)] bg-[var(--appkit-color-surface)] px-[var(--appkit-space-2-5)] py-[var(--appkit-space-1)] text-[length:var(--appkit-text-xs)] font-medium text-[var(--appkit-color-text-muted)] transition-colors hover:border-primary-300 hover:bg-primary-surface hover:text-primary-700 dark:hover:border-primary-700/60 dark:hover:text-primary-400", children: categoryNames[i] ?? slug }, slug))), subcategory && (_jsx(Span, { layout: "inline-flex", size: "xs", weight: "medium", border: "subtle", rounded: "full", padding: "pill-sm-tall", surface: "muted", color: "muted", transform: "capitalize", children: subcategory })), brand && brandSlug && (_jsx(Link, { href: String(ROUTES.PUBLIC.BRAND_DETAIL(brandSlug)), className: "inline-flex items-center rounded-full border border-[var(--appkit-color-border)] bg-[var(--appkit-color-surface)] px-[var(--appkit-space-2-5)] py-[var(--appkit-space-1)] text-[length:var(--appkit-text-xs)] font-medium text-[var(--appkit-color-text-muted)] transition-colors hover:border-primary-300 hover:bg-primary-surface hover:text-primary-700 dark:hover:border-primary-700/60 dark:hover:text-primary-400", children: brand })), brand && !brandSlug && (_jsx(Span, { layout: "inline-flex", size: "xs", weight: "medium", border: "subtle", rounded: "full", padding: "pill-sm-tall", surface: "muted", color: "muted", children: brand }))] })), bundleMemberships.length > 0 && (_jsx(Row, { gap: "sm", wrap: true, children: bundleMemberships.map((b) => (_jsxs(Link, { href: String(ROUTES.PUBLIC.BUNDLE_DETAIL(b.id)), className: CLS_BUNDLE_PILL, children: [_jsx(Span, { "aria-hidden": "true", children: "\uD83D\uDCE6" }), "In bundle: ", b.title] }, b.id))) })), _jsx(ProductFeatureBadges, { featured: featured, freeShipping: freeShipping, codAvailable: codEnabled === true, codHref: String(ROUTES.PUBLIC.HOW_CHECKOUT_WORKS), emiAvailable: emiEnabled === true, emiHref: String(ROUTES.PUBLIC.HOW_EMI_WORKS), condition: condition ?? undefined, returnable: !finalSale && returnsEnabled, finalSale: finalSale, labels: {
390
390
  featured: "Featured",
391
391
  fasterDelivery: "Faster Delivery",
392
392
  ratedSeller: "Rated Seller",
@@ -28,7 +28,7 @@ export declare const productFeatureAdminCreateSchema: z.ZodObject<{
28
28
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
29
29
  isActive: boolean;
30
30
  displayOrder: number;
31
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
31
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
32
32
  storeId?: string | undefined;
33
33
  description?: string | undefined;
34
34
  iconColor?: string | undefined;
@@ -39,7 +39,7 @@ export declare const productFeatureAdminCreateSchema: z.ZodObject<{
39
39
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
40
40
  isActive: boolean;
41
41
  displayOrder: number;
42
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
42
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
43
43
  storeId?: string | undefined;
44
44
  description?: string | undefined;
45
45
  iconColor?: string | undefined;
@@ -60,7 +60,7 @@ export declare const productFeatureStoreCreateSchema: z.ZodObject<{
60
60
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
61
61
  isActive: boolean;
62
62
  displayOrder: number;
63
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
63
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
64
64
  description?: string | undefined;
65
65
  iconColor?: string | undefined;
66
66
  }, {
@@ -69,7 +69,7 @@ export declare const productFeatureStoreCreateSchema: z.ZodObject<{
69
69
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
70
70
  isActive: boolean;
71
71
  displayOrder: number;
72
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
72
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
73
73
  description?: string | undefined;
74
74
  iconColor?: string | undefined;
75
75
  }>;
@@ -91,7 +91,7 @@ export declare const productFeatureUpdateSchema: z.ZodObject<{
91
91
  isActive?: boolean | undefined;
92
92
  displayOrder?: number | undefined;
93
93
  iconColor?: string | undefined;
94
- productTypes?: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[] | undefined;
94
+ productTypes?: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[] | undefined;
95
95
  }, {
96
96
  label?: string | undefined;
97
97
  icon?: string | undefined;
@@ -100,7 +100,7 @@ export declare const productFeatureUpdateSchema: z.ZodObject<{
100
100
  isActive?: boolean | undefined;
101
101
  displayOrder?: number | undefined;
102
102
  iconColor?: string | undefined;
103
- productTypes?: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[] | undefined;
103
+ productTypes?: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[] | undefined;
104
104
  }>;
105
105
  /**
106
106
  * The FORM schema for the product-feature editor, with UI metadata.
@@ -136,7 +136,7 @@ export declare const productFeatureFormSchema: z.ZodEffects<z.ZodObject<{
136
136
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
137
137
  isActive: boolean;
138
138
  displayOrder: number;
139
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
139
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
140
140
  storeId?: string | undefined;
141
141
  description?: string | undefined;
142
142
  iconColor?: string | undefined;
@@ -147,7 +147,7 @@ export declare const productFeatureFormSchema: z.ZodEffects<z.ZodObject<{
147
147
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
148
148
  isActive: boolean;
149
149
  displayOrder: number;
150
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
150
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
151
151
  storeId?: string | undefined;
152
152
  description?: string | undefined;
153
153
  iconColor?: string | undefined;
@@ -158,7 +158,7 @@ export declare const productFeatureFormSchema: z.ZodEffects<z.ZodObject<{
158
158
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
159
159
  isActive: boolean;
160
160
  displayOrder: number;
161
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
161
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
162
162
  storeId?: string | undefined;
163
163
  description?: string | undefined;
164
164
  iconColor?: string | undefined;
@@ -169,7 +169,7 @@ export declare const productFeatureFormSchema: z.ZodEffects<z.ZodObject<{
169
169
  category: "shipping" | "seller" | "custom" | "condition" | "auction" | "platform" | "preorder";
170
170
  isActive: boolean;
171
171
  displayOrder: number;
172
- productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "product" | "preorder")[];
172
+ productTypes: ("all" | "classified" | "auction" | "prize-draw" | "digital-code" | "live" | "preorder" | "product")[];
173
173
  storeId?: string | undefined;
174
174
  description?: string | undefined;
175
175
  iconColor?: string | undefined;
@@ -4,21 +4,48 @@
4
4
  * A cart may hold at most one seller-scoped coupon per store, plus at most
5
5
  * one admin (platform-wide) coupon on top. Both scopes stack with each
6
6
  * other freely — the old `combineWithSellerCoupons` opt-out was removed
7
- * (2026-08-21): stacking is now unconditional as long as the two "buckets"
8
- * (per-store, and the single platform-wide slot) don't collide.
7
+ * (2026-08-21): stacking is now unconditional as long as the buckets
8
+ * (per-store, the single platform-wide slot, and the points-earn slot) don't
9
+ * collide.
10
+ *
11
+ * ## 🛑 THREE buckets since 2026-10-22, and the third is not a nicety (D51)
12
+ *
13
+ * `RIPLI05` is a PERMANENT, site-wide, undeletable coupon that awards points
14
+ * rather than discounting. With only the admin bucket it would occupy the one
15
+ * platform-wide slot forever, and **every other platform coupon would be
16
+ * unusable for as long as the points programme existed** — a seasonal sale
17
+ * coupon could never be applied by anyone.
18
+ *
19
+ * The spec also requires it to stack with a discount coupon, because it awards
20
+ * a percentage of the POST-discount amount paid. A design where the two cannot
21
+ * coexist cannot implement that sentence at all.
22
+ *
23
+ * So the bucket is keyed on the coupon's TYPE, not its scope: a `points_earn`
24
+ * coupon is admin-scoped like any platform coupon, and it is the type that
25
+ * decides which slot it competes for.
9
26
  *
10
27
  * Pure function, no I/O — safe to call from both the cart-apply route and
11
28
  * the checkout re-validation pass.
12
29
  */
13
30
  import type { CartAppliedCoupon } from "../../cart/schemas/firestore";
31
+ import type { CouponType } from "../types";
14
32
  export interface IncomingCoupon {
15
33
  code: string;
16
34
  scope: "admin" | "seller";
17
35
  storeId?: string;
36
+ /**
37
+ * The coupon's type, which decides its bucket (D51).
38
+ *
39
+ * Optional, and absence means "a discount coupon" — every cart written
40
+ * before `points_earn` existed carries no type on its applied-coupon
41
+ * entries, and treating those as discount coupons is both correct and what
42
+ * preserves the previous behaviour exactly.
43
+ */
44
+ type?: CouponType;
18
45
  }
19
46
  /**
20
47
  * Returns a human-readable conflict message, or null when `incoming` can be
21
48
  * added alongside `existing` without violating the one-per-store +
22
- * one-global rule.
49
+ * one-global + one-points-earn rule.
23
50
  */
24
51
  export declare function detectCouponConflict(existing: CartAppliedCoupon[], incoming: IncomingCoupon): string | null;
@@ -1,9 +1,14 @@
1
+ /** A points-earn coupon competes for its own slot, never the admin one. */
2
+ function isPointsEarn(coupon) {
3
+ return coupon.type === "points_earn";
4
+ }
1
5
  /**
2
6
  * Returns a human-readable conflict message, or null when `incoming` can be
3
7
  * added alongside `existing` without violating the one-per-store +
4
- * one-global rule.
8
+ * one-global + one-points-earn rule.
5
9
  */
6
10
  export function detectCouponConflict(existing, incoming) {
11
+ const incomingIsPoints = isPointsEarn(incoming);
7
12
  for (const applied of existing) {
8
13
  if (applied.code === incoming.code) {
9
14
  return `Coupon ${incoming.code} is already applied.`;
@@ -13,7 +18,21 @@ export function detectCouponConflict(existing, incoming) {
13
18
  applied.storeId === incoming.storeId) {
14
19
  return `A coupon for this store is already applied (${applied.code}). Remove it first.`;
15
20
  }
16
- if (incoming.scope === "admin" && applied.scope === "admin") {
21
+ const appliedIsPoints = isPointsEarn(applied);
22
+ /*
23
+ * 🛑 The two admin-scoped buckets are checked SEPARATELY, and the order of
24
+ * these two branches does not matter precisely because each requires both
25
+ * sides to be in the same bucket. An earlier shape — testing scope first
26
+ * and type second — would have let a points coupon collide with a discount
27
+ * coupon, which is the whole defect.
28
+ */
29
+ if (incomingIsPoints && appliedIsPoints) {
30
+ return `A points offer is already applied (${applied.code}). Remove it first.`;
31
+ }
32
+ if (!incomingIsPoints &&
33
+ !appliedIsPoints &&
34
+ incoming.scope === "admin" &&
35
+ applied.scope === "admin") {
17
36
  return `Only one platform-wide coupon can be applied at a time (${applied.code}). Remove it first.`;
18
37
  }
19
38
  }
@@ -13,6 +13,19 @@ const TYPE_COLORS = {
13
13
  fixed: { card: "bg-success-surface border-success dark:bg-success-surface dark:border-success", code: "bg-success-surface dark:bg-success-surface text-success dark:text-success border-success dark:border-success" },
14
14
  free_shipping: { card: "bg-info-surface border-info dark:bg-info-surface dark:border-info", code: "bg-info-surface dark:bg-info-surface text-info dark:text-info border-info dark:border-info" },
15
15
  buy_x_get_y: { card: "bg-warning-surface border-warning dark:bg-warning-surface dark:border-warning", code: "bg-warning-surface dark:bg-warning-surface text-warning dark:text-warning border-warning dark:border-warning" },
16
+ /*
17
+ * D51. A `Record<CouponType, …>`, so this entry is a COMPILE requirement
18
+ * rather than a nicety — which is the reason the union was widened first.
19
+ *
20
+ * 🛑 `-surface` + the matching status ink, never a literal `text-white`.
21
+ * A past sweep paired `bg-{status}-surface` with `text-white` on 26
22
+ * surfaces, and since `-surface` is a near-white tint in light themes and a
23
+ * dark tint in dark ones, every one of them was invisible in exactly one
24
+ * theme (Root Cause #67). `primary` rather than a status colour because
25
+ * earning points is neither a warning nor an error — it is the brand's own
26
+ * offer.
27
+ */
28
+ points_earn: { card: "bg-primary-surface border-primary dark:bg-primary-surface dark:border-primary", code: "bg-primary-surface dark:bg-primary-surface text-primary dark:text-primary border-primary dark:border-primary" },
16
29
  };
17
30
  function pick(obj, ...keys) {
18
31
  for (const k of keys) {
@@ -15,10 +15,10 @@ export declare const COUPON_HELP: {
15
15
  readonly title: "How coupons work";
16
16
  /** The stacking rules — the part buyers most often get wrong. */
17
17
  readonly stackingHeading: "You can use more than one coupon";
18
- readonly stackingRules: readonly ["One store coupon per store. If your cart has items from three stores, you can apply each of those stores' coupons at the same time.", "Plus one platform-wide LetItRip coupon, on top of any store coupons.", "A second coupon for the same store, or a second platform-wide coupon, will be declined — remove the first one to swap it."];
18
+ readonly stackingRules: readonly ["One store coupon per store. If your cart has items from three stores, you can apply each of those stores' coupons at the same time.", "Plus one platform-wide LetItRip coupon, on top of any store coupons.", "Plus one points offer, which stacks with everything else — it earns you points rather than discounting, so it never takes the place of a discount coupon.", "A second coupon for the same store, a second platform-wide coupon, or a second points offer will be declined — remove the first one to swap it."];
19
19
  /** How the discount is actually distributed. */
20
20
  readonly applicationHeading: "Where each discount lands";
21
- readonly applicationRules: readonly ["A store coupon only discounts that store's items.", "A platform-wide coupon is spread proportionally across every store in your cart.", "Orders are placed per store, so each store's order shows its own share of the discount."];
21
+ readonly applicationRules: readonly ["A store coupon only discounts that store's items.", "A platform-wide coupon is spread proportionally across every store in your cart.", "Orders are placed per store, so each store's order shows its own share of the discount.", "A points offer earns points on what you pay after any discounts, so the two interact rather than ignoring each other."];
22
22
  /** Reuses the failure reasons already written for the buyer shopping guide. */
23
23
  readonly failureHeading: "Why a coupon might not apply";
24
24
  readonly failureReasons: readonly ["The eligible items in your cart are below the coupon's minimum purchase amount — minimum spend is measured against the items the coupon actually covers, not your whole cart.", "The coupon has expired, or hasn't started yet.", "The coupon is limited to certain products or categories, and your cart has none of them.", "The coupon is first-order-only and you've ordered before.", "You've already used the coupon the maximum number of times allowed.", "The coupon ran out — some coupons have a total limit across all buyers."];