@medusajs/loyalty-plugin 0.0.1 → 0.0.3

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 (233) hide show
  1. package/.medusa/server/src/admin/index.js +30277 -0
  2. package/.medusa/server/src/admin/index.mjs +30256 -0
  3. package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +24 -0
  4. package/.medusa/server/src/api/store/carts/middlewares.js +9 -1
  5. package/.medusa/server/src/api/store/carts/validators.js +5 -2
  6. package/.medusa/server/src/links/customer-gift-card-link.js +2 -2
  7. package/.medusa/server/src/links/customer-store-credit-account-link.js +2 -2
  8. package/.medusa/server/src/links/order-line-item-gift-card-link.js +2 -2
  9. package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +104 -0
  10. package/.medusa/server/src/workflows/hooks/after-order-created.js +2 -2
  11. package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +3 -3
  12. package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +1 -1
  13. package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +1 -1
  14. package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +115 -0
  15. package/package.json +14 -9
  16. package/.medusa/server/src/admin/components/action-menu.js +0 -63
  17. package/.medusa/server/src/admin/components/chip-group.js +0 -82
  18. package/.medusa/server/src/admin/components/chip-input.js +0 -157
  19. package/.medusa/server/src/admin/components/combobox.js +0 -324
  20. package/.medusa/server/src/admin/components/conditional-tooltip.js +0 -15
  21. package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +0 -66
  22. package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +0 -77
  23. package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +0 -110
  24. package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +0 -16
  25. package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +0 -214
  26. package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +0 -77
  27. package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +0 -32
  28. package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +0 -743
  29. package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +0 -37
  30. package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +0 -54
  31. package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +0 -66
  32. package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +0 -166
  33. package/.medusa/server/src/admin/components/data-grid/components/index.js +0 -16
  34. package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +0 -7
  35. package/.medusa/server/src/admin/components/data-grid/context/index.js +0 -6
  36. package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +0 -14
  37. package/.medusa/server/src/admin/components/data-grid/data-grid.js +0 -31
  38. package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +0 -28
  39. package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +0 -85
  40. package/.medusa/server/src/admin/components/data-grid/helpers/index.js +0 -6
  41. package/.medusa/server/src/admin/components/data-grid/hooks/index.js +0 -31
  42. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +0 -50
  43. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +0 -123
  44. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +0 -52
  45. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +0 -43
  46. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +0 -191
  47. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +0 -70
  48. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +0 -51
  49. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +0 -15
  50. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +0 -86
  51. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +0 -149
  52. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +0 -482
  53. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +0 -64
  54. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +0 -81
  55. package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +0 -14
  56. package/.medusa/server/src/admin/components/data-grid/index.js +0 -8
  57. package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +0 -27
  58. package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +0 -296
  59. package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +0 -62
  60. package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +0 -25
  61. package/.medusa/server/src/admin/components/data-grid/models/index.js +0 -10
  62. package/.medusa/server/src/admin/components/data-grid/types.js +0 -1
  63. package/.medusa/server/src/admin/components/data-grid/utils.js +0 -18
  64. package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +0 -36
  65. package/.medusa/server/src/admin/components/data-table/data-table.js +0 -271
  66. package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +0 -51
  67. package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +0 -90
  68. package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +0 -10
  69. package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +0 -48
  70. package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +0 -19
  71. package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +0 -30
  72. package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +0 -23
  73. package/.medusa/server/src/admin/components/data-table/index.js +0 -4
  74. package/.medusa/server/src/admin/components/data-table.js +0 -249
  75. package/.medusa/server/src/admin/components/display-id.js +0 -18
  76. package/.medusa/server/src/admin/components/file-upload.js +0 -116
  77. package/.medusa/server/src/admin/components/form.js +0 -151
  78. package/.medusa/server/src/admin/components/handle-input.js +0 -22
  79. package/.medusa/server/src/admin/components/header.js +0 -41
  80. package/.medusa/server/src/admin/components/icon-avatar.js +0 -27
  81. package/.medusa/server/src/admin/components/json-view-section.js +0 -139
  82. package/.medusa/server/src/admin/components/keybound-form.js +0 -32
  83. package/.medusa/server/src/admin/components/layouts/single-column.js +0 -7
  84. package/.medusa/server/src/admin/components/layouts/two-column.js +0 -13
  85. package/.medusa/server/src/admin/components/listicle.js +0 -20
  86. package/.medusa/server/src/admin/components/modals/index.js +0 -19
  87. package/.medusa/server/src/admin/components/modals/route-drawer/index.js +0 -4
  88. package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +0 -57
  89. package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +0 -4
  90. package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +0 -71
  91. package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +0 -4
  92. package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +0 -60
  93. package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +0 -6
  94. package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +0 -5
  95. package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +0 -30
  96. package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +0 -12
  97. package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +0 -5
  98. package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +0 -55
  99. package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +0 -5
  100. package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +0 -63
  101. package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +0 -6
  102. package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +0 -5
  103. package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +0 -47
  104. package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +0 -14
  105. package/.medusa/server/src/admin/components/placeholder-cell.js +0 -7
  106. package/.medusa/server/src/admin/components/product/product-cell/index.js +0 -5
  107. package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +0 -15
  108. package/.medusa/server/src/admin/components/product/product-status-cell/index.js +0 -5
  109. package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +0 -18
  110. package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +0 -5
  111. package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +0 -31
  112. package/.medusa/server/src/admin/components/product/variant-cell/index.js +0 -5
  113. package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +0 -15
  114. package/.medusa/server/src/admin/components/section-row.js +0 -32
  115. package/.medusa/server/src/admin/components/sidebar-link.js +0 -31
  116. package/.medusa/server/src/admin/components/sortable-list.js +0 -152
  117. package/.medusa/server/src/admin/components/switch-box.js +0 -43
  118. package/.medusa/server/src/admin/components/tax-badge.js +0 -18
  119. package/.medusa/server/src/admin/components/thumbnail.js +0 -28
  120. package/.medusa/server/src/admin/components/upload-media-form-item.js +0 -83
  121. package/.medusa/server/src/admin/hooks/api/customers.js +0 -26
  122. package/.medusa/server/src/admin/hooks/api/gift-cards.js +0 -107
  123. package/.medusa/server/src/admin/hooks/api/order.js +0 -16
  124. package/.medusa/server/src/admin/hooks/api/price-preferences.js +0 -19
  125. package/.medusa/server/src/admin/hooks/api/products.js +0 -127
  126. package/.medusa/server/src/admin/hooks/api/regions.js +0 -17
  127. package/.medusa/server/src/admin/hooks/api/sales-channels.js +0 -28
  128. package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +0 -41
  129. package/.medusa/server/src/admin/hooks/api/store.js +0 -31
  130. package/.medusa/server/src/admin/hooks/api/transaction-groups.js +0 -23
  131. package/.medusa/server/src/admin/hooks/api/transactions.js +0 -23
  132. package/.medusa/server/src/admin/hooks/commands/use-command-history.js +0 -45
  133. package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +0 -59
  134. package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +0 -89
  135. package/.medusa/server/src/admin/hooks/common/use-date.js +0 -32
  136. package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +0 -22
  137. package/.medusa/server/src/admin/hooks/common/use-query-params.js +0 -14
  138. package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +0 -30
  139. package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +0 -30
  140. package/.medusa/server/src/admin/hooks/sales-channels/index.js +0 -10
  141. package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +0 -48
  142. package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +0 -19
  143. package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +0 -30
  144. package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +0 -23
  145. package/.medusa/server/src/admin/lib/currencies.js +0 -729
  146. package/.medusa/server/src/admin/lib/query-key.js +0 -17
  147. package/.medusa/server/src/admin/lib/sdk.js +0 -10
  148. package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +0 -75
  149. package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +0 -172
  150. package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +0 -30
  151. package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +0 -180
  152. package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +0 -30
  153. package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +0 -97
  154. package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +0 -162
  155. package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +0 -89
  156. package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +0 -199
  157. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +0 -353
  158. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +0 -5
  159. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +0 -4
  160. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +0 -247
  161. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +0 -4
  162. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +0 -5
  163. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +0 -48
  164. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +0 -14
  165. package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +0 -28
  166. package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +0 -40
  167. package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +0 -121
  168. package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +0 -72
  169. package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +0 -23
  170. package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +0 -123
  171. package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +0 -23
  172. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +0 -1
  173. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +0 -98
  174. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +0 -28
  175. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +0 -96
  176. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +0 -90
  177. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +0 -288
  178. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +0 -111
  179. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +0 -23
  180. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +0 -285
  181. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +0 -124
  182. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +0 -4
  183. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +0 -112
  184. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +0 -1
  185. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +0 -35
  186. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +0 -11
  187. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +0 -61
  188. package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +0 -23
  189. package/.medusa/server/src/admin/routes/gift-card-products/page.js +0 -18
  190. package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +0 -137
  191. package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +0 -87
  192. package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +0 -352
  193. package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +0 -116
  194. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +0 -49
  195. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +0 -177
  196. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +0 -27
  197. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +0 -33
  198. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +0 -33
  199. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +0 -18
  200. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +0 -50
  201. package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +0 -23
  202. package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +0 -78
  203. package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +0 -40
  204. package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +0 -57
  205. package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +0 -13
  206. package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +0 -61
  207. package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +0 -23
  208. package/.medusa/server/src/admin/routes/gift-cards/page.js +0 -27
  209. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +0 -126
  210. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +0 -31
  211. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +0 -43
  212. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +0 -44
  213. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +0 -18
  214. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +0 -37
  215. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +0 -58
  216. package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +0 -39
  217. package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +0 -58
  218. package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +0 -13
  219. package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +0 -31
  220. package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +0 -56
  221. package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +0 -19
  222. package/.medusa/server/src/admin/utils/date-utils.js +0 -27
  223. package/.medusa/server/src/admin/utils/format-amount.js +0 -9
  224. package/.medusa/server/src/admin/utils/format-date.js +0 -21
  225. package/.medusa/server/src/admin/utils/refs.js +0 -20
  226. package/.medusa/server/src/admin/utils/statuses.js +0 -23
  227. package/.medusa/server/src/admin/utils/validations.js +0 -71
  228. package/.medusa/server/src/admin/utils/variants.js +0 -92
  229. package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +0 -67
  230. package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +0 -42
  231. package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +0 -58
  232. package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +0 -96
  233. package/.medusa/server/types/loyalty/module.js +0 -8
@@ -1,47 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { StackedModalContext } from "./stacked-modal-context.js";
4
- const StackedModalProvider = ({
5
- children,
6
- onOpenChange
7
- }) => {
8
- const [state, setState] = useState({});
9
- const getIsOpen = (id) => {
10
- return state[id] || false;
11
- };
12
- const setIsOpen = (id, open) => {
13
- setState((prevState) => ({
14
- ...prevState,
15
- [id]: open
16
- }));
17
- onOpenChange(open);
18
- };
19
- const register = (id) => {
20
- setState((prevState) => ({
21
- ...prevState,
22
- [id]: false
23
- }));
24
- };
25
- const unregister = (id) => {
26
- setState((prevState) => {
27
- const newState = { ...prevState };
28
- delete newState[id];
29
- return newState;
30
- });
31
- };
32
- return /* @__PURE__ */ jsx(
33
- StackedModalContext.Provider,
34
- {
35
- value: {
36
- getIsOpen,
37
- setIsOpen,
38
- register,
39
- unregister
40
- },
41
- children
42
- }
43
- );
44
- };
45
- export {
46
- StackedModalProvider
47
- };
@@ -1,14 +0,0 @@
1
- import { useContext } from "react";
2
- import { StackedModalContext } from "./stacked-modal-context.js";
3
- const useStackedModal = () => {
4
- const context = useContext(StackedModalContext);
5
- if (!context) {
6
- throw new Error(
7
- "useStackedModal must be used within a StackedModalProvider"
8
- );
9
- }
10
- return context;
11
- };
12
- export {
13
- useStackedModal
14
- };
@@ -1,7 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- const PlaceholderCell = () => {
3
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "-" }) });
4
- };
5
- export {
6
- PlaceholderCell
7
- };
@@ -1,5 +0,0 @@
1
- import { ProductCell, ProductHeader } from "./product-cell.js";
2
- export {
3
- ProductCell,
4
- ProductHeader
5
- };
@@ -1,15 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { Thumbnail } from "../../thumbnail.js";
3
- const ProductCell = ({ product }) => {
4
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full max-w-[250px] items-center gap-x-3 overflow-hidden", children: [
5
- /* @__PURE__ */ jsx("div", { className: "w-fit flex-shrink-0", children: /* @__PURE__ */ jsx(Thumbnail, { src: product.thumbnail }) }),
6
- /* @__PURE__ */ jsx("span", { title: product.title, className: "truncate", children: product.title })
7
- ] });
8
- };
9
- const ProductHeader = () => {
10
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { children: "Product" }) });
11
- };
12
- export {
13
- ProductCell,
14
- ProductHeader
15
- };
@@ -1,5 +0,0 @@
1
- import { ProductStatusCell, ProductStatusHeader } from "./product-status-cell.js";
2
- export {
3
- ProductStatusCell,
4
- ProductStatusHeader
5
- };
@@ -1,18 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { StatusBadge } from "@medusajs/ui";
3
- const ProductStatusCell = ({ status }) => {
4
- const [color, text] = {
5
- draft: ["grey", "Draft"],
6
- proposed: ["orange", "Proposed"],
7
- published: ["green", "Published"],
8
- rejected: ["red", "Rejected"]
9
- }[status];
10
- return /* @__PURE__ */ jsx(StatusBadge, { color, children: text });
11
- };
12
- const ProductStatusHeader = () => {
13
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { children: "Status" }) });
14
- };
15
- export {
16
- ProductStatusCell,
17
- ProductStatusHeader
18
- };
@@ -1,5 +0,0 @@
1
- import { SalesChannelHeader, SalesChannelsCell } from "./sales-channels-cell.js";
2
- export {
3
- SalesChannelHeader,
4
- SalesChannelsCell
5
- };
@@ -1,31 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Tooltip } from "@medusajs/ui";
3
- import { PlaceholderCell } from "../../placeholder-cell.js";
4
- const SalesChannelsCell = ({
5
- salesChannels
6
- }) => {
7
- if (!salesChannels || !salesChannels.length) {
8
- return /* @__PURE__ */ jsx(PlaceholderCell, {});
9
- }
10
- if (salesChannels.length > 2) {
11
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full items-center gap-x-1 overflow-hidden", children: [
12
- /* @__PURE__ */ jsx("span", { className: "truncate", children: salesChannels.slice(0, 2).map((sc) => sc.name).join(", ") }),
13
- /* @__PURE__ */ jsx(
14
- Tooltip,
15
- {
16
- content: /* @__PURE__ */ jsx("ul", { children: salesChannels.slice(2).map((sc) => /* @__PURE__ */ jsx("li", { children: sc.name }, sc.id)) }),
17
- children: /* @__PURE__ */ jsx("span", { className: "text-xs", children: `+ ${salesChannels.length - 2} more` })
18
- }
19
- )
20
- ] });
21
- }
22
- const channels = salesChannels.map((sc) => sc.name).join(", ");
23
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center overflow-hidden max-w-[250px]", children: /* @__PURE__ */ jsx("span", { title: channels, className: "truncate", children: channels }) });
24
- };
25
- const SalesChannelHeader = () => {
26
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { children: "Sales Channels" }) });
27
- };
28
- export {
29
- SalesChannelHeader,
30
- SalesChannelsCell
31
- };
@@ -1,5 +0,0 @@
1
- import { VariantCell, VariantHeader } from "./variant-cell.js";
2
- export {
3
- VariantCell,
4
- VariantHeader
5
- };
@@ -1,15 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { PlaceholderCell } from "../../placeholder-cell.js";
3
- const VariantCell = ({ variants }) => {
4
- if (!variants || !variants.length) {
5
- return /* @__PURE__ */ jsx(PlaceholderCell, {});
6
- }
7
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: `${variants.length} denomination${variants.length > 1 ? "s" : ""}` }) });
8
- };
9
- const VariantHeader = () => {
10
- return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center", children: /* @__PURE__ */ jsx("span", { children: "Denominations" }) });
11
- };
12
- export {
13
- VariantCell,
14
- VariantHeader
15
- };
@@ -1,32 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { clx, Text } from "@medusajs/ui";
3
- const SectionRow = ({ title, value, actions }) => {
4
- const isValueString = typeof value === "string" || !value;
5
- return /* @__PURE__ */ jsxs(
6
- "div",
7
- {
8
- className: clx(
9
- `text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4`,
10
- {
11
- "grid-cols-[1fr_1fr_28px]": !!actions
12
- }
13
- ),
14
- children: [
15
- /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: title }),
16
- isValueString ? /* @__PURE__ */ jsx(
17
- Text,
18
- {
19
- size: "small",
20
- leading: "compact",
21
- className: "whitespace-pre-line text-pretty",
22
- children: value ?? "-"
23
- }
24
- ) : /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: value }),
25
- actions && /* @__PURE__ */ jsx("div", { children: actions })
26
- ]
27
- }
28
- );
29
- };
30
- export {
31
- SectionRow
32
- };
@@ -1,31 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Link } from "react-router-dom";
3
- import { TriangleRightMini } from "@medusajs/icons";
4
- import { Text } from "@medusajs/ui";
5
- const SidebarLink = ({
6
- to,
7
- labelKey,
8
- descriptionKey,
9
- icon,
10
- children
11
- }) => {
12
- return /* @__PURE__ */ jsx(Link, { to, className: "group outline-none", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
13
- icon && /* @__PURE__ */ jsx("div", { children: icon }),
14
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
15
- /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: labelKey }),
16
- /* @__PURE__ */ jsx(
17
- Text,
18
- {
19
- size: "small",
20
- leading: "compact",
21
- className: "text-ui-fg-subtle",
22
- children: descriptionKey
23
- }
24
- )
25
- ] }),
26
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: children ? children : /* @__PURE__ */ jsx(TriangleRightMini, { className: "text-ui-fg-muted" }) })
27
- ] }) }) }) });
28
- };
29
- export {
30
- SidebarLink
31
- };
@@ -1,152 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { defaultDropAnimationSideEffects, useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, DragOverlay } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@dnd-kit/core/dist/core.esm.js";
3
- import { sortableKeyboardCoordinates, SortableContext, useSortable, arrayMove } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@dnd-kit/sortable/dist/sortable.esm.js";
4
- import { CSS } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@dnd-kit/utilities/dist/utilities.esm.js";
5
- import { DotsSix } from "@medusajs/icons";
6
- import { IconButton, clx } from "@medusajs/ui";
7
- import { createContext, useState, useMemo, Fragment, useContext } from "react";
8
- const List = ({
9
- items,
10
- onChange,
11
- renderItem
12
- }) => {
13
- const [active, setActive] = useState(null);
14
- const [activeItem, activeIndex] = useMemo(() => {
15
- if (active === null) {
16
- return [null, null];
17
- }
18
- const index = items.findIndex(({ id }) => id === active.id);
19
- return [items[index], index];
20
- }, [active, items]);
21
- const sensors = useSensors(
22
- useSensor(PointerSensor),
23
- useSensor(KeyboardSensor, {
24
- coordinateGetter: sortableKeyboardCoordinates
25
- })
26
- );
27
- const handleDragStart = ({ active: active2 }) => {
28
- setActive(active2);
29
- };
30
- const handleDragEnd = ({ active: active2, over }) => {
31
- if (over && active2.id !== over.id) {
32
- const activeIndex2 = items.findIndex(({ id }) => id === active2.id);
33
- const overIndex = items.findIndex(({ id }) => id === over.id);
34
- onChange(arrayMove(items, activeIndex2, overIndex));
35
- }
36
- setActive(null);
37
- };
38
- const handleDragCancel = () => {
39
- setActive(null);
40
- };
41
- return /* @__PURE__ */ jsxs(
42
- DndContext,
43
- {
44
- sensors,
45
- onDragStart: handleDragStart,
46
- onDragEnd: handleDragEnd,
47
- onDragCancel: handleDragCancel,
48
- children: [
49
- /* @__PURE__ */ jsx(Overlay, { children: activeItem && activeIndex !== null ? renderItem(activeItem, activeIndex) : null }),
50
- /* @__PURE__ */ jsx(SortableContext, { items, children: /* @__PURE__ */ jsx(
51
- "ul",
52
- {
53
- role: "application",
54
- className: "flex list-inside list-none list-image-none flex-col p-0",
55
- children: items.map((item, index) => /* @__PURE__ */ jsx(Fragment, { children: renderItem(item, index) }, item.id))
56
- }
57
- ) })
58
- ]
59
- }
60
- );
61
- };
62
- const dropAnimationConfig = {
63
- sideEffects: defaultDropAnimationSideEffects({
64
- styles: {
65
- active: {
66
- opacity: "0.4"
67
- }
68
- }
69
- })
70
- };
71
- const Overlay = ({ children }) => {
72
- return /* @__PURE__ */ jsx(
73
- DragOverlay,
74
- {
75
- className: "shadow-elevation-card-hover overflow-hidden rounded-md [&>li]:border-b-0",
76
- dropAnimation: dropAnimationConfig,
77
- children
78
- }
79
- );
80
- };
81
- const SortableItemContext = createContext(
82
- null
83
- );
84
- const useSortableItemContext = () => {
85
- const context = useContext(SortableItemContext);
86
- if (!context) {
87
- throw new Error(
88
- "useSortableItemContext must be used within a SortableItemContext"
89
- );
90
- }
91
- return context;
92
- };
93
- const Item = ({
94
- id,
95
- className,
96
- children
97
- }) => {
98
- const {
99
- attributes,
100
- isDragging,
101
- listeners,
102
- setNodeRef,
103
- setActivatorNodeRef,
104
- transform,
105
- transition
106
- } = useSortable({ id });
107
- const context = useMemo(
108
- () => ({
109
- attributes,
110
- listeners,
111
- ref: setActivatorNodeRef,
112
- isDragging
113
- }),
114
- [attributes, listeners, setActivatorNodeRef, isDragging]
115
- );
116
- const style = {
117
- opacity: isDragging ? 0.4 : void 0,
118
- transform: CSS.Translate.toString(transform),
119
- transition
120
- };
121
- return /* @__PURE__ */ jsx(SortableItemContext.Provider, { value: context, children: /* @__PURE__ */ jsx(
122
- "li",
123
- {
124
- className: clx("transition-fg flex flex-1 list-none", className),
125
- ref: setNodeRef,
126
- style,
127
- children
128
- }
129
- ) });
130
- };
131
- const DragHandle = () => {
132
- const { attributes, listeners, ref } = useSortableItemContext();
133
- return /* @__PURE__ */ jsx(
134
- IconButton,
135
- {
136
- variant: "transparent",
137
- size: "small",
138
- ...attributes,
139
- ...listeners,
140
- ref,
141
- className: "cursor-grab touch-none active:cursor-grabbing",
142
- children: /* @__PURE__ */ jsx(DotsSix, { className: "text-ui-fg-muted" })
143
- }
144
- );
145
- };
146
- const SortableList = Object.assign(List, {
147
- Item,
148
- DragHandle
149
- });
150
- export {
151
- SortableList
152
- };
@@ -1,43 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Switch } from "@medusajs/ui";
3
- import { Form } from "./form.js";
4
- const SwitchBox = ({
5
- label,
6
- description,
7
- optional = false,
8
- tooltip,
9
- onCheckedChange,
10
- ...props
11
- }) => {
12
- return /* @__PURE__ */ jsx(
13
- Form.Field,
14
- {
15
- ...props,
16
- render: ({ field: { value, onChange, ...field } }) => {
17
- return /* @__PURE__ */ jsxs(Form.Item, { children: [
18
- /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-component shadow-elevation-card-rest flex items-start gap-x-3 rounded-lg p-3", children: [
19
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
20
- Switch,
21
- {
22
- ...field,
23
- checked: value,
24
- onCheckedChange: (e) => {
25
- onCheckedChange == null ? void 0 : onCheckedChange(e);
26
- onChange(e);
27
- }
28
- }
29
- ) }),
30
- /* @__PURE__ */ jsxs("div", { children: [
31
- /* @__PURE__ */ jsx(Form.Label, { optional, tooltip, children: label }),
32
- /* @__PURE__ */ jsx(Form.Hint, { children: description })
33
- ] })
34
- ] }),
35
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
36
- ] });
37
- }
38
- }
39
- );
40
- };
41
- export {
42
- SwitchBox
43
- };
@@ -1,18 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { TaxInclusive, TaxExclusive } from "@medusajs/icons";
3
- import { Tooltip } from "@medusajs/ui";
4
- const IncludesTaxTooltip = ({
5
- includesTax
6
- }) => {
7
- return /* @__PURE__ */ jsx(
8
- Tooltip,
9
- {
10
- maxWidth: 999,
11
- content: includesTax ? "Includes Tax" : "Excludes Tax",
12
- children: includesTax ? /* @__PURE__ */ jsx(TaxInclusive, { className: "text-ui-fg-muted shrink-0" }) : /* @__PURE__ */ jsx(TaxExclusive, { className: "text-ui-fg-muted shrink-0" })
13
- }
14
- );
15
- };
16
- export {
17
- IncludesTaxTooltip
18
- };
@@ -1,28 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Photo } from "@medusajs/icons";
3
- import { clx } from "@medusajs/ui";
4
- const Thumbnail = ({ src, alt, size = "base" }) => {
5
- return /* @__PURE__ */ jsx(
6
- "div",
7
- {
8
- className: clx(
9
- "bg-ui-bg-component border-ui-border-base flex items-center justify-center overflow-hidden rounded border",
10
- {
11
- "h-8 w-6": size === "base",
12
- "h-5 w-4": size === "small"
13
- }
14
- ),
15
- children: src ? /* @__PURE__ */ jsx(
16
- "img",
17
- {
18
- src,
19
- alt,
20
- className: "h-full w-full object-cover object-center"
21
- }
22
- ) : /* @__PURE__ */ jsx(Photo, { className: "text-ui-fg-subtle" })
23
- }
24
- );
25
- };
26
- export {
27
- Thumbnail
28
- };
@@ -1,83 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useCallback } from "react";
3
- import { FileUpload } from "./file-upload.js";
4
- import { Form } from "./form.js";
5
- const SUPPORTED_FORMATS = [
6
- "image/jpeg",
7
- "image/png",
8
- "image/gif",
9
- "image/webp",
10
- "image/heic",
11
- "image/svg+xml"
12
- ];
13
- const SUPPORTED_FORMATS_FILE_EXTENSIONS = [
14
- ".jpeg",
15
- ".png",
16
- ".gif",
17
- ".webp",
18
- ".heic",
19
- ".svg"
20
- ];
21
- const UploadMediaFormItem = ({
22
- form,
23
- append,
24
- showHint = true
25
- }) => {
26
- const hasInvalidFiles = useCallback(
27
- (fileList) => {
28
- const invalidFile = fileList.find(
29
- (f) => !SUPPORTED_FORMATS.includes(f.file.type)
30
- );
31
- if (invalidFile) {
32
- form.setError("media", {
33
- type: "invalid_file",
34
- message: `"'${invalidFile.file.name}' is not a supported file type. Supported file types are: ${SUPPORTED_FORMATS_FILE_EXTENSIONS.join(
35
- ", "
36
- )}.",`
37
- });
38
- return true;
39
- }
40
- return false;
41
- },
42
- [form]
43
- );
44
- const onUploaded = useCallback(
45
- (files) => {
46
- form.clearErrors("media");
47
- if (hasInvalidFiles(files)) {
48
- return;
49
- }
50
- files.forEach((f) => append({ ...f, isThumbnail: false }));
51
- },
52
- [form, append, hasInvalidFiles]
53
- );
54
- return /* @__PURE__ */ jsx(
55
- Form.Field,
56
- {
57
- control: form.control,
58
- name: "media",
59
- render: () => {
60
- return /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
61
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1", children: [
62
- /* @__PURE__ */ jsx(Form.Label, { optional: true, children: "Upload images" }),
63
- showHint && /* @__PURE__ */ jsx(Form.Hint, { children: "Upload images for the gift card product" })
64
- ] }),
65
- /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
66
- FileUpload,
67
- {
68
- label: "Upload images",
69
- hint: "Upload images for the gift card product",
70
- hasError: !!form.formState.errors.media,
71
- formats: SUPPORTED_FORMATS,
72
- onUploaded
73
- }
74
- ) }),
75
- /* @__PURE__ */ jsx(Form.ErrorMessage, {})
76
- ] }) });
77
- }
78
- }
79
- );
80
- };
81
- export {
82
- UploadMediaFormItem
83
- };
@@ -1,26 +0,0 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { queryKeysFactory } from "../../lib/query-key.js";
3
- import { sdk } from "../../lib/sdk.js";
4
- const CUSTOMERS_QUERY_KEY = "customers";
5
- const customersQueryKeys = queryKeysFactory(CUSTOMERS_QUERY_KEY);
6
- const useCustomer = (id, query, options) => {
7
- const { data, ...rest } = useQuery({
8
- queryKey: customersQueryKeys.detail(id),
9
- queryFn: async () => sdk.admin.customer.retrieve(id, query),
10
- ...options
11
- });
12
- return { ...data, ...rest };
13
- };
14
- const useCustomers = (query, options) => {
15
- const { data, ...rest } = useQuery({
16
- queryFn: () => sdk.admin.customer.list(query),
17
- queryKey: customersQueryKeys.list(query),
18
- ...options
19
- });
20
- return { ...data, ...rest };
21
- };
22
- export {
23
- customersQueryKeys,
24
- useCustomer,
25
- useCustomers
26
- };