@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,257 @@
1
+ "use client"
2
+
3
+ import { isManual, isStripeLike, isRazorpay } from "@core/constants"
4
+ import { placeOrder } from "@core/data/cart"
5
+ import { trackAddPaymentInfo } from "@core/analytics/ga4-ecommerce"
6
+ import { HttpTypes } from "@medusajs/types"
7
+ import { Button, clx } from "@medusajs/ui"
8
+ import { useElements, useStripe } from "@stripe/react-stripe-js"
9
+ import React, { useState } from "react"
10
+ import ErrorMessage from "../error-message"
11
+ import { RazorpayPaymentButton } from "./razorpay-payment-button"
12
+
13
+ type PaymentButtonProps = {
14
+ cart: HttpTypes.StoreCart
15
+ "data-testid": string
16
+ }
17
+
18
+ const PaymentButton: React.FC<PaymentButtonProps> = ({
19
+ cart,
20
+ "data-testid": dataTestId,
21
+ }) => {
22
+ const notReady =
23
+ !cart ||
24
+ !cart.shipping_address ||
25
+ !cart.billing_address ||
26
+ !cart.email ||
27
+ (cart.shipping_methods?.length ?? 0) < 1
28
+
29
+ const paymentSession = cart.payment_collection?.payment_sessions?.[0]
30
+
31
+ switch (true) {
32
+ case isStripeLike(paymentSession?.provider_id):
33
+ return (
34
+ <StripePaymentButton
35
+ notReady={notReady}
36
+ cart={cart}
37
+ data-testid={dataTestId}
38
+ />
39
+ )
40
+ case isRazorpay(paymentSession?.provider_id):
41
+ return (
42
+ <RazorpayPaymentButton
43
+ notReady={notReady}
44
+ session={paymentSession!}
45
+ cart={cart}
46
+ />
47
+ )
48
+ case isManual(paymentSession?.provider_id):
49
+ return (
50
+ <ManualTestPaymentButton
51
+ notReady={notReady}
52
+ cart={cart}
53
+ data-testid={dataTestId}
54
+ />
55
+ )
56
+ default:
57
+ return <Button disabled>Select a payment method</Button>
58
+ }
59
+ }
60
+
61
+ const StripePaymentButton = ({
62
+ cart,
63
+ notReady,
64
+ "data-testid": dataTestId,
65
+ }: {
66
+ cart: HttpTypes.StoreCart
67
+ notReady: boolean
68
+ "data-testid"?: string
69
+ }) => {
70
+ const [submitting, setSubmitting] = useState(false)
71
+ const [errorMessage, setErrorMessage] = useState<string | null>(null)
72
+
73
+ const onPaymentCompleted = async () => {
74
+ await placeOrder()
75
+ .catch((err) => {
76
+ setErrorMessage(err.message)
77
+ })
78
+ .finally(() => {
79
+ setSubmitting(false)
80
+ })
81
+ }
82
+
83
+ const stripe = useStripe()
84
+ const elements = useElements()
85
+ const card = elements?.getElement("card")
86
+
87
+ const session = cart.payment_collection?.payment_sessions?.find(
88
+ (s) => s.status === "pending"
89
+ )
90
+
91
+ const disabled = !stripe || !elements ? true : false
92
+
93
+ const handlePayment = async () => {
94
+ setSubmitting(true)
95
+
96
+ if (!stripe || !elements || !card || !cart) {
97
+ setSubmitting(false)
98
+ return
99
+ }
100
+
101
+ const currency =
102
+ (cart as any).currency_code?.toUpperCase() ??
103
+ (cart as any).region?.currency_code?.toUpperCase() ??
104
+ "USD"
105
+ const value = ((cart as any).total ?? 0) / 100
106
+ const items = (cart.items ?? []).map((item: any, index: number) => {
107
+ const unitTotal = item.total && item.quantity ? item.total / item.quantity : 0
108
+ return {
109
+ item_id: item.variant_id ?? item.id,
110
+ item_name: item.title ?? "",
111
+ price: unitTotal / 100,
112
+ quantity: item.quantity,
113
+ index,
114
+ }
115
+ })
116
+ trackAddPaymentInfo({ currency, value, items })
117
+
118
+ await stripe
119
+ .confirmCardPayment(session?.data.client_secret as string, {
120
+ payment_method: {
121
+ card: card,
122
+ billing_details: {
123
+ name:
124
+ cart.billing_address?.first_name +
125
+ " " +
126
+ cart.billing_address?.last_name,
127
+ address: {
128
+ city: cart.billing_address?.city ?? undefined,
129
+ country: cart.billing_address?.country_code ?? undefined,
130
+ line1: cart.billing_address?.address_1 ?? undefined,
131
+ line2: cart.billing_address?.address_2 ?? undefined,
132
+ postal_code: cart.billing_address?.postal_code ?? undefined,
133
+ state: cart.billing_address?.province ?? undefined,
134
+ },
135
+ email: cart.email,
136
+ phone: cart.billing_address?.phone ?? undefined,
137
+ },
138
+ },
139
+ })
140
+ .then(({ error, paymentIntent }) => {
141
+ if (error) {
142
+ const pi = error.payment_intent
143
+
144
+ if (
145
+ (pi && pi.status === "requires_capture") ||
146
+ (pi && pi.status === "succeeded")
147
+ ) {
148
+ onPaymentCompleted()
149
+ }
150
+
151
+ setErrorMessage(error.message || null)
152
+ return
153
+ }
154
+
155
+ if (
156
+ (paymentIntent && paymentIntent.status === "requires_capture") ||
157
+ paymentIntent.status === "succeeded"
158
+ ) {
159
+ return onPaymentCompleted()
160
+ }
161
+
162
+ return
163
+ })
164
+ }
165
+
166
+ return (
167
+ <>
168
+ <button
169
+ disabled={disabled || notReady || submitting}
170
+ onClick={handlePayment}
171
+ className={clx(
172
+ "w-full py-2.5 px-6 rounded-full font-semibold text-base transition-all shadow-sm flex items-center justify-center",
173
+ {
174
+ "bg-brand-accent text-inverse hover:bg-brand-accent-hover": !disabled && !notReady && !submitting,
175
+ "bg-gray-300 text-gray-500 cursor-not-allowed": disabled || notReady || submitting,
176
+ }
177
+ )}
178
+ data-testid={dataTestId}
179
+ >
180
+ {submitting ? "Processing..." : "Place order"}
181
+ </button>
182
+ <ErrorMessage
183
+ error={errorMessage}
184
+ data-testid="stripe-payment-error-message"
185
+ />
186
+ </>
187
+ )
188
+ }
189
+
190
+ const ManualTestPaymentButton = ({
191
+ notReady,
192
+ cart,
193
+ "data-testid": dataTestId,
194
+ }: {
195
+ notReady: boolean
196
+ cart: HttpTypes.StoreCart
197
+ "data-testid"?: string
198
+ }) => {
199
+ const [submitting, setSubmitting] = useState(false)
200
+ const [errorMessage, setErrorMessage] = useState<string | null>(null)
201
+
202
+ const onPaymentCompleted = async () => {
203
+ await placeOrder()
204
+ .catch((err) => {
205
+ setErrorMessage(err.message)
206
+ })
207
+ .finally(() => {
208
+ setSubmitting(false)
209
+ })
210
+ }
211
+
212
+ const handlePayment = () => {
213
+ setSubmitting(true)
214
+ const currency =
215
+ (cart as any).currency_code?.toUpperCase() ??
216
+ (cart as any).region?.currency_code?.toUpperCase() ??
217
+ "USD"
218
+ const value = ((cart as any).total ?? 0) / 100
219
+ const items = (cart.items ?? []).map((item: any, index: number) => {
220
+ const unitTotal = item.total && item.quantity ? item.total / item.quantity : 0
221
+ return {
222
+ item_id: item.variant_id ?? item.id,
223
+ item_name: item.title ?? "",
224
+ price: unitTotal / 100,
225
+ quantity: item.quantity,
226
+ index,
227
+ }
228
+ })
229
+ trackAddPaymentInfo({ currency, value, items })
230
+ onPaymentCompleted()
231
+ }
232
+
233
+ return (
234
+ <>
235
+ <button
236
+ disabled={notReady || submitting}
237
+ onClick={handlePayment}
238
+ className={clx(
239
+ "w-full py-2.5 px-6 rounded-full font-semibold text-base transition-all shadow-sm flex items-center justify-center",
240
+ {
241
+ "bg-brand-accent text-inverse hover:bg-brand-accent-hover": !notReady && !submitting,
242
+ "bg-gray-300 text-gray-500 cursor-not-allowed": notReady || submitting,
243
+ }
244
+ )}
245
+ data-testid={dataTestId ?? "submit-order-button"}
246
+ >
247
+ {submitting ? "Processing..." : "Place order"}
248
+ </button>
249
+ <ErrorMessage
250
+ error={errorMessage}
251
+ data-testid="manual-payment-error-message"
252
+ />
253
+ </>
254
+ )
255
+ }
256
+
257
+ export default PaymentButton
@@ -0,0 +1,136 @@
1
+ import { Button, clx } from "@medusajs/ui"
2
+ import Spinner from "@modules/common/icons/spinner"
3
+ import React, { useCallback, useEffect, useState } from "react"
4
+ import { useRazorpay, RazorpayOrderOptions } from "react-razorpay"
5
+ import { HttpTypes } from "@medusajs/types"
6
+ import { placeOrder } from "@core/data/cart"
7
+ import ProcessingOverlay from "@modules/checkout/components/processing-overlay"
8
+
9
+ export const RazorpayPaymentButton = ({
10
+ session,
11
+ notReady,
12
+ cart,
13
+ }: {
14
+ session: HttpTypes.StorePaymentSession
15
+ notReady: boolean
16
+ cart: HttpTypes.StoreCart
17
+ }) => {
18
+ const [submitting, setSubmitting] = useState(false)
19
+ const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined)
20
+ const { Razorpay } = useRazorpay()
21
+ const [orderData, setOrderData] = useState({ id: "" })
22
+
23
+ const onPaymentCompleted = async () => {
24
+ await placeOrder().catch((err) => {
25
+ if (err.message === "NEXT_REDIRECT") {
26
+ return
27
+ }
28
+ setErrorMessage("Final verification failed. Please contact support.")
29
+ setSubmitting(false)
30
+ })
31
+ }
32
+
33
+ useEffect(() => {
34
+ if (session.data?.id) {
35
+ setOrderData({ id: session.data.id as string })
36
+ }
37
+ }, [session.data])
38
+
39
+ const handlePayment = useCallback(async () => {
40
+ if (!Razorpay) {
41
+ setErrorMessage("Payment gateway failed to load. Please refresh.")
42
+ setSubmitting(false)
43
+ return;
44
+ }
45
+
46
+ const currency = cart.currency_code?.toUpperCase() ?? "USD"
47
+ const value = ((cart as any).total ?? 0) / 100
48
+ const items = (cart.items ?? []).map((item: any, index: number) => {
49
+ const unitTotal = item.total && item.quantity ? item.total / item.quantity : 0
50
+ return {
51
+ item_id: item.variant_id ?? item.id,
52
+ item_name: item.title ?? "",
53
+ price: unitTotal / 100,
54
+ quantity: item.quantity,
55
+ index,
56
+ }
57
+ })
58
+ trackAddPaymentInfo({ currency, value, items })
59
+
60
+ const options: RazorpayOrderOptions = {
61
+ callback_url: `${process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL}/razorpay/hooks`,
62
+ key: process.env.NEXT_PUBLIC_RAZORPAY_KEY ?? "",
63
+ amount: session.amount,
64
+ order_id: orderData.id,
65
+ currency: cart.currency_code.toUpperCase(),
66
+ name: process.env.NEXT_PUBLIC_SHOP_NAME ?? "Chocomelon",
67
+ description: `Secure checkout for your order`,
68
+ remember_customer: true,
69
+ modal: {
70
+ backdropclose: true,
71
+ escape: true,
72
+ handleback: true,
73
+ confirm_close: true,
74
+ ondismiss: () => {
75
+ setSubmitting(false)
76
+ },
77
+ animation: true,
78
+ },
79
+ handler: async (response) => {
80
+ setSubmitting(true) // Ensure we show the premium processing state
81
+ await onPaymentCompleted();
82
+ },
83
+ prefill: {
84
+ name: `${cart.billing_address?.first_name || ""} ${cart.billing_address?.last_name || ""}`,
85
+ email: cart.email,
86
+ contact: cart.shipping_address?.phone || cart.billing_address?.phone || undefined,
87
+ },
88
+ theme: {
89
+ color: "var(--color-brand-accent)"
90
+ }
91
+ };
92
+
93
+ try {
94
+ const razorpay = new Razorpay(options);
95
+ razorpay.on("payment.failed", function (response: any) {
96
+ setErrorMessage(response.error.description || "Payment failed");
97
+ setSubmitting(false);
98
+ });
99
+ razorpay.open();
100
+ } catch (error: any) {
101
+ setSubmitting(false);
102
+ }
103
+ }, [Razorpay, cart, orderData.id, session.amount, onPaymentCompleted]);
104
+
105
+ return (
106
+ <div className="w-full">
107
+ <ProcessingOverlay isOpen={submitting} />
108
+ <button
109
+ type="button"
110
+ disabled={submitting || notReady || !orderData?.id || !Razorpay}
111
+ onClick={async (e) => {
112
+ e.preventDefault();
113
+ setSubmitting(true)
114
+ handlePayment()
115
+ }}
116
+ data-ga-event="razorpay_payment_click"
117
+ data-ga-label="Pay with Razorpay"
118
+ className={clx(
119
+ "w-full py-2.5 min-[550px]:py-3 px-6 rounded-full font-bold text-base transition-all mt-6 shadow-md active:scale-[0.98]",
120
+ {
121
+ "bg-brand-accent text-inverse hover:bg-brand-accent-hover hover:shadow-lg": !submitting,
122
+ "bg-gray-200 text-gray-400 cursor-not-allowed": submitting,
123
+ }
124
+ )}
125
+ >
126
+ Pay with Razorpay
127
+ </button>
128
+
129
+ {errorMessage && !submitting && (
130
+ <div className="text-red-500 text-xs font-bold mt-3 p-3 bg-red-50 rounded-lg border border-red-100 animate-in fade-in slide-in-from-top-2">
131
+ ⚠️ {errorMessage}
132
+ </div>
133
+ )}
134
+ </div>
135
+ )
136
+ }
@@ -0,0 +1,129 @@
1
+ import { Radio as RadioGroupOption } from "@headlessui/react"
2
+ import { Text, clx } from "@medusajs/ui"
3
+ import React, { useContext, useMemo, type JSX } from "react"
4
+
5
+ import Radio from "@modules/common/components/radio"
6
+
7
+ import { isManual } from "@core/constants"
8
+ import SkeletonCardDetails from "@modules/skeletons/components/skeleton-card-details"
9
+ import { CardElement } from "@stripe/react-stripe-js"
10
+ import { StripeCardElementOptions } from "@stripe/stripe-js"
11
+ import PaymentTest from "../payment-test"
12
+ import { StripeContext } from "../payment-wrapper/stripe-wrapper"
13
+
14
+ type PaymentContainerProps = {
15
+ paymentProviderId: string
16
+ selectedPaymentOptionId: string | null
17
+ disabled?: boolean
18
+ paymentInfoMap: Record<string, { title: string; icon: JSX.Element }>
19
+ children?: React.ReactNode
20
+ }
21
+
22
+ const PaymentContainer: React.FC<PaymentContainerProps> = ({
23
+ paymentProviderId,
24
+ selectedPaymentOptionId,
25
+ paymentInfoMap,
26
+ disabled = false,
27
+ children,
28
+ }) => {
29
+ const isDevelopment = process.env.NODE_ENV === "development"
30
+
31
+ return (
32
+ <RadioGroupOption
33
+ key={paymentProviderId}
34
+ value={paymentProviderId}
35
+ disabled={disabled}
36
+ className={clx(
37
+ "flex flex-col gap-y-2 text-small-regular cursor-pointer py-4 border rounded-rounded px-8 mb-2 hover:shadow-borders-interactive-with-active",
38
+ {
39
+ "border-ui-border-interactive":
40
+ selectedPaymentOptionId === paymentProviderId,
41
+ }
42
+ )}
43
+ >
44
+ <div className="flex items-center justify-between ">
45
+ <div className="flex items-center gap-x-4">
46
+ <Radio checked={selectedPaymentOptionId === paymentProviderId} />
47
+ <Text className="text-base-regular">
48
+ {paymentInfoMap[paymentProviderId]?.title || paymentProviderId}
49
+ </Text>
50
+ {isManual(paymentProviderId) && isDevelopment && (
51
+ <PaymentTest className="hidden small:block" />
52
+ )}
53
+ </div>
54
+ <span className="justify-self-end text-ui-fg-base">
55
+ {paymentInfoMap[paymentProviderId]?.icon}
56
+ </span>
57
+ </div>
58
+ {isManual(paymentProviderId) && isDevelopment && (
59
+ <PaymentTest className="small:hidden text-[10px]" />
60
+ )}
61
+ {children}
62
+ </RadioGroupOption>
63
+ )
64
+ }
65
+
66
+ export default PaymentContainer
67
+
68
+ export const StripeCardContainer = ({
69
+ paymentProviderId,
70
+ selectedPaymentOptionId,
71
+ paymentInfoMap,
72
+ disabled = false,
73
+ setCardBrand,
74
+ setError,
75
+ setCardComplete,
76
+ }: Omit<PaymentContainerProps, "children"> & {
77
+ setCardBrand: (brand: string) => void
78
+ setError: (error: string | null) => void
79
+ setCardComplete: (complete: boolean) => void
80
+ }) => {
81
+ const stripeReady = useContext(StripeContext)
82
+
83
+ const useOptions: StripeCardElementOptions = useMemo(() => {
84
+ return {
85
+ style: {
86
+ base: {
87
+ fontFamily: "Inter, sans-serif",
88
+ color: "#424270",
89
+ "::placeholder": {
90
+ color: "rgb(107 114 128)",
91
+ },
92
+ },
93
+ },
94
+ classes: {
95
+ base: "pt-3 pb-1 block w-full h-11 px-4 mt-0 bg-ui-bg-field border rounded-md appearance-none focus:outline-none focus:ring-0 focus:shadow-borders-interactive-with-active border-ui-border-base hover:bg-ui-bg-field-hover transition-all duration-300 ease-in-out",
96
+ },
97
+ }
98
+ }, [])
99
+
100
+ return (
101
+ <PaymentContainer
102
+ paymentProviderId={paymentProviderId}
103
+ selectedPaymentOptionId={selectedPaymentOptionId}
104
+ paymentInfoMap={paymentInfoMap}
105
+ disabled={disabled}
106
+ >
107
+ {selectedPaymentOptionId === paymentProviderId &&
108
+ (stripeReady ? (
109
+ <div className="my-4 transition-all duration-150 ease-in-out">
110
+ <Text className="txt-medium-plus text-ui-fg-base mb-1">
111
+ Enter your card details:
112
+ </Text>
113
+ <CardElement
114
+ options={useOptions as StripeCardElementOptions}
115
+ onChange={(e) => {
116
+ setCardBrand(
117
+ e.brand && e.brand.charAt(0).toUpperCase() + e.brand.slice(1)
118
+ )
119
+ setError(e.error?.message || null)
120
+ setCardComplete(e.complete)
121
+ }}
122
+ />
123
+ </div>
124
+ ) : (
125
+ <SkeletonCardDetails />
126
+ ))}
127
+ </PaymentContainer>
128
+ )
129
+ }
@@ -0,0 +1,12 @@
1
+ import { Badge } from "@medusajs/ui"
2
+
3
+ const PaymentTest = ({ className }: { className?: string }) => {
4
+ return (
5
+ <Badge color="orange" className={className}>
6
+ <span className="font-semibold">Attention:</span> For testing purposes
7
+ only.
8
+ </Badge>
9
+ )
10
+ }
11
+
12
+ export default PaymentTest
@@ -0,0 +1,50 @@
1
+ "use client"
2
+
3
+ import { loadStripe } from "@stripe/stripe-js"
4
+ import React from "react"
5
+ import StripeWrapper from "./stripe-wrapper"
6
+ import { HttpTypes } from "@medusajs/types"
7
+ import { isStripeLike } from "@core/constants"
8
+
9
+ type PaymentWrapperProps = {
10
+ cart: HttpTypes.StoreCart
11
+ children: React.ReactNode
12
+ }
13
+
14
+ const stripeKey =
15
+ process.env.NEXT_PUBLIC_STRIPE_KEY ||
16
+ process.env.NEXT_PUBLIC_MEDUSA_PAYMENTS_PUBLISHABLE_KEY
17
+
18
+ const medusaAccountId = process.env.NEXT_PUBLIC_MEDUSA_PAYMENTS_ACCOUNT_ID
19
+ const stripePromise = stripeKey
20
+ ? loadStripe(
21
+ stripeKey,
22
+ medusaAccountId ? { stripeAccount: medusaAccountId } : undefined
23
+ )
24
+ : null
25
+
26
+ const PaymentWrapper: React.FC<PaymentWrapperProps> = ({ cart, children }) => {
27
+ const paymentSession = cart.payment_collection?.payment_sessions?.find(
28
+ (s) => s.status === "pending"
29
+ )
30
+
31
+ if (
32
+ isStripeLike(paymentSession?.provider_id) &&
33
+ paymentSession &&
34
+ stripePromise
35
+ ) {
36
+ return (
37
+ <StripeWrapper
38
+ paymentSession={paymentSession}
39
+ stripeKey={stripeKey}
40
+ stripePromise={stripePromise}
41
+ >
42
+ {children}
43
+ </StripeWrapper>
44
+ )
45
+ }
46
+
47
+ return <div>{children}</div>
48
+ }
49
+
50
+ export default PaymentWrapper
@@ -0,0 +1,54 @@
1
+ "use client"
2
+
3
+ import { Stripe, StripeElementsOptions } from "@stripe/stripe-js"
4
+ import { Elements } from "@stripe/react-stripe-js"
5
+ import { HttpTypes } from "@medusajs/types"
6
+ import { createContext } from "react"
7
+
8
+ type StripeWrapperProps = {
9
+ paymentSession: HttpTypes.StorePaymentSession
10
+ stripeKey?: string
11
+ stripePromise: Promise<Stripe | null> | null
12
+ children: React.ReactNode
13
+ }
14
+
15
+ export const StripeContext = createContext(false)
16
+
17
+ const StripeWrapper: React.FC<StripeWrapperProps> = ({
18
+ paymentSession,
19
+ stripeKey,
20
+ stripePromise,
21
+ children,
22
+ }) => {
23
+ const options: StripeElementsOptions = {
24
+ clientSecret: paymentSession!.data?.client_secret as string | undefined,
25
+ }
26
+
27
+ if (!stripeKey) {
28
+ throw new Error(
29
+ "Stripe key is missing. Set NEXT_PUBLIC_STRIPE_KEY environment variable."
30
+ )
31
+ }
32
+
33
+ if (!stripePromise) {
34
+ throw new Error(
35
+ "Stripe promise is missing. Make sure you have provided a valid Stripe key."
36
+ )
37
+ }
38
+
39
+ if (!paymentSession?.data?.client_secret) {
40
+ throw new Error(
41
+ "Stripe client secret is missing. Cannot initialize Stripe."
42
+ )
43
+ }
44
+
45
+ return (
46
+ <StripeContext.Provider value={true}>
47
+ <Elements options={options} stripe={stripePromise}>
48
+ {children}
49
+ </Elements>
50
+ </StripeContext.Provider>
51
+ )
52
+ }
53
+
54
+ export default StripeWrapper