@medusajs/loyalty-plugin 0.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.
- package/.medusa/server/src/admin/components/action-menu.js +63 -0
- package/.medusa/server/src/admin/components/chip-group.js +82 -0
- package/.medusa/server/src/admin/components/chip-input.js +157 -0
- package/.medusa/server/src/admin/components/combobox.js +324 -0
- package/.medusa/server/src/admin/components/conditional-tooltip.js +15 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +66 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +77 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +110 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +16 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +214 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +77 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +32 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +743 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +37 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +54 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +66 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +166 -0
- package/.medusa/server/src/admin/components/data-grid/components/index.js +16 -0
- package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +7 -0
- package/.medusa/server/src/admin/components/data-grid/context/index.js +6 -0
- package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +14 -0
- package/.medusa/server/src/admin/components/data-grid/data-grid.js +31 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +28 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +85 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/index.js +6 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/index.js +31 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +50 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +123 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +52 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +43 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +191 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +70 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +51 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +15 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +86 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +149 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +482 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +64 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +81 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +14 -0
- package/.medusa/server/src/admin/components/data-grid/index.js +8 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +27 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +296 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +62 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +25 -0
- package/.medusa/server/src/admin/components/data-grid/models/index.js +10 -0
- package/.medusa/server/src/admin/components/data-grid/types.js +1 -0
- package/.medusa/server/src/admin/components/data-grid/utils.js +18 -0
- package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +36 -0
- package/.medusa/server/src/admin/components/data-table/data-table.js +271 -0
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +51 -0
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +90 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +10 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +48 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +19 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +30 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +23 -0
- package/.medusa/server/src/admin/components/data-table/index.js +4 -0
- package/.medusa/server/src/admin/components/data-table.js +249 -0
- package/.medusa/server/src/admin/components/display-id.js +18 -0
- package/.medusa/server/src/admin/components/file-upload.js +116 -0
- package/.medusa/server/src/admin/components/form.js +151 -0
- package/.medusa/server/src/admin/components/handle-input.js +22 -0
- package/.medusa/server/src/admin/components/header.js +41 -0
- package/.medusa/server/src/admin/components/icon-avatar.js +27 -0
- package/.medusa/server/src/admin/components/json-view-section.js +139 -0
- package/.medusa/server/src/admin/components/keybound-form.js +32 -0
- package/.medusa/server/src/admin/components/layouts/single-column.js +7 -0
- package/.medusa/server/src/admin/components/layouts/two-column.js +13 -0
- package/.medusa/server/src/admin/components/listicle.js +20 -0
- package/.medusa/server/src/admin/components/modals/index.js +19 -0
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +57 -0
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +71 -0
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +60 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +6 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +5 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +30 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +12 -0
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +55 -0
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +63 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +6 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +47 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +14 -0
- package/.medusa/server/src/admin/components/placeholder-cell.js +7 -0
- package/.medusa/server/src/admin/components/product/product-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +15 -0
- package/.medusa/server/src/admin/components/product/product-status-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +18 -0
- package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +31 -0
- package/.medusa/server/src/admin/components/product/variant-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +15 -0
- package/.medusa/server/src/admin/components/section-row.js +32 -0
- package/.medusa/server/src/admin/components/sidebar-link.js +31 -0
- package/.medusa/server/src/admin/components/sortable-list.js +152 -0
- package/.medusa/server/src/admin/components/switch-box.js +43 -0
- package/.medusa/server/src/admin/components/tax-badge.js +18 -0
- package/.medusa/server/src/admin/components/thumbnail.js +28 -0
- package/.medusa/server/src/admin/components/upload-media-form-item.js +83 -0
- package/.medusa/server/src/admin/hooks/api/customers.js +26 -0
- package/.medusa/server/src/admin/hooks/api/gift-cards.js +107 -0
- package/.medusa/server/src/admin/hooks/api/order.js +16 -0
- package/.medusa/server/src/admin/hooks/api/price-preferences.js +19 -0
- package/.medusa/server/src/admin/hooks/api/products.js +127 -0
- package/.medusa/server/src/admin/hooks/api/regions.js +17 -0
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +28 -0
- package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +41 -0
- package/.medusa/server/src/admin/hooks/api/store.js +31 -0
- package/.medusa/server/src/admin/hooks/api/transaction-groups.js +23 -0
- package/.medusa/server/src/admin/hooks/api/transactions.js +23 -0
- package/.medusa/server/src/admin/hooks/commands/use-command-history.js +45 -0
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +59 -0
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +89 -0
- package/.medusa/server/src/admin/hooks/common/use-date.js +32 -0
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +22 -0
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +14 -0
- package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/sales-channels/index.js +10 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +48 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +19 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +23 -0
- package/.medusa/server/src/admin/lib/currencies.js +729 -0
- package/.medusa/server/src/admin/lib/query-key.js +17 -0
- package/.medusa/server/src/admin/lib/sdk.js +10 -0
- package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +75 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +172 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +30 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +180 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +30 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +97 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +162 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +89 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +199 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +353 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +5 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +247 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +5 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +48 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +14 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +28 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +40 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +121 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +72 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +123 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +1 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +98 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +28 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +96 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +90 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +288 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +111 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +285 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +124 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +112 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +1 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +35 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +11 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +61 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/page.js +18 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +137 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +87 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +352 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +116 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +49 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +177 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +27 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +33 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +33 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +18 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +50 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +78 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +40 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +57 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +13 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +61 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-cards/page.js +27 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +126 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +31 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +43 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +44 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +18 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +37 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +58 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +39 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +58 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +13 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +31 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +56 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +19 -0
- package/.medusa/server/src/admin/utils/date-utils.js +27 -0
- package/.medusa/server/src/admin/utils/format-amount.js +9 -0
- package/.medusa/server/src/admin/utils/format-date.js +21 -0
- package/.medusa/server/src/admin/utils/refs.js +20 -0
- package/.medusa/server/src/admin/utils/statuses.js +23 -0
- package/.medusa/server/src/admin/utils/validations.js +71 -0
- package/.medusa/server/src/admin/utils/variants.js +92 -0
- package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +67 -0
- package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +42 -0
- package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +58 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/redeem/route.js +25 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.js +41 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/transfer/route.js +24 -0
- package/.medusa/server/src/api/admin/gift-cards/middlewares.js +55 -0
- package/.medusa/server/src/api/admin/gift-cards/query-config.js +29 -0
- package/.medusa/server/src/api/admin/gift-cards/route.js +42 -0
- package/.medusa/server/src/api/admin/gift-cards/validators.js +69 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.js +24 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.js +23 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.js +38 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.js +43 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/route.js +52 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.js +51 -0
- package/.medusa/server/src/api/admin/transaction-groups/middlewares.js +16 -0
- package/.medusa/server/src/api/admin/transaction-groups/query-config.js +13 -0
- package/.medusa/server/src/api/admin/transaction-groups/route.js +27 -0
- package/.medusa/server/src/api/admin/transaction-groups/validators.js +19 -0
- package/.medusa/server/src/api/middlewares.js +22 -0
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.js +43 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +26 -0
- package/.medusa/server/src/api/store/carts/query-config.js +9 -0
- package/.medusa/server/src/api/store/carts/validators.js +15 -0
- package/.medusa/server/src/api/store/gift-card-invitations/[code]/accept/route.js +24 -0
- package/.medusa/server/src/api/store/gift-card-invitations/[code]/reject/route.js +24 -0
- package/.medusa/server/src/api/store/gift-card-invitations/middlewares.js +30 -0
- package/.medusa/server/src/api/store/gift-card-invitations/query-config.js +17 -0
- package/.medusa/server/src/api/store/gift-card-invitations/validators.js +14 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/invitation/route.js +26 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/redeem/route.js +24 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/route.js +16 -0
- package/.medusa/server/src/api/store/gift-cards/middlewares.js +46 -0
- package/.medusa/server/src/api/store/gift-cards/query-config.js +26 -0
- package/.medusa/server/src/api/store/gift-cards/route.js +28 -0
- package/.medusa/server/src/api/store/gift-cards/validators.js +26 -0
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.js +31 -0
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.js +28 -0
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.js +24 -0
- package/.medusa/server/src/api/store/store-credit-accounts/route.js +40 -0
- package/.medusa/server/src/api/store/store-credit-accounts/validators.js +17 -0
- package/.medusa/server/src/links/cart-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/customer-gift-card-link.js +13 -0
- package/.medusa/server/src/links/customer-store-credit-account-link.js +13 -0
- package/.medusa/server/src/links/order-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +19 -0
- package/.medusa/server/src/modules/loyalty/index.js +12 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.js +17 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.js +14 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.js +14 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card-invitation.js +20 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card.js +28 -0
- package/.medusa/server/src/modules/loyalty/service.js +15 -0
- package/.medusa/server/src/modules/store-credit/index.js +12 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.js +16 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.js +18 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.js +19 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.js +14 -0
- package/.medusa/server/src/modules/store-credit/models/account-transaction.js +27 -0
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.js +29 -0
- package/.medusa/server/src/modules/store-credit/models/transaction-group.js +28 -0
- package/.medusa/server/src/modules/store-credit/service.js +412 -0
- package/.medusa/server/src/providers/index.js +12 -0
- package/.medusa/server/src/providers/store-credit-payment/index.js +12 -0
- package/.medusa/server/src/providers/store-credit-payment/service.js +181 -0
- package/.medusa/server/src/subscribers/create-gift-card.js +94 -0
- package/.medusa/server/src/types/cart/index.js +3 -0
- package/.medusa/server/src/types/http/gift-card.js +3 -0
- package/.medusa/server/src/types/http/index.js +21 -0
- package/.medusa/server/src/types/http/store-credit-account.js +3 -0
- package/.medusa/server/src/types/http/transaction-group.js +3 -0
- package/.medusa/server/src/types/http/transaction.js +3 -0
- package/.medusa/server/src/types/index.js +21 -0
- package/.medusa/server/src/types/loyalty/index.js +20 -0
- package/.medusa/server/src/types/loyalty/module.js +17 -0
- package/.medusa/server/src/types/loyalty/service.js +3 -0
- package/.medusa/server/src/types/loyalty/workflows.js +3 -0
- package/.medusa/server/src/types/modules.js +14 -0
- package/.medusa/server/src/types/store-credit/index.js +19 -0
- package/.medusa/server/src/types/store-credit/module.js +10 -0
- package/.medusa/server/src/types/store-credit/service.js +3 -0
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.js +167 -0
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.js +95 -0
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.js +136 -0
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.js +66 -0
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.js +11 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/create-gift-card-invitation.js +17 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/delete-gift-card-invitation.js +20 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/update-gift-card-invitation.js +31 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/accept-gift-card-invitation.js +79 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/create-gift-card-invitation.js +66 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/delete-gift-card-invitation.js +10 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/reject-gift-card-invitation.js +70 -0
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.js +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.js +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.js +20 -0
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.js +34 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.js +12 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.js +19 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.js +90 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/transfer-gift-card.js +48 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.js +12 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +26 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +27 -0
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.js +58 -0
- package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +96 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-transaction-groups.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.js +17 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.js +57 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-transaction-groups.js +12 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.js +12 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.js +12 -0
- package/.medusa/server/types/loyalty/module.js +8 -0
- package/README.md +62 -0
- package/package.json +94 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@hookform/resolvers/zod/dist/zod.mjs";
|
|
3
|
+
import { toast, ProgressTabs, Button } from "@medusajs/ui";
|
|
4
|
+
import { useState, useMemo, useEffect } from "react";
|
|
5
|
+
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
6
|
+
import { KeyboundForm } from "../../../../components/keybound-form.js";
|
|
7
|
+
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
8
|
+
import { RouteFocusModal } from "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
9
|
+
import "react-router-dom";
|
|
10
|
+
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
11
|
+
import { useRouteModal } from "../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
12
|
+
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
13
|
+
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
14
|
+
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
15
|
+
import { useCreateProduct } from "../../../../hooks/api/products.js";
|
|
16
|
+
import { sdk } from "../../../../lib/sdk.js";
|
|
17
|
+
import { normalizeProductFormValues } from "../../../../utils/variants.js";
|
|
18
|
+
import { GiftCardProductCreateDenominationsForm } from "./gift-card-product-create-denominations-form.js";
|
|
19
|
+
import { GiftCardProductCreateDetailsForm } from "./gift-card-product-create-details-form.js";
|
|
20
|
+
import { PRODUCT_CREATE_FORM_DEFAULTS, ProductCreateSchema } from "./schema.js";
|
|
21
|
+
const SAVE_DRAFT_BUTTON = "save-draft-button";
|
|
22
|
+
const GiftCardProductCreateForm = ({
|
|
23
|
+
defaultChannel,
|
|
24
|
+
regions,
|
|
25
|
+
store,
|
|
26
|
+
pricePreferences
|
|
27
|
+
}) => {
|
|
28
|
+
const [tab, setTab] = useState(
|
|
29
|
+
"details"
|
|
30
|
+
/* DETAILS */
|
|
31
|
+
);
|
|
32
|
+
const [tabState, setTabState] = useState({
|
|
33
|
+
[
|
|
34
|
+
"details"
|
|
35
|
+
/* DETAILS */
|
|
36
|
+
]: "in-progress",
|
|
37
|
+
[
|
|
38
|
+
"prices"
|
|
39
|
+
/* PRICES */
|
|
40
|
+
]: "not-started"
|
|
41
|
+
});
|
|
42
|
+
const { handleSuccess } = useRouteModal();
|
|
43
|
+
const form = useForm({
|
|
44
|
+
defaultValues: {
|
|
45
|
+
...PRODUCT_CREATE_FORM_DEFAULTS,
|
|
46
|
+
sales_channels: defaultChannel ? [{ id: defaultChannel.id, name: defaultChannel.name }] : []
|
|
47
|
+
},
|
|
48
|
+
resolver: zodResolver(ProductCreateSchema)
|
|
49
|
+
});
|
|
50
|
+
const { mutateAsync, isPending } = useCreateProduct();
|
|
51
|
+
const regionsCurrencyMap = useMemo(() => {
|
|
52
|
+
if (!(regions == null ? void 0 : regions.length)) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
return regions.reduce((acc, reg) => {
|
|
56
|
+
acc[reg.id] = reg.currency_code;
|
|
57
|
+
return acc;
|
|
58
|
+
}, {});
|
|
59
|
+
}, [regions]);
|
|
60
|
+
const handleSubmit = form.handleSubmit(async (values, e) => {
|
|
61
|
+
var _a;
|
|
62
|
+
let isDraftSubmission = false;
|
|
63
|
+
if ((e == null ? void 0 : e.nativeEvent) instanceof SubmitEvent) {
|
|
64
|
+
const submitter = (_a = e == null ? void 0 : e.nativeEvent) == null ? void 0 : _a.submitter;
|
|
65
|
+
isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
|
|
66
|
+
}
|
|
67
|
+
const media = values.media || [];
|
|
68
|
+
const payload = { ...values, media: void 0 };
|
|
69
|
+
let uploadedMedia = [];
|
|
70
|
+
try {
|
|
71
|
+
if (media.length) {
|
|
72
|
+
const thumbnailReq = media.find((m) => m.isThumbnail);
|
|
73
|
+
const otherMediaReq = media.filter((m) => !m.isThumbnail);
|
|
74
|
+
const fileReqs = [];
|
|
75
|
+
if (thumbnailReq) {
|
|
76
|
+
fileReqs.push(
|
|
77
|
+
sdk.admin.upload.create({ files: [thumbnailReq.file] }).then((r) => r.files.map((f) => ({ ...f, isThumbnail: true })))
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
if (otherMediaReq == null ? void 0 : otherMediaReq.length) {
|
|
81
|
+
fileReqs.push(
|
|
82
|
+
sdk.admin.upload.create({
|
|
83
|
+
files: otherMediaReq.map((m) => m.file)
|
|
84
|
+
}).then((r) => r.files.map((f) => ({ ...f, isThumbnail: false })))
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
uploadedMedia = (await Promise.all(fileReqs)).flat();
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof Error) {
|
|
91
|
+
toast.error(error.message);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await mutateAsync(
|
|
95
|
+
normalizeProductFormValues({
|
|
96
|
+
...payload,
|
|
97
|
+
media: uploadedMedia,
|
|
98
|
+
status: isDraftSubmission ? "draft" : "published",
|
|
99
|
+
regionsCurrencyMap
|
|
100
|
+
}),
|
|
101
|
+
{
|
|
102
|
+
onSuccess: (data) => {
|
|
103
|
+
toast.success(
|
|
104
|
+
`Product ${data.product.title} was successfully created.`
|
|
105
|
+
);
|
|
106
|
+
handleSuccess(`../${data.product.id}`);
|
|
107
|
+
},
|
|
108
|
+
onError: (error) => {
|
|
109
|
+
toast.error(error.message);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
const onNext = async (currentTab) => {
|
|
115
|
+
const valid = await form.trigger();
|
|
116
|
+
if (!valid) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (currentTab === "details") {
|
|
120
|
+
setTab(
|
|
121
|
+
"prices"
|
|
122
|
+
/* PRICES */
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
const currentState = { ...tabState };
|
|
128
|
+
if (tab === "details") {
|
|
129
|
+
currentState[
|
|
130
|
+
"details"
|
|
131
|
+
/* DETAILS */
|
|
132
|
+
] = "in-progress";
|
|
133
|
+
}
|
|
134
|
+
if (tab === "prices") {
|
|
135
|
+
currentState[
|
|
136
|
+
"details"
|
|
137
|
+
/* DETAILS */
|
|
138
|
+
] = "completed";
|
|
139
|
+
currentState[
|
|
140
|
+
"prices"
|
|
141
|
+
/* PRICES */
|
|
142
|
+
] = "in-progress";
|
|
143
|
+
}
|
|
144
|
+
setTabState({ ...currentState });
|
|
145
|
+
}, [tab]);
|
|
146
|
+
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
147
|
+
KeyboundForm,
|
|
148
|
+
{
|
|
149
|
+
onKeyDown: (e) => {
|
|
150
|
+
if (e.key === "Enter") {
|
|
151
|
+
if (e.target instanceof HTMLTextAreaElement && !(e.metaKey || e.ctrlKey)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
if (e.metaKey || e.ctrlKey) {
|
|
156
|
+
if (tab !== "prices") {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
onNext(tab);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
handleSubmit();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
onSubmit: handleSubmit,
|
|
167
|
+
className: "flex h-full flex-col",
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsxs(
|
|
170
|
+
ProgressTabs,
|
|
171
|
+
{
|
|
172
|
+
value: tab,
|
|
173
|
+
onValueChange: async (tab2) => {
|
|
174
|
+
const valid = await form.trigger();
|
|
175
|
+
if (!valid) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setTab(tab2);
|
|
179
|
+
},
|
|
180
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsx("div", { className: "-my-2 w-full border-l", children: /* @__PURE__ */ jsxs(ProgressTabs.List, { className: "justify-start-start flex w-full items-center", children: [
|
|
183
|
+
/* @__PURE__ */ jsx(
|
|
184
|
+
ProgressTabs.Trigger,
|
|
185
|
+
{
|
|
186
|
+
status: tabState[
|
|
187
|
+
"details"
|
|
188
|
+
/* DETAILS */
|
|
189
|
+
],
|
|
190
|
+
value: "details",
|
|
191
|
+
className: "max-w-[200px] truncate",
|
|
192
|
+
children: "Details"
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ jsx(
|
|
196
|
+
ProgressTabs.Trigger,
|
|
197
|
+
{
|
|
198
|
+
status: tabState[
|
|
199
|
+
"prices"
|
|
200
|
+
/* PRICES */
|
|
201
|
+
],
|
|
202
|
+
value: "prices",
|
|
203
|
+
className: "max-w-[200px] truncate",
|
|
204
|
+
children: "Prices"
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] }) }) }),
|
|
208
|
+
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: [
|
|
209
|
+
/* @__PURE__ */ jsx(
|
|
210
|
+
ProgressTabs.Content,
|
|
211
|
+
{
|
|
212
|
+
className: "size-full overflow-y-auto",
|
|
213
|
+
value: "details",
|
|
214
|
+
children: /* @__PURE__ */ jsx(GiftCardProductCreateDetailsForm, { form })
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ jsx(
|
|
218
|
+
ProgressTabs.Content,
|
|
219
|
+
{
|
|
220
|
+
className: "size-full overflow-y-auto",
|
|
221
|
+
value: "prices",
|
|
222
|
+
children: /* @__PURE__ */ jsx(
|
|
223
|
+
GiftCardProductCreateDenominationsForm,
|
|
224
|
+
{
|
|
225
|
+
form,
|
|
226
|
+
store,
|
|
227
|
+
regions,
|
|
228
|
+
pricePreferences
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
] })
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
238
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
239
|
+
/* @__PURE__ */ jsx(
|
|
240
|
+
Button,
|
|
241
|
+
{
|
|
242
|
+
"data-name": SAVE_DRAFT_BUTTON,
|
|
243
|
+
size: "small",
|
|
244
|
+
type: "submit",
|
|
245
|
+
isLoading: isPending,
|
|
246
|
+
className: "whitespace-nowrap",
|
|
247
|
+
children: "Save as draft"
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx(PrimaryButton, { tab, next: onNext, isLoading: isPending })
|
|
251
|
+
] }) })
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
) });
|
|
255
|
+
};
|
|
256
|
+
const PrimaryButton = ({ tab, next, isLoading }) => {
|
|
257
|
+
if (tab === "prices") {
|
|
258
|
+
return /* @__PURE__ */ jsx(
|
|
259
|
+
Button,
|
|
260
|
+
{
|
|
261
|
+
"data-name": "publish-button",
|
|
262
|
+
type: "submit",
|
|
263
|
+
variant: "primary",
|
|
264
|
+
size: "small",
|
|
265
|
+
isLoading,
|
|
266
|
+
children: "Publish"
|
|
267
|
+
},
|
|
268
|
+
"submit-button"
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return /* @__PURE__ */ jsx(
|
|
272
|
+
Button,
|
|
273
|
+
{
|
|
274
|
+
type: "button",
|
|
275
|
+
variant: "primary",
|
|
276
|
+
size: "small",
|
|
277
|
+
onClick: () => next(tab),
|
|
278
|
+
children: "Continue"
|
|
279
|
+
},
|
|
280
|
+
"next-button"
|
|
281
|
+
);
|
|
282
|
+
};
|
|
283
|
+
export {
|
|
284
|
+
GiftCardProductCreateForm
|
|
285
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createDataTableColumnHelper, Button } from "@medusajs/ui";
|
|
3
|
+
import { useState, useEffect, useMemo } from "react";
|
|
4
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
5
|
+
import { DataTable } from "../../../../components/data-table.js";
|
|
6
|
+
import { useSalesChannelTableColumns } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js";
|
|
7
|
+
import { useSalesChannelTableEmptyState } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js";
|
|
8
|
+
import { useSalesChannelTableFilters } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js";
|
|
9
|
+
import { useSalesChannelTableQuery } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-query.js";
|
|
10
|
+
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
11
|
+
import "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
12
|
+
import "react-router-dom";
|
|
13
|
+
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
14
|
+
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
15
|
+
import { StackedFocusModal } from "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
16
|
+
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
17
|
+
import { useStackedModal } from "../../../../components/modals/stacked-modal-provider/use-stacked-modal.js";
|
|
18
|
+
import { useSalesChannels } from "../../../../hooks/api/sales-channels.js";
|
|
19
|
+
import { SC_STACKED_MODAL_ID } from "./schema.js";
|
|
20
|
+
const PAGE_SIZE = 50;
|
|
21
|
+
const GiftCardProductSalesChannelStackedModal = ({
|
|
22
|
+
form
|
|
23
|
+
}) => {
|
|
24
|
+
const { getValues, setValue } = form;
|
|
25
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
26
|
+
const [rowSelection, setRowSelection] = useState(
|
|
27
|
+
{}
|
|
28
|
+
);
|
|
29
|
+
const [state, setState] = useState([]);
|
|
30
|
+
const searchParams = useSalesChannelTableQuery({
|
|
31
|
+
pageSize: PAGE_SIZE,
|
|
32
|
+
prefix: SC_STACKED_MODAL_ID
|
|
33
|
+
});
|
|
34
|
+
const { sales_channels, count, isLoading, isError, error } = useSalesChannels(
|
|
35
|
+
searchParams,
|
|
36
|
+
{ placeholderData: keepPreviousData }
|
|
37
|
+
);
|
|
38
|
+
const open = getIsOpen(SC_STACKED_MODAL_ID);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!open) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const salesChannels = getValues("sales_channels");
|
|
44
|
+
if (salesChannels) {
|
|
45
|
+
setState(
|
|
46
|
+
salesChannels.map((channel) => ({
|
|
47
|
+
id: channel.id,
|
|
48
|
+
name: channel.name
|
|
49
|
+
}))
|
|
50
|
+
);
|
|
51
|
+
setRowSelection(
|
|
52
|
+
salesChannels.reduce(
|
|
53
|
+
(acc, channel) => ({
|
|
54
|
+
...acc,
|
|
55
|
+
[channel.id]: true
|
|
56
|
+
}),
|
|
57
|
+
{}
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}, [open, getValues]);
|
|
62
|
+
const onRowSelectionChange = (state2) => {
|
|
63
|
+
const ids = Object.keys(state2);
|
|
64
|
+
const addedIdsSet = new Set(
|
|
65
|
+
ids.filter((id) => state2[id] && !rowSelection[id])
|
|
66
|
+
);
|
|
67
|
+
let addedSalesChannels = [];
|
|
68
|
+
if (addedIdsSet.size > 0) {
|
|
69
|
+
addedSalesChannels = (sales_channels == null ? void 0 : sales_channels.filter((channel) => addedIdsSet.has(channel.id))) ?? [];
|
|
70
|
+
}
|
|
71
|
+
setState((prev) => {
|
|
72
|
+
const filteredPrev = prev.filter((channel) => state2[channel.id]);
|
|
73
|
+
return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedSalesChannels]));
|
|
74
|
+
});
|
|
75
|
+
setRowSelection(state2);
|
|
76
|
+
};
|
|
77
|
+
const handleAdd = () => {
|
|
78
|
+
setValue("sales_channels", state, {
|
|
79
|
+
shouldDirty: true,
|
|
80
|
+
shouldTouch: true
|
|
81
|
+
});
|
|
82
|
+
setIsOpen(SC_STACKED_MODAL_ID, false);
|
|
83
|
+
};
|
|
84
|
+
const filters = useSalesChannelTableFilters();
|
|
85
|
+
const columns = useColumns();
|
|
86
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
87
|
+
if (isError) {
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
return /* @__PURE__ */ jsxs(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
|
|
91
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
|
|
92
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
93
|
+
DataTable,
|
|
94
|
+
{
|
|
95
|
+
data: sales_channels,
|
|
96
|
+
columns,
|
|
97
|
+
filters,
|
|
98
|
+
emptyState,
|
|
99
|
+
rowCount: count,
|
|
100
|
+
pageSize: PAGE_SIZE,
|
|
101
|
+
getRowId: (row) => row.id,
|
|
102
|
+
rowSelection: {
|
|
103
|
+
state: rowSelection,
|
|
104
|
+
onRowSelectionChange
|
|
105
|
+
},
|
|
106
|
+
isLoading,
|
|
107
|
+
layout: "fill",
|
|
108
|
+
prefix: SC_STACKED_MODAL_ID
|
|
109
|
+
}
|
|
110
|
+
) }),
|
|
111
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
112
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
113
|
+
/* @__PURE__ */ jsx(Button, { size: "small", onClick: handleAdd, type: "button", children: "Save" })
|
|
114
|
+
] }) })
|
|
115
|
+
] });
|
|
116
|
+
};
|
|
117
|
+
const columnHelper = createDataTableColumnHelper();
|
|
118
|
+
const useColumns = () => {
|
|
119
|
+
const base = useSalesChannelTableColumns();
|
|
120
|
+
return useMemo(() => [columnHelper.select(), ...base], [base]);
|
|
121
|
+
};
|
|
122
|
+
export {
|
|
123
|
+
GiftCardProductSalesChannelStackedModal
|
|
124
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
2
|
+
import { optionalInt, optionalFloat } from "../../../../utils/validations.js";
|
|
3
|
+
const SC_STACKED_MODAL_ID = "sc";
|
|
4
|
+
const MediaSchema = z.object({
|
|
5
|
+
id: z.string().optional(),
|
|
6
|
+
url: z.string(),
|
|
7
|
+
isThumbnail: z.boolean(),
|
|
8
|
+
file: z.any().nullable()
|
|
9
|
+
// File
|
|
10
|
+
});
|
|
11
|
+
z.object({
|
|
12
|
+
should_create: z.boolean(),
|
|
13
|
+
is_default: z.boolean().optional(),
|
|
14
|
+
title: z.string(),
|
|
15
|
+
upc: z.string().optional(),
|
|
16
|
+
ean: z.string().optional(),
|
|
17
|
+
barcode: z.string().optional(),
|
|
18
|
+
mid_code: z.string().optional(),
|
|
19
|
+
hs_code: z.string().optional(),
|
|
20
|
+
width: optionalInt,
|
|
21
|
+
height: optionalInt,
|
|
22
|
+
length: optionalInt,
|
|
23
|
+
weight: optionalInt,
|
|
24
|
+
material: z.string().optional(),
|
|
25
|
+
origin_country: z.string().optional(),
|
|
26
|
+
sku: z.string().optional(),
|
|
27
|
+
manage_inventory: z.boolean().optional(),
|
|
28
|
+
allow_backorder: z.boolean().optional(),
|
|
29
|
+
inventory_kit: z.boolean().optional(),
|
|
30
|
+
options: z.record(z.string(), z.string()),
|
|
31
|
+
variant_rank: z.number(),
|
|
32
|
+
prices: z.record(z.string(), optionalFloat).optional(),
|
|
33
|
+
inventory: z.array(
|
|
34
|
+
z.object({
|
|
35
|
+
inventory_item_id: z.string(),
|
|
36
|
+
required_quantity: optionalInt
|
|
37
|
+
})
|
|
38
|
+
).optional()
|
|
39
|
+
});
|
|
40
|
+
z.object({
|
|
41
|
+
title: z.string(),
|
|
42
|
+
values: z.array(z.string()).min(1)
|
|
43
|
+
});
|
|
44
|
+
const ProductCreateSchema = z.object({
|
|
45
|
+
title: z.string().min(1),
|
|
46
|
+
subtitle: z.string().optional(),
|
|
47
|
+
handle: z.string().optional(),
|
|
48
|
+
description: z.string().optional(),
|
|
49
|
+
discountable: z.boolean(),
|
|
50
|
+
type_id: z.string().optional(),
|
|
51
|
+
collection_id: z.string().optional(),
|
|
52
|
+
shipping_profile_id: z.string().optional(),
|
|
53
|
+
categories: z.array(z.string()),
|
|
54
|
+
tags: z.array(z.string()).optional(),
|
|
55
|
+
sales_channels: z.array(
|
|
56
|
+
z.object({
|
|
57
|
+
id: z.string(),
|
|
58
|
+
name: z.string()
|
|
59
|
+
})
|
|
60
|
+
).optional(),
|
|
61
|
+
origin_country: z.string().optional(),
|
|
62
|
+
material: z.string().optional(),
|
|
63
|
+
width: z.string().optional(),
|
|
64
|
+
length: z.string().optional(),
|
|
65
|
+
height: z.string().optional(),
|
|
66
|
+
weight: z.string().optional(),
|
|
67
|
+
mid_code: z.string().optional(),
|
|
68
|
+
hs_code: z.string().optional(),
|
|
69
|
+
denominations: z.array(
|
|
70
|
+
z.object({
|
|
71
|
+
value: z.string().min(1),
|
|
72
|
+
sku: z.string().optional(),
|
|
73
|
+
prices: z.record(z.string(), optionalFloat).optional()
|
|
74
|
+
})
|
|
75
|
+
).min(1),
|
|
76
|
+
enable_variants: z.boolean(),
|
|
77
|
+
media: z.array(MediaSchema).optional()
|
|
78
|
+
});
|
|
79
|
+
const EditProductMediaSchema = z.object({
|
|
80
|
+
media: z.array(MediaSchema)
|
|
81
|
+
});
|
|
82
|
+
const PRODUCT_CREATE_FORM_DEFAULTS = {
|
|
83
|
+
discountable: true,
|
|
84
|
+
tags: [],
|
|
85
|
+
sales_channels: [],
|
|
86
|
+
denominations: [],
|
|
87
|
+
enable_variants: true,
|
|
88
|
+
media: [],
|
|
89
|
+
categories: [],
|
|
90
|
+
collection_id: "",
|
|
91
|
+
shipping_profile_id: "",
|
|
92
|
+
description: "",
|
|
93
|
+
handle: "",
|
|
94
|
+
height: "",
|
|
95
|
+
hs_code: "",
|
|
96
|
+
length: "",
|
|
97
|
+
material: "",
|
|
98
|
+
mid_code: "",
|
|
99
|
+
origin_country: "",
|
|
100
|
+
subtitle: "",
|
|
101
|
+
title: "",
|
|
102
|
+
type_id: "",
|
|
103
|
+
weight: "",
|
|
104
|
+
width: ""
|
|
105
|
+
};
|
|
106
|
+
export {
|
|
107
|
+
EditProductMediaSchema,
|
|
108
|
+
MediaSchema,
|
|
109
|
+
PRODUCT_CREATE_FORM_DEFAULTS,
|
|
110
|
+
ProductCreateSchema,
|
|
111
|
+
SC_STACKED_MODAL_ID
|
|
112
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createColumnHelper } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@tanstack/react-table/build/lib/index.mjs";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { ProductCell, ProductHeader } from "../../../../components/product/product-cell/product-cell.js";
|
|
5
|
+
import { ProductStatusCell, ProductStatusHeader } from "../../../../components/product/product-status-cell/product-status-cell.js";
|
|
6
|
+
import { SalesChannelsCell, SalesChannelHeader } from "../../../../components/product/sales-channels-cell/sales-channels-cell.js";
|
|
7
|
+
import { VariantCell, VariantHeader } from "../../../../components/product/variant-cell/variant-cell.js";
|
|
8
|
+
const columnHelper = createColumnHelper();
|
|
9
|
+
const useGiftCardProductsTableColumns = () => {
|
|
10
|
+
return useMemo(
|
|
11
|
+
() => [
|
|
12
|
+
columnHelper.display({
|
|
13
|
+
id: "product",
|
|
14
|
+
header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
|
|
15
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(ProductCell, { product: row.original })
|
|
16
|
+
}),
|
|
17
|
+
columnHelper.accessor("sales_channels", {
|
|
18
|
+
header: () => /* @__PURE__ */ jsx(SalesChannelHeader, {}),
|
|
19
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(SalesChannelsCell, { salesChannels: row.original.sales_channels })
|
|
20
|
+
}),
|
|
21
|
+
columnHelper.accessor("variants", {
|
|
22
|
+
header: () => /* @__PURE__ */ jsx(VariantHeader, {}),
|
|
23
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(VariantCell, { variants: row.original.variants })
|
|
24
|
+
}),
|
|
25
|
+
columnHelper.accessor("status", {
|
|
26
|
+
header: () => /* @__PURE__ */ jsx(ProductStatusHeader, {}),
|
|
27
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(ProductStatusCell, { status: row.original.status })
|
|
28
|
+
})
|
|
29
|
+
],
|
|
30
|
+
[]
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
useGiftCardProductsTableColumns
|
|
35
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useDataTableDateFilters } from "../../../../hooks/common/use-data-table-date-filters.js";
|
|
3
|
+
const useGiftCardProductsFilters = () => {
|
|
4
|
+
const dateFilterOptions = useDataTableDateFilters();
|
|
5
|
+
return useMemo(() => {
|
|
6
|
+
return [...dateFilterOptions];
|
|
7
|
+
}, [dateFilterOptions]);
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
useGiftCardProductsFilters
|
|
11
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Container } from "@medusajs/ui";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { Outlet } from "react-router-dom";
|
|
5
|
+
import { DataTable } from "../../../../components/data-table.js";
|
|
6
|
+
import { useProducts } from "../../../../hooks/api/products.js";
|
|
7
|
+
import { useGiftCardProductsTableColumns } from "./columns.js";
|
|
8
|
+
import { useGiftCardProductsFilters } from "./filters.js";
|
|
9
|
+
import { useGiftCardProductsTableQuery } from "./query.js";
|
|
10
|
+
const PAGE_SIZE = 10;
|
|
11
|
+
function GiftCardProductsTable() {
|
|
12
|
+
const queryParams = useGiftCardProductsTableQuery({
|
|
13
|
+
pageSize: PAGE_SIZE
|
|
14
|
+
});
|
|
15
|
+
const {
|
|
16
|
+
products: giftCardProducts,
|
|
17
|
+
isPending,
|
|
18
|
+
count
|
|
19
|
+
} = useProducts({
|
|
20
|
+
...queryParams,
|
|
21
|
+
is_giftcard: true,
|
|
22
|
+
order: queryParams.order ?? "-created_at"
|
|
23
|
+
});
|
|
24
|
+
const columns = useGiftCardProductsTableColumns();
|
|
25
|
+
const filters = useGiftCardProductsFilters();
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Container, { className: "p-0", children: /* @__PURE__ */ jsx(
|
|
28
|
+
DataTable,
|
|
29
|
+
{
|
|
30
|
+
data: giftCardProducts,
|
|
31
|
+
getRowId: (row) => row.id,
|
|
32
|
+
columns,
|
|
33
|
+
filters,
|
|
34
|
+
isLoading: isPending,
|
|
35
|
+
pageSize: PAGE_SIZE,
|
|
36
|
+
rowCount: count,
|
|
37
|
+
enableSearch: false,
|
|
38
|
+
heading: "Gift Card Products",
|
|
39
|
+
action: {
|
|
40
|
+
label: "Create gift card product",
|
|
41
|
+
to: "create"
|
|
42
|
+
},
|
|
43
|
+
rowHref: (row) => `${row.id}`,
|
|
44
|
+
emptyState: {
|
|
45
|
+
empty: {
|
|
46
|
+
heading: "No gift card products found",
|
|
47
|
+
description: "Create a new gift card product to get started."
|
|
48
|
+
},
|
|
49
|
+
filtered: {
|
|
50
|
+
heading: "No results found",
|
|
51
|
+
description: "No gift card products match your filter criteria."
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
) }),
|
|
56
|
+
/* @__PURE__ */ jsx(Outlet, {})
|
|
57
|
+
] });
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
GiftCardProductsTable
|
|
61
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQueryParams } from "../../../../hooks/common/use-query-params.js";
|
|
2
|
+
const useGiftCardProductsTableQuery = ({
|
|
3
|
+
prefix,
|
|
4
|
+
pageSize = 20
|
|
5
|
+
}) => {
|
|
6
|
+
const queryObject = useQueryParams(
|
|
7
|
+
["offset", "customer_id", "created_at", "updated_at"],
|
|
8
|
+
prefix
|
|
9
|
+
);
|
|
10
|
+
const { offset, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
11
|
+
const searchParams = {
|
|
12
|
+
limit: pageSize,
|
|
13
|
+
offset: offset ? Number(offset) : 0,
|
|
14
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
15
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
16
|
+
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
17
|
+
...rest
|
|
18
|
+
};
|
|
19
|
+
return searchParams;
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useGiftCardProductsTableQuery
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
|
+
import { Toaster } from "@medusajs/ui";
|
|
4
|
+
import { GiftCardProductsTable } from "./components/gift-card-products-table/gift-card-products-table.js";
|
|
5
|
+
const GiftCardProductsPage = () => {
|
|
6
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7
|
+
/* @__PURE__ */ jsx(GiftCardProductsTable, {}),
|
|
8
|
+
/* @__PURE__ */ jsx(Toaster, {})
|
|
9
|
+
] });
|
|
10
|
+
};
|
|
11
|
+
const config = defineRouteConfig({
|
|
12
|
+
label: "Gift Cards",
|
|
13
|
+
nested: "/products"
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
config,
|
|
17
|
+
GiftCardProductsPage as default
|
|
18
|
+
};
|