@pradip1995/create-storefront 1.0.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 (338) hide show
  1. package/bin/create-storefront.js +239 -0
  2. package/lib/kit-next-config.js +84 -0
  3. package/package.json +32 -0
  4. package/templates/storefront/.eslintrc.json +3 -0
  5. package/templates/storefront/README.md +35 -0
  6. package/templates/storefront/check-env-variables.js +51 -0
  7. package/templates/storefront/kit-next-config.js +71 -0
  8. package/templates/storefront/next-env.d.ts +5 -0
  9. package/templates/storefront/next.config.js +25 -0
  10. package/templates/storefront/package.json +56 -0
  11. package/templates/storefront/postcss.config.js +6 -0
  12. package/templates/storefront/public/favicon.png +0 -0
  13. package/templates/storefront/src/app/[countryCode]/(checkout)/checkout/page.tsx +23 -0
  14. package/templates/storefront/src/app/[countryCode]/(checkout)/checkout/payment/page.tsx +47 -0
  15. package/templates/storefront/src/app/[countryCode]/(checkout)/layout.tsx +31 -0
  16. package/templates/storefront/src/app/[countryCode]/(checkout)/not-found.tsx +19 -0
  17. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/addresses/page.tsx +31 -0
  18. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/loading.tsx +9 -0
  19. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/orders/details/[id]/page.tsx +35 -0
  20. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/orders/exchange/[id]/page.tsx +47 -0
  21. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/orders/page.tsx +28 -0
  22. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/orders/return/[id]/page.tsx +66 -0
  23. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/page.tsx +22 -0
  24. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/payment-methods/page.tsx +23 -0
  25. package/templates/storefront/src/app/[countryCode]/(main)/account/@dashboard/profile/page.tsx +43 -0
  26. package/templates/storefront/src/app/[countryCode]/(main)/account/@login/default.tsx +11 -0
  27. package/templates/storefront/src/app/[countryCode]/(main)/account/@login/page.tsx +18 -0
  28. package/templates/storefront/src/app/[countryCode]/(main)/account/guest-orders/page.tsx +13 -0
  29. package/templates/storefront/src/app/[countryCode]/(main)/account/layout.tsx +22 -0
  30. package/templates/storefront/src/app/[countryCode]/(main)/account/loading.tsx +9 -0
  31. package/templates/storefront/src/app/[countryCode]/(main)/cart/loading.tsx +5 -0
  32. package/templates/storefront/src/app/[countryCode]/(main)/cart/not-found.tsx +21 -0
  33. package/templates/storefront/src/app/[countryCode]/(main)/cart/page.tsx +23 -0
  34. package/templates/storefront/src/app/[countryCode]/(main)/categories/[...category]/page.tsx +11 -0
  35. package/templates/storefront/src/app/[countryCode]/(main)/collections/[handle]/page.tsx +11 -0
  36. package/templates/storefront/src/app/[countryCode]/(main)/contact/page.tsx +21 -0
  37. package/templates/storefront/src/app/[countryCode]/(main)/guest-orders/page.tsx +12 -0
  38. package/templates/storefront/src/app/[countryCode]/(main)/help/page.tsx +28 -0
  39. package/templates/storefront/src/app/[countryCode]/(main)/layout.tsx +21 -0
  40. package/templates/storefront/src/app/[countryCode]/(main)/not-found.tsx +20 -0
  41. package/templates/storefront/src/app/[countryCode]/(main)/order/[id]/confirmed/loading.tsx +5 -0
  42. package/templates/storefront/src/app/[countryCode]/(main)/order/[id]/confirmed/page.tsx +23 -0
  43. package/templates/storefront/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/accept/page.tsx +41 -0
  44. package/templates/storefront/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/decline/page.tsx +41 -0
  45. package/templates/storefront/src/app/[countryCode]/(main)/order/[id]/transfer/[token]/page.tsx +38 -0
  46. package/templates/storefront/src/app/[countryCode]/(main)/order/exchange/[id]/page.tsx +47 -0
  47. package/templates/storefront/src/app/[countryCode]/(main)/order/return/[id]/page.tsx +61 -0
  48. package/templates/storefront/src/app/[countryCode]/(main)/orders/[id]/page.tsx +33 -0
  49. package/templates/storefront/src/app/[countryCode]/(main)/page.tsx +24 -0
  50. package/templates/storefront/src/app/[countryCode]/(main)/privacy-policy/page.tsx +173 -0
  51. package/templates/storefront/src/app/[countryCode]/(main)/products/[handle]/page.tsx +193 -0
  52. package/templates/storefront/src/app/[countryCode]/(main)/reset-password/page.tsx +192 -0
  53. package/templates/storefront/src/app/[countryCode]/(main)/store/page.tsx +72 -0
  54. package/templates/storefront/src/app/[countryCode]/(main)/terms-of-use/page.tsx +179 -0
  55. package/templates/storefront/src/app/[countryCode]/(main)/wishlist/page.tsx +19 -0
  56. package/templates/storefront/src/app/api/meta/event/route.ts +63 -0
  57. package/templates/storefront/src/app/auth/customer/google/callback/page.tsx +126 -0
  58. package/templates/storefront/src/app/layout.tsx +104 -0
  59. package/templates/storefront/src/app/not-found.tsx +30 -0
  60. package/templates/storefront/src/app/opengraph-image.jpg +0 -0
  61. package/templates/storefront/src/app/robots.ts +15 -0
  62. package/templates/storefront/src/app/sitemap.ts +65 -0
  63. package/templates/storefront/src/app/twitter-image.jpg +0 -0
  64. package/templates/storefront/src/modules/account/components/account-deletion/index.tsx +160 -0
  65. package/templates/storefront/src/modules/account/components/account-info/index.tsx +145 -0
  66. package/templates/storefront/src/modules/account/components/account-nav/icons.tsx +43 -0
  67. package/templates/storefront/src/modules/account/components/account-nav/index.tsx +318 -0
  68. package/templates/storefront/src/modules/account/components/account-nav/logout-modal.tsx +92 -0
  69. package/templates/storefront/src/modules/account/components/account-nav/payment-methods-icon.tsx +9 -0
  70. package/templates/storefront/src/modules/account/components/address-book/index.tsx +47 -0
  71. package/templates/storefront/src/modules/account/components/address-card/add-address.tsx +377 -0
  72. package/templates/storefront/src/modules/account/components/address-card/edit-address-modal.tsx +468 -0
  73. package/templates/storefront/src/modules/account/components/deletion-pending-modal/index.tsx +213 -0
  74. package/templates/storefront/src/modules/account/components/forgot-password/index.tsx +1 -0
  75. package/templates/storefront/src/modules/account/components/login/index.tsx +1 -0
  76. package/templates/storefront/src/modules/account/components/order-card/index.tsx +221 -0
  77. package/templates/storefront/src/modules/account/components/order-overview/index.tsx +159 -0
  78. package/templates/storefront/src/modules/account/components/overview/index.tsx +189 -0
  79. package/templates/storefront/src/modules/account/components/profile-billing-address/index.tsx +447 -0
  80. package/templates/storefront/src/modules/account/components/profile-email/index.tsx +75 -0
  81. package/templates/storefront/src/modules/account/components/profile-form/index.tsx +416 -0
  82. package/templates/storefront/src/modules/account/components/profile-name/index.tsx +76 -0
  83. package/templates/storefront/src/modules/account/components/profile-password/index.tsx +70 -0
  84. package/templates/storefront/src/modules/account/components/profile-phone/index.tsx +185 -0
  85. package/templates/storefront/src/modules/account/components/register/index.tsx +1 -0
  86. package/templates/storefront/src/modules/account/components/return-item-selector/index.tsx +187 -0
  87. package/templates/storefront/src/modules/account/components/return-shipping-selector/index.tsx +118 -0
  88. package/templates/storefront/src/modules/account/components/transfer-request-form/index.tsx +81 -0
  89. package/templates/storefront/src/modules/account/templates/account-layout.tsx +38 -0
  90. package/templates/storefront/src/modules/account/templates/exchange-request-template.tsx +389 -0
  91. package/templates/storefront/src/modules/account/templates/guest-orders-template.tsx +123 -0
  92. package/templates/storefront/src/modules/account/templates/login-template.tsx +44 -0
  93. package/templates/storefront/src/modules/account/templates/payment-methods-template.tsx +478 -0
  94. package/templates/storefront/src/modules/account/templates/return-request-template.tsx +300 -0
  95. package/templates/storefront/src/modules/cart/components/abandoned-carts/ScrollToPendingOrdersButton.tsx +21 -0
  96. package/templates/storefront/src/modules/cart/components/abandoned-carts/index.tsx +335 -0
  97. package/templates/storefront/src/modules/cart/components/applied-promotions/index.tsx +121 -0
  98. package/templates/storefront/src/modules/cart/components/cart-delivery-selection/index.tsx +203 -0
  99. package/templates/storefront/src/modules/cart/components/cart-item-card/index.tsx +476 -0
  100. package/templates/storefront/src/modules/cart/components/cart-item-select/index.tsx +73 -0
  101. package/templates/storefront/src/modules/cart/components/cart-view-tracker/index.tsx +44 -0
  102. package/templates/storefront/src/modules/cart/components/delivery-information/index.tsx +89 -0
  103. package/templates/storefront/src/modules/cart/components/empty-cart-message/index.tsx +38 -0
  104. package/templates/storefront/src/modules/cart/components/item/index.tsx +150 -0
  105. package/templates/storefront/src/modules/cart/components/pincode-checker/index.tsx +174 -0
  106. package/templates/storefront/src/modules/cart/components/sign-in-prompt/index.tsx +26 -0
  107. package/templates/storefront/src/modules/cart/components/you-may-also-like/index.tsx +137 -0
  108. package/templates/storefront/src/modules/cart/templates/index.tsx +88 -0
  109. package/templates/storefront/src/modules/cart/templates/items.tsx +49 -0
  110. package/templates/storefront/src/modules/cart/templates/preview.tsx +51 -0
  111. package/templates/storefront/src/modules/cart/templates/summary.tsx +29 -0
  112. package/templates/storefront/src/modules/checkout/components/add-address-modal/index.tsx +390 -0
  113. package/templates/storefront/src/modules/checkout/components/address-card/index.tsx +135 -0
  114. package/templates/storefront/src/modules/checkout/components/address-select/index.tsx +116 -0
  115. package/templates/storefront/src/modules/checkout/components/addresses/index.tsx +605 -0
  116. package/templates/storefront/src/modules/checkout/components/back-link/index.tsx +32 -0
  117. package/templates/storefront/src/modules/checkout/components/billing_address/index.tsx +301 -0
  118. package/templates/storefront/src/modules/checkout/components/checkout-begin-tracker/index.tsx +45 -0
  119. package/templates/storefront/src/modules/checkout/components/checkout-leave-guard/index.tsx +109 -0
  120. package/templates/storefront/src/modules/checkout/components/checkout-shipping-tracker/index.tsx +45 -0
  121. package/templates/storefront/src/modules/checkout/components/country-select/index.tsx +50 -0
  122. package/templates/storefront/src/modules/checkout/components/discount-code/index.tsx +220 -0
  123. package/templates/storefront/src/modules/checkout/components/error-message/index.tsx +13 -0
  124. package/templates/storefront/src/modules/checkout/components/payment/index.tsx +572 -0
  125. package/templates/storefront/src/modules/checkout/components/payment-button/index.tsx +257 -0
  126. package/templates/storefront/src/modules/checkout/components/payment-button/razorpay-payment-button.tsx +136 -0
  127. package/templates/storefront/src/modules/checkout/components/payment-container/index.tsx +129 -0
  128. package/templates/storefront/src/modules/checkout/components/payment-test/index.tsx +12 -0
  129. package/templates/storefront/src/modules/checkout/components/payment-wrapper/index.tsx +50 -0
  130. package/templates/storefront/src/modules/checkout/components/payment-wrapper/stripe-wrapper.tsx +54 -0
  131. package/templates/storefront/src/modules/checkout/components/processing-overlay/index.tsx +83 -0
  132. package/templates/storefront/src/modules/checkout/components/review/index.tsx +60 -0
  133. package/templates/storefront/src/modules/checkout/components/select-address-modal/index.tsx +103 -0
  134. package/templates/storefront/src/modules/checkout/components/shipping/index.tsx +533 -0
  135. package/templates/storefront/src/modules/checkout/components/shipping-address/index.tsx +521 -0
  136. package/templates/storefront/src/modules/checkout/components/submit-button/index.tsx +32 -0
  137. package/templates/storefront/src/modules/checkout/templates/checkout-form/index.tsx +38 -0
  138. package/templates/storefront/src/modules/checkout/templates/checkout-summary/index.tsx +274 -0
  139. package/templates/storefront/src/modules/common/components/breadcrumb/index.tsx +43 -0
  140. package/templates/storefront/src/modules/common/components/cart-totals/index.tsx +473 -0
  141. package/templates/storefront/src/modules/common/components/checkbox/index.tsx +98 -0
  142. package/templates/storefront/src/modules/common/components/delete-button/index.tsx +156 -0
  143. package/templates/storefront/src/modules/common/components/divider/index.tsx +9 -0
  144. package/templates/storefront/src/modules/common/components/filter-checkbox-group/index.tsx +134 -0
  145. package/templates/storefront/src/modules/common/components/filter-radio-group/index.tsx +62 -0
  146. package/templates/storefront/src/modules/common/components/input/index.tsx +79 -0
  147. package/templates/storefront/src/modules/common/components/interactive-link/index.tsx +33 -0
  148. package/templates/storefront/src/modules/common/components/line-item-options/index.tsx +26 -0
  149. package/templates/storefront/src/modules/common/components/line-item-price/index.tsx +64 -0
  150. package/templates/storefront/src/modules/common/components/line-item-unit-price/index.tsx +61 -0
  151. package/templates/storefront/src/modules/common/components/localized-client-link/index.tsx +32 -0
  152. package/templates/storefront/src/modules/common/components/login-popup/index.tsx +78 -0
  153. package/templates/storefront/src/modules/common/components/modal/index.tsx +123 -0
  154. package/templates/storefront/src/modules/common/components/native-select/index.tsx +75 -0
  155. package/templates/storefront/src/modules/common/components/obfuscated-email/index.tsx +30 -0
  156. package/templates/storefront/src/modules/common/components/product/product-rating/index.tsx +172 -0
  157. package/templates/storefront/src/modules/common/components/product/review-modal/index.tsx +333 -0
  158. package/templates/storefront/src/modules/common/components/product/share-button/index.tsx +227 -0
  159. package/templates/storefront/src/modules/common/components/product/wishlist-icon/index.tsx +46 -0
  160. package/templates/storefront/src/modules/common/components/radio/index.tsx +27 -0
  161. package/templates/storefront/src/modules/common/components/select/index.tsx +164 -0
  162. package/templates/storefront/src/modules/common/components/side-panel/index.tsx +65 -0
  163. package/templates/storefront/src/modules/common/icons/arrow-left.tsx +36 -0
  164. package/templates/storefront/src/modules/common/icons/back.tsx +37 -0
  165. package/templates/storefront/src/modules/common/icons/bancontact.tsx +26 -0
  166. package/templates/storefront/src/modules/common/icons/chevron-down.tsx +30 -0
  167. package/templates/storefront/src/modules/common/icons/delivered.tsx +29 -0
  168. package/templates/storefront/src/modules/common/icons/envelope.tsx +27 -0
  169. package/templates/storefront/src/modules/common/icons/eye-off.tsx +37 -0
  170. package/templates/storefront/src/modules/common/icons/eye.tsx +37 -0
  171. package/templates/storefront/src/modules/common/icons/fast-delivery.tsx +65 -0
  172. package/templates/storefront/src/modules/common/icons/ideal.tsx +26 -0
  173. package/templates/storefront/src/modules/common/icons/lock.tsx +31 -0
  174. package/templates/storefront/src/modules/common/icons/map-pin.tsx +37 -0
  175. package/templates/storefront/src/modules/common/icons/medusa.tsx +27 -0
  176. package/templates/storefront/src/modules/common/icons/menu.tsx +45 -0
  177. package/templates/storefront/src/modules/common/icons/nextjs.tsx +27 -0
  178. package/templates/storefront/src/modules/common/icons/package.tsx +44 -0
  179. package/templates/storefront/src/modules/common/icons/paypal.tsx +30 -0
  180. package/templates/storefront/src/modules/common/icons/phone.tsx +30 -0
  181. package/templates/storefront/src/modules/common/icons/placeholder-image.tsx +44 -0
  182. package/templates/storefront/src/modules/common/icons/refresh.tsx +51 -0
  183. package/templates/storefront/src/modules/common/icons/spinner.tsx +37 -0
  184. package/templates/storefront/src/modules/common/icons/trash.tsx +51 -0
  185. package/templates/storefront/src/modules/common/icons/user.tsx +37 -0
  186. package/templates/storefront/src/modules/common/icons/x.tsx +37 -0
  187. package/templates/storefront/src/modules/contact/templates/index.tsx +272 -0
  188. package/templates/storefront/src/modules/help/templates/index.tsx +629 -0
  189. package/templates/storefront/src/modules/home/components/dynamic-banner/index.tsx +190 -0
  190. package/templates/storefront/src/modules/home/components/featured-products/index.tsx +16 -0
  191. package/templates/storefront/src/modules/home/components/featured-products/product-rail/index.tsx +51 -0
  192. package/templates/storefront/src/modules/home/components/features/index.tsx +1 -0
  193. package/templates/storefront/src/modules/home/components/hero/index.tsx +1 -0
  194. package/templates/storefront/src/modules/home/components/loved-by-moms/index.tsx +1 -0
  195. package/templates/storefront/src/modules/home/components/new-arrivals/index.tsx +1 -0
  196. package/templates/storefront/src/modules/home/components/shop-by-age/index.tsx +1 -0
  197. package/templates/storefront/src/modules/home/components/shop-by-category/index.tsx +1 -0
  198. package/templates/storefront/src/modules/home/components/testimonials/index.tsx +1 -0
  199. package/templates/storefront/src/modules/home/components/why-choose-us/dynamic-features.tsx +93 -0
  200. package/templates/storefront/src/modules/home/components/why-choose-us/index.tsx +1 -0
  201. package/templates/storefront/src/modules/layout/components/account-dropdown/index.tsx +56 -0
  202. package/templates/storefront/src/modules/layout/components/cart-button/index.tsx +8 -0
  203. package/templates/storefront/src/modules/layout/components/cart-dropdown/index.tsx +424 -0
  204. package/templates/storefront/src/modules/layout/components/cart-mismatch-banner/index.tsx +57 -0
  205. package/templates/storefront/src/modules/layout/components/cookie-consent/index.tsx +116 -0
  206. package/templates/storefront/src/modules/layout/components/country-select/index.tsx +135 -0
  207. package/templates/storefront/src/modules/layout/components/desktop-search/index.tsx +148 -0
  208. package/templates/storefront/src/modules/layout/components/dynamic-logo/index.tsx +27 -0
  209. package/templates/storefront/src/modules/layout/components/footer-categories/index.tsx +34 -0
  210. package/templates/storefront/src/modules/layout/components/footer-contact/index.tsx +87 -0
  211. package/templates/storefront/src/modules/layout/components/footer-description/index.tsx +12 -0
  212. package/templates/storefront/src/modules/layout/components/footer-logo/index.tsx +22 -0
  213. package/templates/storefront/src/modules/layout/components/footer-newsletter/index.tsx +100 -0
  214. package/templates/storefront/src/modules/layout/components/language-select/index.tsx +192 -0
  215. package/templates/storefront/src/modules/layout/components/medusa-cta/index.tsx +21 -0
  216. package/templates/storefront/src/modules/layout/components/mobile-menu/index.tsx +296 -0
  217. package/templates/storefront/src/modules/layout/components/nav-links/index.tsx +66 -0
  218. package/templates/storefront/src/modules/layout/components/nav-wrapper/index.tsx +14 -0
  219. package/templates/storefront/src/modules/layout/components/promo-bar/index.tsx +7 -0
  220. package/templates/storefront/src/modules/layout/components/promo-bar/promo-bar-content.tsx +174 -0
  221. package/templates/storefront/src/modules/layout/components/push-notification-manager/index.tsx +191 -0
  222. package/templates/storefront/src/modules/layout/components/search-panel/index.tsx +136 -0
  223. package/templates/storefront/src/modules/layout/components/side-menu/index.tsx +144 -0
  224. package/templates/storefront/src/modules/layout/components/verification-banner/index.tsx +217 -0
  225. package/templates/storefront/src/modules/layout/components/wishlist-counter/index.tsx +17 -0
  226. package/templates/storefront/src/modules/layout/templates/footer/index.tsx +7 -0
  227. package/templates/storefront/src/modules/layout/templates/nav/index.tsx +14 -0
  228. package/templates/storefront/src/modules/order/components/cancel-order-modal/index.tsx +168 -0
  229. package/templates/storefront/src/modules/order/components/help/index.tsx +25 -0
  230. package/templates/storefront/src/modules/order/components/item/index.tsx +62 -0
  231. package/templates/storefront/src/modules/order/components/items/index.tsx +44 -0
  232. package/templates/storefront/src/modules/order/components/onboarding-cta/index.tsx +28 -0
  233. package/templates/storefront/src/modules/order/components/order-confirmation-back-handler/index.tsx +28 -0
  234. package/templates/storefront/src/modules/order/components/order-details/index.tsx +63 -0
  235. package/templates/storefront/src/modules/order/components/order-purchase-tracker/index.tsx +48 -0
  236. package/templates/storefront/src/modules/order/components/order-redesign/index.tsx +887 -0
  237. package/templates/storefront/src/modules/order/components/order-summary/index.tsx +60 -0
  238. package/templates/storefront/src/modules/order/components/payment-details/index.tsx +63 -0
  239. package/templates/storefront/src/modules/order/components/shipping-details/index.tsx +73 -0
  240. package/templates/storefront/src/modules/order/components/transfer-actions/index.tsx +81 -0
  241. package/templates/storefront/src/modules/order/components/transfer-image/index.tsx +275 -0
  242. package/templates/storefront/src/modules/order/templates/order-completed-template.tsx +233 -0
  243. package/templates/storefront/src/modules/order/templates/order-details-template.tsx +128 -0
  244. package/templates/storefront/src/modules/products/components/image-gallery/index.tsx +297 -0
  245. package/templates/storefront/src/modules/products/components/product-actions/index.tsx +1400 -0
  246. package/templates/storefront/src/modules/products/components/product-actions/mobile-actions.tsx +217 -0
  247. package/templates/storefront/src/modules/products/components/product-actions/option-select.tsx +62 -0
  248. package/templates/storefront/src/modules/products/components/product-onboarding-cta/index.tsx +30 -0
  249. package/templates/storefront/src/modules/products/components/product-preview/index.tsx +5 -0
  250. package/templates/storefront/src/modules/products/components/product-preview/price.tsx +29 -0
  251. package/templates/storefront/src/modules/products/components/product-price/index.tsx +58 -0
  252. package/templates/storefront/src/modules/products/components/product-rating/index.tsx +1 -0
  253. package/templates/storefront/src/modules/products/components/product-tabs/accordion.tsx +100 -0
  254. package/templates/storefront/src/modules/products/components/product-tabs/index.tsx +127 -0
  255. package/templates/storefront/src/modules/products/components/product-tabs/ratings-tab.tsx +598 -0
  256. package/templates/storefront/src/modules/products/components/product-view-tracker/index.tsx +53 -0
  257. package/templates/storefront/src/modules/products/components/related-products/index.tsx +152 -0
  258. package/templates/storefront/src/modules/products/components/review-modal/index.tsx +1 -0
  259. package/templates/storefront/src/modules/products/components/share-button/index.tsx +1 -0
  260. package/templates/storefront/src/modules/products/components/thumbnail/index.tsx +91 -0
  261. package/templates/storefront/src/modules/products/components/wishlist-icon/index.tsx +1 -0
  262. package/templates/storefront/src/modules/products/context/product-context.tsx +52 -0
  263. package/templates/storefront/src/modules/products/templates/index.tsx +26 -0
  264. package/templates/storefront/src/modules/products/templates/product-actions-wrapper/index.tsx +1 -0
  265. package/templates/storefront/src/modules/products/templates/product-info/index.tsx +2 -0
  266. package/templates/storefront/src/modules/shipping/components/free-shipping-price-nudge/index.tsx +283 -0
  267. package/templates/storefront/src/modules/skeletons/components/skeleton-button/index.tsx +5 -0
  268. package/templates/storefront/src/modules/skeletons/components/skeleton-card-details/index.tsx +10 -0
  269. package/templates/storefront/src/modules/skeletons/components/skeleton-cart-item/index.tsx +35 -0
  270. package/templates/storefront/src/modules/skeletons/components/skeleton-cart-totals/index.tsx +30 -0
  271. package/templates/storefront/src/modules/skeletons/components/skeleton-code-form/index.tsx +13 -0
  272. package/templates/storefront/src/modules/skeletons/components/skeleton-line-item/index.tsx +35 -0
  273. package/templates/storefront/src/modules/skeletons/components/skeleton-order-confirmed-header/index.tsx +14 -0
  274. package/templates/storefront/src/modules/skeletons/components/skeleton-order-information/index.tsx +36 -0
  275. package/templates/storefront/src/modules/skeletons/components/skeleton-order-items/index.tsx +43 -0
  276. package/templates/storefront/src/modules/skeletons/components/skeleton-order-summary/index.tsx +15 -0
  277. package/templates/storefront/src/modules/skeletons/components/skeleton-product-preview/index.tsx +15 -0
  278. package/templates/storefront/src/modules/skeletons/templates/skeleton-cart-page/index.tsx +65 -0
  279. package/templates/storefront/src/modules/skeletons/templates/skeleton-order-confirmed/index.tsx +21 -0
  280. package/templates/storefront/src/modules/skeletons/templates/skeleton-product-grid/index.tsx +23 -0
  281. package/templates/storefront/src/modules/skeletons/templates/skeleton-related-products/index.tsx +25 -0
  282. package/templates/storefront/src/modules/store/components/client-paginated-products.tsx +108 -0
  283. package/templates/storefront/src/modules/store/components/mobile-filters/index.tsx +135 -0
  284. package/templates/storefront/src/modules/store/components/pagination/index.tsx +118 -0
  285. package/templates/storefront/src/modules/store/components/product-list-view-tracker/index.tsx +43 -0
  286. package/templates/storefront/src/modules/store/components/refinement-list/index.tsx +299 -0
  287. package/templates/storefront/src/modules/store/components/refinement-list/sort-products/index.tsx +120 -0
  288. package/templates/storefront/src/modules/store/components/store-header/index.tsx +67 -0
  289. package/templates/storefront/src/modules/store/templates/index.tsx +1 -0
  290. package/templates/storefront/src/modules/store/templates/paginated-products.tsx +175 -0
  291. package/templates/storefront/src/modules/wishlist/components/wishlist-item/index.tsx +797 -0
  292. package/templates/storefront/src/modules/wishlist/templates/index.tsx +176 -0
  293. package/templates/storefront/src/storefront.config.ts +12 -0
  294. package/templates/storefront/src/styles/globals.css +326 -0
  295. package/templates/storefront/src/theme/valero/blocks/home/Features/index.tsx +61 -0
  296. package/templates/storefront/src/theme/valero/blocks/home/Hero/index.tsx +102 -0
  297. package/templates/storefront/src/theme/valero/blocks/home/LovedByMoms/index.tsx +407 -0
  298. package/templates/storefront/src/theme/valero/blocks/home/NewArrivals/index.tsx +48 -0
  299. package/templates/storefront/src/theme/valero/blocks/home/ShopByAge/index.tsx +128 -0
  300. package/templates/storefront/src/theme/valero/blocks/home/ShopByCategory/index.tsx +409 -0
  301. package/templates/storefront/src/theme/valero/blocks/home/Testimonials/index.tsx +697 -0
  302. package/templates/storefront/src/theme/valero/blocks/home/WhyChooseUs/index.tsx +62 -0
  303. package/templates/storefront/src/theme/valero/layouts/MainLayoutShell.tsx +14 -0
  304. package/templates/storefront/src/theme/valero/primitives/Button.tsx +28 -0
  305. package/templates/storefront/src/theme/valero/primitives/Card.tsx +32 -0
  306. package/templates/storefront/src/theme/valero/primitives/index.ts +2 -0
  307. package/templates/storefront/src/theme/valero/slots/account/ForgotPassword/index.tsx +1 -0
  308. package/templates/storefront/src/theme/valero/slots/account/Login/index.tsx +1 -0
  309. package/templates/storefront/src/theme/valero/slots/account/LoginTemplate/index.tsx +44 -0
  310. package/templates/storefront/src/theme/valero/slots/account/Register/index.tsx +1 -0
  311. package/templates/storefront/src/theme/valero/slots/cart/CartItem/index.tsx +11 -0
  312. package/templates/storefront/src/theme/valero/slots/cart/CartSummary/index.tsx +13 -0
  313. package/templates/storefront/src/theme/valero/slots/checkout/CheckoutForm/index.tsx +1 -0
  314. package/templates/storefront/src/theme/valero/slots/checkout/CheckoutSummary/index.tsx +1 -0
  315. package/templates/storefront/src/theme/valero/slots/layout/Footer/index.tsx +104 -0
  316. package/templates/storefront/src/theme/valero/slots/layout/Nav/index.tsx +97 -0
  317. package/templates/storefront/src/theme/valero/slots/layout/PromoBar/index.tsx +19 -0
  318. package/templates/storefront/src/theme/valero/slots/layout/PromoBar/promo-bar-content.tsx +174 -0
  319. package/templates/storefront/src/theme/valero/slots/order/OrderDetails/index.tsx +12 -0
  320. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductCTASection.tsx +191 -0
  321. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductDetailsSection.tsx +137 -0
  322. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductFeaturePanel.tsx +245 -0
  323. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductHighlightsSection.tsx +98 -0
  324. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductOptionsSection.tsx +233 -0
  325. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductPriceSection.tsx +53 -0
  326. package/templates/storefront/src/theme/valero/slots/product/ProductActions/ProductTrustSection.tsx +84 -0
  327. package/templates/storefront/src/theme/valero/slots/product/ProductActions/index.tsx +161 -0
  328. package/templates/storefront/src/theme/valero/slots/product/ProductCard/index.tsx +132 -0
  329. package/templates/storefront/src/theme/valero/slots/product/ProductInfo/index.tsx +40 -0
  330. package/templates/storefront/src/theme/valero/templates/StorePage/index.tsx +154 -0
  331. package/templates/storefront/src/theme/valero/tokens/colors.js +16 -0
  332. package/templates/storefront/src/theme/valero/tokens/colors.ts +21 -0
  333. package/templates/storefront/src/theme/valero/tokens/fonts.ts +13 -0
  334. package/templates/storefront/src/theme/valero/tokens/index.ts +3 -0
  335. package/templates/storefront/src/theme/valero/tokens/spacing.ts +9 -0
  336. package/templates/storefront/src/theme/valero/tokens/theme.css +91 -0
  337. package/templates/storefront/tailwind.config.js +221 -0
  338. package/templates/storefront/tsconfig.json +30 -0
@@ -0,0 +1,887 @@
1
+ "use client"
2
+
3
+ import { HttpTypes } from "@medusajs/types"
4
+ import { convertToLocale } from "@core/util/money"
5
+ import Thumbnail from "@modules/products/components/thumbnail"
6
+ import LineItemOptions from "@modules/common/components/line-item-options"
7
+ import LocalizedClientLink from "@modules/common/components/localized-client-link"
8
+ import React, { useEffect, useState } from "react"
9
+ import { listSwaps } from "@core/data/swaps"
10
+ import { listReturns } from "@core/data/returns"
11
+ import { sdk } from "@core/config"
12
+ import { XMark, Spinner } from "@medusajs/icons"
13
+ import Image from "next/image"
14
+
15
+ type OrderRedesignProps = {
16
+ order: HttpTypes.StoreOrder
17
+ handleDownloadInvoice: () => Promise<void>
18
+ isDownloading: boolean
19
+ handleCancelOrder: () => Promise<void>
20
+ isCancelling: boolean
21
+ handleReorder: (skipVariantIds?: string[], forceReorder?: boolean) => Promise<void>
22
+ isReordering: boolean
23
+ canCancel: boolean
24
+ isCancelled: boolean
25
+ hasReturnableItems: boolean
26
+ inventoryIssues: any[] | null
27
+ setInventoryIssues: (issues: any[] | null) => void
28
+ }
29
+
30
+ const OrderRedesign: React.FC<OrderRedesignProps> = ({
31
+ order,
32
+ handleDownloadInvoice,
33
+ isDownloading,
34
+ handleCancelOrder,
35
+ isCancelling,
36
+ handleReorder,
37
+ isReordering,
38
+ canCancel,
39
+ isCancelled,
40
+ hasReturnableItems,
41
+ inventoryIssues,
42
+ setInventoryIssues
43
+ }) => {
44
+ const [paddingClass, setPaddingClass] = useState("px-0")
45
+ const [hasActiveExchange, setHasActiveExchange] = useState(false)
46
+ const [hasActiveReturn, setHasActiveReturn] = useState(false)
47
+ const [isGuestUser, setIsGuestUser] = useState<boolean | null>(null)
48
+ const [isCheckingStock, setIsCheckingStock] = useState(false)
49
+ const [fetchedReturns, setFetchedReturns] = useState<any[]>([])
50
+ const [fetchedSwaps, setFetchedSwaps] = useState<any[]>([])
51
+ const [showReorderConfirmModal, setShowReorderConfirmModal] = useState(false)
52
+
53
+ useEffect(() => {
54
+ setPaddingClass("px-0")
55
+
56
+ // Check login status on mount
57
+ const isLoggedIn = document.cookie.includes("_medusa_jwt")
58
+
59
+ // Safely determine guest status after mount
60
+ const guestStatus = !order.customer_id || !isLoggedIn
61
+ setIsGuestUser(guestStatus)
62
+ const checkSwaps = async () => {
63
+ try {
64
+ const result = await listSwaps(order.id)
65
+ const activeSwaps = (result?.swaps || []).filter((s: any) =>
66
+ s.status !== "canceled" && s.status !== "rejected"
67
+ )
68
+ if (activeSwaps.length > 0) {
69
+ setHasActiveExchange(true)
70
+ setFetchedSwaps(activeSwaps)
71
+ }
72
+ } catch (err) {
73
+ // Silence error
74
+ }
75
+ }
76
+
77
+ // Check for active returns
78
+ const checkReturns = async () => {
79
+ try {
80
+ const result = await listReturns(order.id)
81
+ const activeReturns = (result?.returns || result?.return_orders || []).filter((r: any) =>
82
+ r.status !== "canceled" && r.status !== "rejected"
83
+ )
84
+ if (activeReturns.length > 0) {
85
+ setHasActiveReturn(true)
86
+ setFetchedReturns(activeReturns)
87
+ }
88
+ } catch (err) {
89
+ // Silence error
90
+ }
91
+ }
92
+
93
+ checkSwaps()
94
+ checkReturns()
95
+ }, [order.id])
96
+
97
+ // Lock body scroll when inventory issues modal is open
98
+ useEffect(() => {
99
+ if (inventoryIssues) {
100
+ document.body.style.overflow = 'hidden'
101
+ } else {
102
+ document.body.style.overflow = 'unset'
103
+ }
104
+ return () => {
105
+ document.body.style.overflow = 'unset'
106
+ }
107
+ }, [inventoryIssues])
108
+
109
+ const getAmount = (amount?: number | null) => {
110
+ if (amount === undefined || amount === null) return "₹0"
111
+ return convertToLocale({
112
+ amount,
113
+ currency_code: order.currency_code,
114
+ })
115
+ }
116
+
117
+ const formatDate = (date: string | Date) => {
118
+ try {
119
+ const d = new Date(date)
120
+ if (isNaN(d.getTime())) return "N/A"
121
+ return new Intl.DateTimeFormat("en-US", {
122
+ month: "short",
123
+ day: "numeric",
124
+ year: "numeric",
125
+ }).format(d)
126
+ } catch (e) {
127
+ return "N/A"
128
+ }
129
+ }
130
+
131
+ const formatStepDate = (date: string | Date) => {
132
+ try {
133
+ if (!date) return ""
134
+ const d = new Date(date)
135
+ if (isNaN(d.getTime())) return ""
136
+ return new Intl.DateTimeFormat("en-US", {
137
+ weekday: "short",
138
+ day: "numeric",
139
+ month: "short",
140
+ }).format(d)
141
+ } catch (e) {
142
+ return ""
143
+ }
144
+ }
145
+
146
+ const fromMetadataDate = order.metadata?.estimated_delivery || (order as any).shipping_methods?.[0]?.metadata?.etd
147
+ const calcDays = fromMetadataDate ? Math.max(1, Math.ceil((new Date(fromMetadataDate as string).getTime() - new Date(order.created_at).getTime()) / (1000 * 60 * 60 * 24))) : 7
148
+
149
+ const estimatedDays =
150
+ order.metadata?.estimated_delivery_days ||
151
+ order.metadata?.delivery_days ||
152
+ order.metadata?.days ||
153
+ (order as any).shipping_methods?.[0]?.metadata?.estimated_delivery_days ||
154
+ (order as any).shipping_methods?.[0]?.metadata?.delivery_days ||
155
+ (order as any).shipping_methods?.[0]?.metadata?.days ||
156
+ calcDays;
157
+
158
+ const deliveryText = (estimatedDays === 7 || estimatedDays === "7") ? "1 week" : `${estimatedDays} days`
159
+
160
+ const steps = [
161
+ { title: "Order Confirmed", status: "confirmed", date: order.created_at },
162
+ { title: "Shipped", status: "shipped", date: null },
163
+ { title: "Out For Delivery", status: "out_for_delivery", date: null },
164
+ { title: "Delivered", status: "delivered", date: null },
165
+ ]
166
+
167
+ const getStatusIndex = (status: string) => {
168
+ switch (status) {
169
+ case "not_fulfilled":
170
+ return 0
171
+ case "partially_fulfilled":
172
+ case "fulfilled":
173
+ return 1
174
+ case "partially_shipped":
175
+ case "shipped":
176
+ return 2
177
+ case "delivered":
178
+ return 3
179
+ default:
180
+ return 0
181
+ }
182
+ }
183
+
184
+ const currentStatusIndex = getStatusIndex(order.fulfillment_status)
185
+
186
+ return (
187
+ <>
188
+ <div className={"w-full max-w-[1360px] mx-auto overflow-x-hidden " + paddingClass + " py-6 sm:py-8 font-sans"}>
189
+ <h1 className="text-2xl sm:text-3xl font-bold text-[#0D1B3E] mb-6 sm:mb-8 text-center">
190
+ Track Your Little One's Order
191
+ </h1>
192
+
193
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-6 sm:gap-8">
194
+ {/* Left Column */}
195
+ <div className="lg:col-span-2 space-y-4 sm:space-y-6">
196
+ {/* Main Order Card */}
197
+ <div className="bg-[#FFFAFE] rounded-2xl shadow-sm border border-gray-100 p-4 sm:p-6 overflow-visible">
198
+ <div className="flex flex-col md:flex-row justify-between items-start gap-4 mb-4 sm:mb-6">
199
+ <div>
200
+
201
+ <div className="flex items-center gap-2 sm:gap-3 flex-wrap">
202
+ <h2 className="text-lg sm:text-xl font-bold text-[#0D1B3E] flex items-center gap-2">
203
+ Order ID: {order.display_id}
204
+ </h2>
205
+ {/* Order Status Badges */}
206
+ <div className="flex items-center gap-2">
207
+ {/* Fulfillment Status */}
208
+ {(() => {
209
+ const returns = (order as any).returns || (order as any).return_orders || []
210
+ const isReviewed = returns.some((r: any) => r.status === "received" || r.status === "partially_received")
211
+ const isRequested = returns.some((r: any) => r.status === "requested")
212
+
213
+ if (isReviewed) {
214
+ return (
215
+ <span className="px-3 py-1 rounded-full text-xs font-semibold bg-sky-50 text-sky-600 border border-sky-100">
216
+ Returned
217
+ </span>
218
+ )
219
+ }
220
+
221
+ if (isRequested) {
222
+ return (
223
+ <span className="px-3 py-1 rounded-full text-xs font-semibold bg-amber-50 text-amber-600 border border-amber-100 italic">
224
+ Return Requested
225
+ </span>
226
+ )
227
+ }
228
+
229
+ return (
230
+ <span className={`px-3 py-1 rounded-full text-xs font-semibold ${(order.fulfillment_status === 'fulfilled' || order.fulfillment_status === 'shipped' || order.fulfillment_status === 'delivered')
231
+ ? 'bg-green-100 text-green-700'
232
+ : order.fulfillment_status === 'canceled'
233
+ ? 'bg-red-100 text-red-700'
234
+ : order.fulfillment_status === 'partially_fulfilled'
235
+ ? 'bg-yellow-100 text-yellow-700'
236
+ : 'bg-blue-100 text-blue-700'
237
+ }`}>
238
+ {(order.fulfillment_status || 'pending').split('_').map(word =>
239
+ word.charAt(0).toUpperCase() + word.slice(1)
240
+ ).join(' ')}
241
+ </span>
242
+ )
243
+ })()}
244
+
245
+ {/* Refund Status */}
246
+ {(order.payment_status === "refunded" || order.payment_status === "partially_refunded") && (
247
+ <span className="px-3 py-1 bg-green-50 text-[#008A5D] rounded-full text-[10px] font-bold italic border border-green-100 shadow-sm animate-pulse">
248
+ Amount Refunded ✨
249
+ </span>
250
+ )}
251
+
252
+ {/* Payment Status */}
253
+ <span className={`px-3 py-1 rounded-full text-xs font-semibold ${(order.payment_status === 'captured' || order.payment_status === 'partially_captured')
254
+ ? 'bg-green-100 text-green-700'
255
+ : (order.payment_status === 'awaiting' || order.payment_status === 'authorized' || order.payment_status === 'partially_authorized')
256
+ ? 'bg-yellow-100 text-yellow-700'
257
+ : (order.payment_status === 'canceled' || order.payment_status === 'refunded' || order.payment_status === 'partially_refunded')
258
+ ? 'bg-red-100 text-red-700'
259
+ : 'bg-gray-100 text-gray-700'
260
+ }`}>
261
+ Payment: {(order.payment_status || 'pending').split('_').map(word =>
262
+ word.charAt(0).toUpperCase() + word.slice(1)
263
+ ).join(' ')}
264
+ </span>
265
+ </div>
266
+ </div>
267
+ <div className="flex flex-wrap items-center gap-x-6 gap-y-2 mt-2">
268
+ <div className="flex items-center gap-2 text-gray-500 text-sm">
269
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>
270
+ <span>Order date: <span className="text-black font-semibold">{formatDate(order.created_at)}</span></span>
271
+ </div>
272
+ <div className="flex items-center gap-2 text-[#008A5D] text-sm">
273
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline></svg>
274
+ <span className="font-semibold">Estimated delivery: After {deliveryText}</span>
275
+ </div>
276
+ </div>
277
+ </div>
278
+ <div className="flex flex-col gap-3 w-full md:w-auto">
279
+ {/* First Row: Invoice & Reorder */}
280
+ {(order.fulfillment_status === "delivered" || isCancelled) && (
281
+ <div className={`grid gap-2 sm:gap-3 ${order.fulfillment_status === "delivered" && !isCancelled ? "grid-cols-2" : "grid-cols-2 md:grid-cols-3"}`}>
282
+ {order.fulfillment_status === "delivered" && !isCancelled && (
283
+ <button
284
+ onClick={handleDownloadInvoice}
285
+ disabled={isDownloading}
286
+ className="inline-flex items-center justify-center gap-2 px-4 py-2 bg-[#FFFAFE] border border-gray-200 rounded-xl text-gray-600 hover:bg-gray-50 hover:text-gray-900 transition-all text-sm font-medium whitespace-nowrap min-w-[120px] shadow-sm"
287
+ >
288
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" /><polyline points="14 2 14 8 20 8" /><path d="M8 13h8" /><path d="M8 17h8" /><path d="M8 9h1" /></svg>
289
+ {isDownloading ? "..." : "Invoice"}
290
+ </button>
291
+ )}
292
+
293
+ <div className="relative group w-full min-w-[120px]">
294
+ <button
295
+ onClick={() => handleReorder()}
296
+ disabled={isReordering}
297
+ className="w-full inline-flex items-center justify-center gap-2 px-4 py-2 bg-[#8B5AB1] border border-transparent text-white rounded-xl hover:bg-[#764a97] hover:shadow-md transition-all text-sm font-bold disabled:opacity-50 shadow-sm transform active:scale-95 disabled:bg-gray-400 disabled:shadow-none"
298
+ data-ga-event="order_reorder_click"
299
+ data-ga-label={`Order ${order.display_id}`}
300
+ >
301
+ {isReordering ? (
302
+ <Spinner className="animate-spin" />
303
+ ) : (
304
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" /><path d="M21 3v5h-5" /><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" /><path d="M3 21v-5h5" /></svg>
305
+ )}
306
+ {isReordering ? "Processing..." : "Reorder"}
307
+ </button>
308
+ </div>
309
+ </div>
310
+ )}
311
+
312
+ {/* Second Row: Return & Exchange & Cancel */}
313
+ <div className="grid grid-cols-2 md:grid-cols-3 gap-2 sm:gap-3 items-start">
314
+ {order.fulfillment_status === "delivered" && (
315
+ <>
316
+ {(() => {
317
+ const returns = (order as any).returns || (order as any).return_orders || []
318
+ const hasActiveReturns = returns.filter((r: any) => r.status !== "canceled" && r.status !== "rejected").length > 0
319
+ const isReturnDisabled = hasActiveReturns || hasActiveReturn || !hasReturnableItems
320
+ // Default to guest path if not yet determined to avoid mismatch
321
+ const returnHref = isGuestUser === false ? `/account/orders/return/${order.id}` : `/order/return/${order.id}`
322
+
323
+ return (
324
+ <div className="w-full">
325
+ {isReturnDisabled ? (
326
+ <button disabled className="w-full flex items-center justify-center gap-2 px-3 py-2 border border-gray-100 bg-gray-50 rounded-xl text-gray-300 cursor-not-allowed text-sm font-medium whitespace-nowrap" data-ga-event="order_return_disabled" data-ga-label={`Order ${order.display_id}`}>
327
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>
328
+ Return
329
+ </button>
330
+ ) : (
331
+ <LocalizedClientLink href={returnHref} className="w-full flex items-center justify-center gap-2 px-3 py-2 border border-gray-300 bg-[#FFFAFE] rounded-xl text-gray-700 hover:border-gray-400 hover:text-black hover:bg-gray-50 transition-all text-sm font-medium whitespace-nowrap shadow-sm" data-ga-event="order_return_click" data-ga-label={`Order ${order.display_id}`}>
332
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>
333
+ Return
334
+ </LocalizedClientLink>
335
+ )}
336
+ </div>
337
+ )
338
+ })()}
339
+
340
+ {(() => {
341
+ const swaps = (order as any).swaps || []
342
+ const hasActiveSwaps = swaps.filter((s: any) => s.status !== "canceled" && s.status !== "rejected").length > 0
343
+ const isExchangeDisabled = hasActiveSwaps || hasActiveExchange || !hasReturnableItems
344
+ const exchangeHref = isGuestUser === false ? `/account/orders/exchange/${order.id}` : `/order/exchange/${order.id}`
345
+
346
+ return (
347
+ <div className="w-full">
348
+ {isExchangeDisabled ? (
349
+ <button disabled className="w-full flex items-center justify-center gap-2 px-3 py-2 border border-gray-100 bg-gray-50 rounded-xl text-gray-300 cursor-not-allowed text-sm font-medium whitespace-nowrap" data-ga-event="order_exchange_disabled" data-ga-label={`Order ${order.display_id}`}>
350
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M8 3 4 7l4 4" /><path d="M4 7h16" /><path d="m16 21 4-4-4-4" /><path d="M20 17H4" /></svg>
351
+ Exchange
352
+ </button>
353
+ ) : (
354
+ <LocalizedClientLink href={exchangeHref} className="w-full flex items-center justify-center gap-2 px-3 py-2 border border-[#8B5AB1] bg-purple-50/50 rounded-xl text-[#8B5AB1] hover:bg-[#8B5AB1] hover:text-white transition-all text-sm font-medium whitespace-nowrap shadow-sm" data-ga-event="order_exchange_click" data-ga-label={`Order ${order.display_id}`}>
355
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M8 3 4 7l4 4" /><path d="M4 7h16" /><path d="m16 21 4-4-4-4" /><path d="M20 17H4" /></svg>
356
+ Exchange
357
+ </LocalizedClientLink>
358
+ )}
359
+ </div>
360
+ )
361
+ })()}
362
+ </>
363
+ )}
364
+
365
+ {/* Cancel Order Button */}
366
+ {(() => {
367
+ const hasFulfillment = order.fulfillment_status !== 'not_fulfilled'
368
+ const isDisabled = isCancelling || isCancelled || !canCancel || hasFulfillment
369
+
370
+ return (
371
+ <div className="relative group w-full">
372
+ <button
373
+ onClick={handleCancelOrder}
374
+ disabled={isDisabled}
375
+ className={`w-full flex items-center justify-center gap-2 px-3 py-2 border rounded-xl transition-all text-sm font-medium disabled:opacity-50 whitespace-nowrap shadow-sm ${isCancelled
376
+ ? "border-gray-200 bg-gray-50 text-gray-400"
377
+ : "border-red-200 bg-[#FFFAFE] text-red-500 hover:bg-red-50 hover:border-red-300 hover:text-red-700 hover:shadow-red-50"
378
+ }`}
379
+ data-ga-event="order_cancel_click"
380
+ data-ga-label={`Order ${order.display_id}`}
381
+ >
382
+ {isCancelling ? (
383
+ <svg className="animate-spin h-4 w-4" fill="none" viewBox="0 0 24 24"><circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle><path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
384
+ ) : (
385
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M18 6L6 18M6 6l12 12" /></svg>
386
+ )}
387
+ {isCancelling ? "..." : isCancelled ? "Cancelled" : "Cancel Order"}
388
+ </button>
389
+
390
+ {hasFulfillment && !isCancelled && (
391
+ <div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-[220px] px-3 py-2 bg-gray-900 text-white text-[10px] leading-tight rounded-lg shadow-xl opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-[100] text-center">
392
+ Cannot cancel after shipping.
393
+ <div className="absolute top-full left-1/2 -translate-x-1/2 border-[4px] border-transparent border-t-gray-900"></div>
394
+ </div>
395
+ )}
396
+ </div>
397
+ )
398
+ })()}
399
+ </div>
400
+ </div>
401
+ </div>
402
+
403
+ <hr className="border-gray-100 mb-6 sm:mb-8" />
404
+
405
+ {/* Stepper */}
406
+ <div className="relative mb-8 sm:mb-12 px-2 sm:px-4">
407
+ <div className="flex justify-between items-start">
408
+ {(isCancelled ? [
409
+ { title: "Order Confirmed", status: "confirmed", date: order.created_at },
410
+ { title: "Order Cancelled", status: "canceled", date: (order as any).canceled_at || new Date() }
411
+ ] : steps).map((step, index, arr) => {
412
+ const isActive = isCancelled ? true : index <= currentStatusIndex
413
+ const isCancelledStep = isCancelled && index === 1
414
+
415
+ // Dynamic color based on status
416
+ const activeColor = isCancelledStep ? "bg-red-600" : "bg-[#008A5D]"
417
+ const ringColor = isCancelledStep ? "ring-red-600" : "ring-[#008A5D]"
418
+ const textColor = isCancelledStep ? "text-red-600" : "text-[#008A5D]"
419
+ const widthClass = isCancelled ? "w-1/2" : "w-1/4"
420
+
421
+ // Helper to get icon based on status
422
+ const getIcon = () => {
423
+ if (isCancelledStep) return (
424
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
425
+ )
426
+
427
+ if (step.status === 'confirmed') return (
428
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
429
+ )
430
+ if (step.status === 'shipped') return (
431
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>
432
+ )
433
+ if (step.status === 'out_for_delivery') return (
434
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="1" y="3" width="15" height="13"></rect><polygon points="16 8 20 8 23 11 23 16 16 16 16 8"></polygon><circle cx="5.5" cy="18.5" r="2.5"></circle><circle cx="18.5" cy="18.5" r="2.5"></circle></svg>
435
+ )
436
+ if (step.status === 'delivered') return (
437
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>
438
+ )
439
+
440
+ // Default fallback
441
+ return <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"></circle></svg>
442
+ }
443
+
444
+ return (
445
+ <div key={index} className={`flex flex-col items-center relative z-10 ${widthClass}`}>
446
+ {/* Line - Adjusted top spacing for larger icon */}
447
+ {index < arr.length - 1 && (
448
+ <div
449
+ className={`absolute left-[50%] top-4 sm:top-5 w-full h-0.5 sm:h-1 -z-10 ${isActive ? (isCancelled ? "bg-red-600" : "bg-[#008A5D]") : "bg-gray-200"
450
+ }`}
451
+ />
452
+ )}
453
+
454
+ {/* Circle - Increased size */}
455
+ <div
456
+ className={`w-8 h-8 sm:w-10 sm:h-10 rounded-full border-2 sm:border-4 flex items-center justify-center transition-all ${isActive
457
+ ? `${activeColor} border-white ring-1 ${ringColor} text-white`
458
+ : "bg-[#FFFAFE] border-gray-200 text-gray-300"
459
+ }`}
460
+ >
461
+ {getIcon()}
462
+ </div>
463
+
464
+ {/* Text */}
465
+ <div className="mt-2 sm:mt-3 text-center px-1">
466
+ <p className={`text-[10px] sm:text-xs font-bold leading-tight ${isActive ? textColor : "text-gray-400"}`}>
467
+ {step.title}
468
+ </p>
469
+ <p className="text-[9px] sm:text-[10px] text-gray-400 mt-1">
470
+ {step.date ? formatStepDate(step.date) : ""}
471
+ {!isCancelled && !isActive && index === 3 ? `After ${deliveryText}` : ""}
472
+ </p>
473
+ </div>
474
+ </div>
475
+ )
476
+ })}
477
+ </div>
478
+ </div>
479
+
480
+ {/* Product List */}
481
+ <div className="space-y-4 sm:space-y-6">
482
+ {order.items?.map((item) => (
483
+ <LocalizedClientLink
484
+ key={item.id}
485
+ href={`/products/${item.variant?.product?.handle}`}
486
+ className="flex flex-row gap-3 sm:gap-4 p-3 sm:p-4 rounded-xl border border-gray-50 bg-[#FFFAFE] group transition-all hover:shadow-sm"
487
+ >
488
+ <div className="w-20 h-20 sm:w-24 sm:h-24 flex-shrink-0 bg-[#FFFAFE] rounded-lg overflow-hidden flex items-center justify-center border border-gray-100 group-hover:opacity-80 transition-opacity">
489
+ <Thumbnail
490
+ thumbnail={item.thumbnail}
491
+ variantImages={item.variant?.images}
492
+ images={item.variant?.product?.images}
493
+ size="square"
494
+ className="object-contain w-full h-full"
495
+ />
496
+ </div>
497
+ <div className="flex-grow flex flex-col justify-between min-w-0">
498
+ <div>
499
+ <h3 className="text-[#0D1B3E] font-bold text-sm sm:text-lg leading-tight line-clamp-2 group-hover:text-[#8B5AB1] transition-colors">
500
+ {item.title}
501
+ </h3>
502
+ <div className="mt-0.5 sm:mt-1 text-gray-500 text-xs sm:text-sm">
503
+ <LineItemOptions variant={item.variant} />
504
+ </div>
505
+ </div>
506
+ <div className="flex justify-between items-end mt-1 sm:mt-0">
507
+ <div className="text-[#0D1B3E] font-bold text-base sm:text-xl">
508
+ {convertToLocale({
509
+ amount: (item.unit_price ?? 0) * item.quantity,
510
+ currency_code: order.currency_code,
511
+ })}
512
+ </div>
513
+ <div className="text-gray-500 text-xs sm:text-sm">
514
+ Qty: {item.quantity}
515
+ </div>
516
+ </div>
517
+ </div>
518
+ </LocalizedClientLink>
519
+ ))}
520
+ </div>
521
+ </div>
522
+
523
+ {/* Returns & Exchanges Details */}
524
+ {(fetchedReturns.length > 0 || fetchedSwaps.length > 0) && (
525
+ <div className="bg-[#FFFAFE] rounded-2xl shadow-sm border border-gray-100 p-4 sm:p-6 mb-4 sm:mb-6 mt-4">
526
+ <h3 className="text-base sm:text-lg font-bold text-[#0D1B3E] mb-4">Return & Exchange Details</h3>
527
+ <div className="space-y-4">
528
+ {fetchedReturns.map((r: any, idx: number) => (
529
+ <div key={r.id || idx} className="bg-orange-50 rounded-xl p-4 border border-orange-100">
530
+ <div className="flex justify-between items-center mb-3">
531
+ <h4 className="font-bold text-orange-800">Return Request</h4>
532
+ <span className="text-[10px] font-bold bg-orange-200 text-orange-800 px-2 py-0.5 rounded uppercase tracking-wider">{r.status}</span>
533
+ </div>
534
+ <div className="space-y-3">
535
+ {r.items?.map((item: any, i: number) => {
536
+ const itemName = order.items?.find((oItem: any) => oItem.id === item.item_id)?.title || 'Returned Item'
537
+ return (
538
+ <div key={i} className="bg-white p-3 rounded-lg border border-orange-100 shadow-sm">
539
+ <h5 className="font-bold text-sm text-gray-900 mb-2 pb-2 border-b border-gray-50 flex items-center gap-2">
540
+ 📦 <span className="truncate" title={itemName}>{itemName}</span>
541
+ </h5>
542
+ <div className="mb-2">
543
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-bold">Reason</span>
544
+ <p className="text-sm font-semibold text-gray-900 capitalize">{item.return_reason?.value || item.reason?.value || 'N/A'}</p>
545
+ </div>
546
+ {item.note && (
547
+ <div className="mt-2 pt-2 border-t border-gray-50">
548
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-bold">Additional Note</span>
549
+ <p className="text-sm text-gray-700 bg-gray-50 p-2.5 rounded-lg mt-1 font-medium border border-gray-100 italic">"{item.note}"</p>
550
+ </div>
551
+ )}
552
+ </div>
553
+ )
554
+ })}
555
+ </div>
556
+ {r.note && (
557
+ <div className="mt-3 bg-white p-3 rounded-lg border border-orange-100 shadow-sm">
558
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-bold">Request Note</span>
559
+ <p className="text-sm text-gray-700 mt-1 font-medium italic mb-0">"{r.note}"</p>
560
+ </div>
561
+ )}
562
+ </div>
563
+ ))}
564
+
565
+ {fetchedSwaps.map((s: any, idx: number) => (
566
+ <div key={s.id || idx} className="bg-purple-50 rounded-xl p-4 border border-purple-100">
567
+ <div className="flex justify-between items-center mb-3">
568
+ <h4 className="font-bold text-purple-800">Exchange Request</h4>
569
+ <span className="text-[10px] font-bold bg-purple-200 text-purple-800 px-2 py-0.5 rounded uppercase tracking-wider">{s.status}</span>
570
+ </div>
571
+ <div className="space-y-3">
572
+ {s.return_order?.items?.map((item: any, i: number) => {
573
+ const itemName = order.items?.find((oItem: any) => oItem.id === item.item_id)?.title || 'Exchanged Item'
574
+ return (
575
+ <div key={i} className="bg-white p-3 rounded-lg border border-purple-100 shadow-sm">
576
+ <h5 className="font-bold text-sm text-gray-900 mb-2 pb-2 border-b border-gray-50 flex items-center gap-2">
577
+ 🔄 <span className="truncate" title={itemName}>{itemName}</span>
578
+ </h5>
579
+ <div className="mb-2">
580
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-bold">Reason</span>
581
+ <p className="text-sm font-semibold text-gray-900 capitalize">{item.return_reason?.value || item.reason?.value || 'N/A'}</p>
582
+ </div>
583
+ {item.note && (
584
+ <div className="mt-2 pt-2 border-t border-gray-50">
585
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-bold">Additional Note</span>
586
+ <p className="text-sm text-gray-700 bg-gray-50 p-2.5 rounded-lg mt-1 font-medium border border-gray-100 italic">"{item.note}"</p>
587
+ </div>
588
+ )}
589
+ </div>
590
+ )
591
+ })}
592
+ </div>
593
+ {s.return_order?.note && (
594
+ <div className="mt-3 bg-white p-3 rounded-lg border border-purple-100 shadow-sm">
595
+ <span className="text-[10px] text-gray-500 uppercase tracking-wider font-bold">Exchange Note</span>
596
+ <p className="text-sm text-gray-700 mt-1 font-medium italic mb-0">"{s.return_order.note}"</p>
597
+ </div>
598
+ )}
599
+ </div>
600
+ ))}
601
+ </div>
602
+ </div>
603
+ )}
604
+
605
+ {/* Payment & Delivery Bottom Cards */}
606
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4 sm:gap-6">
607
+ {/* Payment Card */}
608
+ <div className="bg-[#FFFAFE] rounded-2xl shadow-sm border border-gray-100 p-4 sm:p-6">
609
+ <h3 className="text-base sm:text-lg font-bold text-[#0D1B3E] mb-3 sm:mb-4">Payment</h3>
610
+ {(() => {
611
+ const payment = (order as any).payments?.[0] || order.payment_collections?.[0]?.payments?.[0]
612
+ const providerId = payment?.provider_id || ""
613
+ const isManual = providerId.includes("manual") || providerId.includes("system_default") || providerId === "cod"
614
+
615
+ if (isManual) {
616
+ return (
617
+ <div className="flex items-center gap-3">
618
+ <span className="inline-flex items-center gap-2 text-gray-900 font-medium text-sm">
619
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><rect x="2" y="6" width="20" height="12" rx="2"/><path d="M12 12h.01"/><path d="M17 12h.01"/><path d="M7 12h.01"/></svg>
620
+ Cash on Delivery (Cash/UPI)
621
+ </span>
622
+ </div>
623
+ )
624
+ }
625
+
626
+ const brand = (payment?.data?.card_brand as string)?.toUpperCase()
627
+ const last4 = payment?.data?.card_last4 as string
628
+
629
+ if (brand || last4) {
630
+ return (
631
+ <div className="flex items-center gap-3">
632
+ <span className="text-gray-600 text-sm font-medium">
633
+ **{last4 || "0000"}
634
+ </span>
635
+ {brand && (
636
+ <div className="px-2 py-0.5 border border-blue-100 rounded text-[10px] font-bold text-blue-600 bg-blue-50">
637
+ {brand}
638
+ </div>
639
+ )}
640
+ </div>
641
+ )
642
+ }
643
+
644
+ return (
645
+ <div className="flex items-center gap-3">
646
+ <span className="text-gray-600 text-sm capitalize">
647
+ {providerId ? providerId.replace(/_/g, " ") : "Payment details not available"}
648
+ </span>
649
+ </div>
650
+ )
651
+ })()}
652
+ </div>
653
+
654
+ {/* Delivery Card */}
655
+ <div className="bg-[#FFFAFE] rounded-2xl shadow-sm border border-gray-100 p-4 sm:p-6">
656
+ <h3 className="text-base sm:text-lg font-bold text-[#0D1B3E] mb-2 sm:mb-3">Delivery</h3>
657
+ <div className="space-y-1">
658
+ <p className="text-gray-500 text-xs font-medium uppercase tracking-wider">Address</p>
659
+ <div className="text-gray-600 text-sm leading-relaxed">
660
+ <p className="font-semibold text-gray-900 mb-1">
661
+ {order.shipping_address?.first_name} {order.shipping_address?.last_name}
662
+ </p>
663
+ <p>{order.shipping_address?.address_1}</p>
664
+ {order.shipping_address?.address_2 && <p>{order.shipping_address.address_2}</p>}
665
+ <p>
666
+ {order.shipping_address?.city}
667
+ {order.shipping_address?.province && `, ${order.shipping_address.province}`}
668
+ {order.shipping_address?.postal_code && ` - ${order.shipping_address.postal_code}`}
669
+ </p>
670
+ <p className="text-gray-400 text-[10px] uppercase mt-0.5">{order.shipping_address?.country_code}</p>
671
+ <p className="mt-2 text-gray-900 font-medium">
672
+ Phone: {order.shipping_address?.phone ? (order.shipping_address.phone.startsWith("+") ? order.shipping_address.phone : `+${order.shipping_address.phone}`) : "N/A"}
673
+ </p>
674
+ </div>
675
+ </div>
676
+ </div>
677
+ </div>
678
+
679
+ {/* Help / Issues Section */}
680
+ <div className="bg-[#FFFAFE] rounded-2xl shadow-sm border border-gray-100 p-4 sm:p-6">
681
+ <div className="flex flex-col sm:flex-row items-center justify-between gap-4 text-center sm:text-left">
682
+ <div>
683
+ <h3 className="text-lg font-bold text-[#0D1B3E]">Having an issue with this order?</h3>
684
+ <p className="text-gray-500 text-sm mt-1">Check our frequently asked questions or contact our support team for help.</p>
685
+ </div>
686
+ <LocalizedClientLink
687
+ href="/help"
688
+ className="inline-flex items-center justify-center gap-2 px-6 py-3 bg-[#FFFAFE] border-2 border-[#8B5AB1] text-[#8B5AB1] rounded-xl hover:bg-[#8B5AB1] hover:text-white transition-all text-sm font-bold shadow-sm whitespace-nowrap min-w-[140px]"
689
+ >
690
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
691
+ Help & FAQ
692
+ </LocalizedClientLink>
693
+ </div>
694
+ </div>
695
+ </div>
696
+
697
+ {/* Right Column - Price Summary */}
698
+ <div className="lg:col-span-1">
699
+ <div className="bg-[#FFFAFE] rounded-2xl shadow-sm border border-gray-100 p-4 sm:p-6 sticky top-4 sm:top-8">
700
+ <h3 className="text-xs sm:text-sm font-bold text-gray-400 uppercase tracking-wider mb-4 sm:mb-6">
701
+ PRICE SUMMARY ({order.items?.length} {order.items?.length === 1 ? "ITEM" : "ITEMS"})
702
+ </h3>
703
+
704
+ <div className="space-y-3 sm:space-y-4">
705
+ <div className="flex justify-between items-center text-gray-600 text-sm sm:text-base">
706
+ <span>Total MRP</span>
707
+ <span className="font-medium">
708
+ {getAmount(order.items?.reduce((acc, item) => {
709
+ return acc + ((item as any).original_total ?? (item.unit_price * item.quantity))
710
+ }, 0))}
711
+ </span>
712
+ </div>
713
+
714
+ {order.discount_total > 0 && (
715
+ <div className="flex justify-between items-center text-[#008A5D] text-sm sm:text-base">
716
+ <span>Discount</span>
717
+ <span className="font-medium">-{getAmount(order.discount_total)}</span>
718
+ </div>
719
+ )}
720
+
721
+ <div className="flex justify-between items-center text-gray-600 text-sm sm:text-base">
722
+ <span>GST</span>
723
+ <span className="font-medium">{getAmount(order.tax_total)}</span>
724
+ </div>
725
+
726
+ <div className="flex justify-between items-center text-gray-600 text-sm sm:text-base">
727
+ <span>Shipping</span>
728
+ <span className="font-medium">{getAmount(order.shipping_total)}</span>
729
+ </div>
730
+
731
+ <hr className="border-gray-100 my-3 sm:my-4" />
732
+
733
+ <div className="flex justify-between items-center text-[#0D1B3E] text-lg sm:text-xl font-bold">
734
+ <span>Subtotal</span>
735
+ <span>{getAmount(order.subtotal)}</span>
736
+ </div>
737
+ </div>
738
+ </div>
739
+ </div>
740
+ </div>
741
+ </div>
742
+ {inventoryIssues && (
743
+ <div className="fixed inset-0 z-[9999] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-300" onClick={() => setInventoryIssues(null)}>
744
+ <div
745
+ className="w-full max-w-[480px] bg-white rounded-[2rem] shadow-[0_20px_40px_rgba(0,0,0,0.1)] overflow-hidden relative animate-in zoom-in-95 duration-200"
746
+ onClick={e => e.stopPropagation()}
747
+ >
748
+ <div className="p-5 sm:p-6 relative">
749
+ {/* Close Icon */}
750
+ <button
751
+ onClick={() => setInventoryIssues(null)}
752
+ className="absolute top-5 right-5 p-1 text-gray-300 hover:text-gray-900 transition-colors"
753
+ >
754
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
755
+ </button>
756
+
757
+ {/* Centered Icon */}
758
+ <div className="flex justify-center mb-4">
759
+ <div className="w-10 h-10 rounded-full bg-red-50 flex items-center justify-center text-red-500">
760
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>
761
+ </div>
762
+ </div>
763
+
764
+ <div className="text-center mb-5 px-2">
765
+ <h2 className="text-[17px] font-bold text-gray-900 leading-snug px-2 whitespace-nowrap">
766
+ {inventoryIssues.every(i => (i.available_quantity ?? 0) === 0) && inventoryIssues.length === (order.items?.length ?? 0) ? (
767
+ <>Sorry! This product is currently out of stock 😔</>
768
+ ) : (
769
+ "Inventory Update"
770
+ )}
771
+ </h2>
772
+ <p className="text-[13px] text-gray-500 mt-2 leading-relaxed">
773
+ {inventoryIssues.every(i => (i.available_quantity ?? 0) === 0) && inventoryIssues.length === (order.items?.length ?? 0)
774
+ ? "You can explore and purchase similar products instead 🛍️✨"
775
+ : "Some items in your order are currently unavailable or have limited stock. Would you like to proceed with the remaining items?"}
776
+ </p>
777
+ </div>
778
+
779
+ {/* Comprehensive Item List */}
780
+ <div className="space-y-3 max-h-[35vh] overflow-y-auto pr-1 custom-scrollbar mb-8">
781
+ {order.items?.map((item, idx) => {
782
+ const issue = inventoryIssues.find(i => i.variant_id === item.variant_id)
783
+ const isOutOfStock = issue?.available_quantity === 0
784
+ const isLimited = issue && (issue.available_quantity ?? 0) > 0
785
+ const isFullyAvailable = !issue
786
+
787
+ return (
788
+ <div key={idx} className={`p-3 rounded-2xl flex items-center gap-4 border transition-all ${
789
+ isOutOfStock ? "bg-red-50/50 border-red-100" :
790
+ isLimited ? "bg-orange-50/50 border-orange-100" :
791
+ "bg-green-50/50 border-green-100"
792
+ }`}>
793
+ <div className="w-12 h-12 rounded-xl overflow-hidden bg-white border border-gray-100 flex-shrink-0 shadow-sm">
794
+ {item.thumbnail ? (
795
+ <Image
796
+ src={item.thumbnail}
797
+ alt={item.title || "Product"}
798
+ width={48}
799
+ height={48}
800
+ className="w-full h-full object-cover"
801
+ />
802
+ ) : (
803
+ <div className="w-full h-full flex items-center justify-center text-[8px] text-gray-300 font-bold">N/A</div>
804
+ )}
805
+ </div>
806
+
807
+ <div className="flex-grow min-w-0">
808
+ <div className="flex justify-between items-start gap-2">
809
+ <h4 className="font-bold text-xs text-gray-900 truncate">
810
+ {item.title}
811
+ </h4>
812
+ <span className="text-[8px] font-black uppercase tracking-tighter text-gray-400 whitespace-nowrap">
813
+ Qty: {item.quantity}
814
+ </span>
815
+ </div>
816
+
817
+ <div className="flex items-center gap-2 mt-1">
818
+ {isOutOfStock ? (
819
+ <span className="text-[9px] font-bold text-red-500 uppercase tracking-wider flex items-center gap-1">
820
+ <div className="w-1 h-1 rounded-full bg-red-500" />
821
+ Out of Stock
822
+ </span>
823
+ ) : isLimited ? (
824
+ <span className="text-[9px] font-bold text-orange-600 uppercase tracking-wider flex items-center gap-1">
825
+ <div className="w-1 h-1 rounded-full bg-orange-500" />
826
+ Only {issue.available_quantity} available
827
+ </span>
828
+ ) : (
829
+ <span className="text-[9px] font-bold text-green-600 uppercase tracking-wider flex items-center gap-1">
830
+ <div className="w-1 h-1 rounded-full bg-green-500" />
831
+ Fully Available
832
+ </span>
833
+ )}
834
+ </div>
835
+ </div>
836
+ </div>
837
+ )
838
+ })}
839
+ </div>
840
+
841
+ <div className="flex gap-3 mt-2">
842
+ {(inventoryIssues.length < (order.items?.length ?? 0) || inventoryIssues.some(i => (i.available_quantity ?? 0) > 0)) ? (
843
+ <>
844
+ <button
845
+ onClick={() => setInventoryIssues(null)}
846
+ className="flex-1 h-11 rounded-xl font-bold text-sm bg-gray-100 text-gray-500 hover:bg-gray-200 transition-all active:scale-95"
847
+ >
848
+ Cancel
849
+ </button>
850
+ <button
851
+ onClick={() => {
852
+ setInventoryIssues(null)
853
+ handleReorder([], true)
854
+ }}
855
+ disabled={isReordering}
856
+ className="flex-1 h-11 rounded-xl font-bold text-sm bg-[#8B5AB1] text-white hover:bg-[#764a97] transition-all active:scale-95 disabled:opacity-50 shadow-sm"
857
+ >
858
+ {isReordering ? <Spinner className="animate-spin" /> : "Reorder"}
859
+ </button>
860
+ </>
861
+ ) : (
862
+ <div className="flex gap-3 w-full">
863
+ <button
864
+ onClick={() => setInventoryIssues(null)}
865
+ className="flex-1 h-11 rounded-xl font-bold text-sm bg-gray-100 text-gray-500 hover:bg-gray-200 transition-all active:scale-95"
866
+ >
867
+ Got It
868
+ </button>
869
+ <LocalizedClientLink
870
+ href="/store"
871
+ className="flex-1 h-11 rounded-xl font-bold text-sm bg-[#8B5AB1] text-white hover:bg-[#764a97] transition-all active:scale-95 shadow-sm flex items-center justify-center"
872
+ onClick={() => setInventoryIssues(null)}
873
+ >
874
+ SHOP NOW
875
+ </LocalizedClientLink>
876
+ </div>
877
+ )}
878
+ </div>
879
+ </div>
880
+ </div>
881
+ </div>
882
+ )}
883
+ </>
884
+ )
885
+ }
886
+
887
+ export default OrderRedesign