@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
package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PencilSquare, ThumbnailBadge } from "@medusajs/icons";
|
|
3
|
+
import { usePrompt, Container, Heading, clx, Checkbox, Tooltip, Text, Button, CommandBar } from "@medusajs/ui";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
7
|
+
import { useUpdateProduct } from "../../../../hooks/api/products.js";
|
|
8
|
+
const ProductMediaSection = ({ product }) => {
|
|
9
|
+
const prompt = usePrompt();
|
|
10
|
+
const [selection, setSelection] = useState({});
|
|
11
|
+
const media = getMedia(product);
|
|
12
|
+
const handleCheckedChange = (id) => {
|
|
13
|
+
setSelection((prev) => {
|
|
14
|
+
if (prev[id]) {
|
|
15
|
+
const { [id]: _, ...rest } = prev;
|
|
16
|
+
return rest;
|
|
17
|
+
} else {
|
|
18
|
+
return { ...prev, [id]: true };
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const { mutateAsync } = useUpdateProduct(product.id);
|
|
23
|
+
const handleDelete = async () => {
|
|
24
|
+
const ids = Object.keys(selection);
|
|
25
|
+
const includingThumbnail = ids.some(
|
|
26
|
+
(id) => {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = media.find((m) => m.id === id)) == null ? void 0 : _a.isThumbnail;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
const res = await prompt({
|
|
32
|
+
title: "Are you sure?",
|
|
33
|
+
description: includingThumbnail ? `Deleting ${ids.length} image(s) including the thumbnail. This will remove the thumbnail from the product.` : `Deleting ${ids.length} image(s).`,
|
|
34
|
+
confirmText: "Delete",
|
|
35
|
+
cancelText: "Cancel"
|
|
36
|
+
});
|
|
37
|
+
if (!res) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const mediaToKeep = ((product == null ? void 0 : product.images) || []).filter((i) => !ids.includes(i.id)).map((i) => ({ url: i.url }));
|
|
41
|
+
await mutateAsync(
|
|
42
|
+
{
|
|
43
|
+
images: mediaToKeep,
|
|
44
|
+
thumbnail: includingThumbnail ? "" : void 0
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
onSuccess: () => {
|
|
48
|
+
setSelection({});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
54
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
55
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Media" }),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
ActionMenu,
|
|
58
|
+
{
|
|
59
|
+
groups: [
|
|
60
|
+
{
|
|
61
|
+
actions: [
|
|
62
|
+
{
|
|
63
|
+
label: "Edit",
|
|
64
|
+
to: "media?view=edit",
|
|
65
|
+
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
] }),
|
|
73
|
+
media.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-4 px-6 py-4", children: media.map((i, index) => {
|
|
74
|
+
const isSelected = selection[i.id];
|
|
75
|
+
return /* @__PURE__ */ jsxs(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: "shadow-elevation-card-rest hover:shadow-elevation-card-hover transition-fg group relative aspect-square size-full cursor-pointer overflow-hidden rounded-[8px]",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: clx(
|
|
84
|
+
"transition-fg invisible absolute right-2 top-2 opacity-0 group-hover:visible group-hover:opacity-100",
|
|
85
|
+
{
|
|
86
|
+
"visible opacity-100": isSelected
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
children: /* @__PURE__ */ jsx(
|
|
90
|
+
Checkbox,
|
|
91
|
+
{
|
|
92
|
+
checked: selection[i.id] || false,
|
|
93
|
+
onCheckedChange: () => handleCheckedChange(i.id)
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
i.isThumbnail && /* @__PURE__ */ jsx("div", { className: "absolute left-2 top-2", children: /* @__PURE__ */ jsx(Tooltip, { content: "Thumbnail", children: /* @__PURE__ */ jsx(ThumbnailBadge, {}) }) }),
|
|
99
|
+
/* @__PURE__ */ jsx(Link, { to: `media`, state: { curr: index }, children: /* @__PURE__ */ jsx(
|
|
100
|
+
"img",
|
|
101
|
+
{
|
|
102
|
+
src: i.url,
|
|
103
|
+
alt: `${product.title} image`,
|
|
104
|
+
className: "size-full object-cover"
|
|
105
|
+
}
|
|
106
|
+
) })
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
i.id
|
|
110
|
+
);
|
|
111
|
+
}) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-y-4 pb-8 pt-6", children: [
|
|
112
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
Text,
|
|
115
|
+
{
|
|
116
|
+
size: "small",
|
|
117
|
+
leading: "compact",
|
|
118
|
+
weight: "plus",
|
|
119
|
+
className: "text-ui-fg-subtle",
|
|
120
|
+
children: "No media yet"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Add images to your product" })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "media?view=edit", children: "Add images" }) })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsx(CommandBar, { open: !!Object.keys(selection).length, children: /* @__PURE__ */ jsxs(CommandBar.Bar, { children: [
|
|
128
|
+
/* @__PURE__ */ jsxs(CommandBar.Value, { children: [
|
|
129
|
+
Object.keys(selection).length,
|
|
130
|
+
" selected"
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsx(CommandBar.Seperator, {}),
|
|
133
|
+
/* @__PURE__ */ jsx(
|
|
134
|
+
CommandBar.Command,
|
|
135
|
+
{
|
|
136
|
+
action: handleDelete,
|
|
137
|
+
label: "Delete",
|
|
138
|
+
shortcut: "d"
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
] }) })
|
|
142
|
+
] });
|
|
143
|
+
};
|
|
144
|
+
const getMedia = (product) => {
|
|
145
|
+
const { images = [], thumbnail } = product;
|
|
146
|
+
const media = (images || []).map((image) => ({
|
|
147
|
+
id: image.id,
|
|
148
|
+
url: image.url,
|
|
149
|
+
isThumbnail: image.url === thumbnail
|
|
150
|
+
}));
|
|
151
|
+
if (thumbnail && !media.some((mediaItem) => mediaItem.url === thumbnail)) {
|
|
152
|
+
media.unshift({
|
|
153
|
+
id: "img_thumbnail",
|
|
154
|
+
url: thumbnail,
|
|
155
|
+
isThumbnail: true
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return media;
|
|
159
|
+
};
|
|
160
|
+
export {
|
|
161
|
+
ProductMediaSection
|
|
162
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PencilSquare, Channels } from "@medusajs/icons";
|
|
3
|
+
import { Container, Heading, Text, Tooltip } from "@medusajs/ui";
|
|
4
|
+
import { Trans } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-i18next/dist/es/index.js";
|
|
5
|
+
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
6
|
+
import { useSalesChannels } from "../../../../hooks/api/sales-channels.js";
|
|
7
|
+
const ProductSalesChannelSection = ({
|
|
8
|
+
product
|
|
9
|
+
}) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const { count } = useSalesChannels();
|
|
12
|
+
const availableInSalesChannels = ((_a = product.sales_channels) == null ? void 0 : _a.map((sc) => ({
|
|
13
|
+
id: sc.id,
|
|
14
|
+
name: sc.name
|
|
15
|
+
}))) ?? [];
|
|
16
|
+
const firstChannels = availableInSalesChannels.slice(0, 3);
|
|
17
|
+
const restChannels = availableInSalesChannels.slice(3);
|
|
18
|
+
return /* @__PURE__ */ jsxs(Container, { className: "flex flex-col gap-y-4 px-6 py-4", children: [
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
20
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Sales Channels" }),
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
ActionMenu,
|
|
23
|
+
{
|
|
24
|
+
groups: [
|
|
25
|
+
{
|
|
26
|
+
actions: [
|
|
27
|
+
{
|
|
28
|
+
label: "Edit",
|
|
29
|
+
to: "sales-channels",
|
|
30
|
+
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
] }),
|
|
38
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[28px_1fr] items-center gap-x-3", children: [
|
|
39
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]", children: /* @__PURE__ */ jsx(Channels, { className: "text-ui-fg-subtle" }) }) }),
|
|
40
|
+
availableInSalesChannels.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
41
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: firstChannels.map((sc) => sc.name).join(", ") }),
|
|
42
|
+
restChannels.length > 0 && /* @__PURE__ */ jsx(
|
|
43
|
+
Tooltip,
|
|
44
|
+
{
|
|
45
|
+
content: /* @__PURE__ */ jsx("ul", { children: restChannels.map((sc) => /* @__PURE__ */ jsx("li", { children: sc.name }, sc.id)) }),
|
|
46
|
+
children: /* @__PURE__ */ jsx(
|
|
47
|
+
Text,
|
|
48
|
+
{
|
|
49
|
+
size: "small",
|
|
50
|
+
leading: "compact",
|
|
51
|
+
className: "text-ui-fg-subtle",
|
|
52
|
+
children: `+${restChannels.length}`
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] }) : /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: "No sales channels" })
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: /* @__PURE__ */ jsx(
|
|
60
|
+
Trans,
|
|
61
|
+
{
|
|
62
|
+
i18nKey: "sales_channels.availableIn",
|
|
63
|
+
values: {
|
|
64
|
+
x: availableInSalesChannels.length,
|
|
65
|
+
y: count ?? 0
|
|
66
|
+
},
|
|
67
|
+
components: [
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
"span",
|
|
70
|
+
{
|
|
71
|
+
className: "text-ui-fg-base txt-compact-medium-plus"
|
|
72
|
+
},
|
|
73
|
+
"x"
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"span",
|
|
77
|
+
{
|
|
78
|
+
className: "text-ui-fg-base txt-compact-medium-plus"
|
|
79
|
+
},
|
|
80
|
+
"y"
|
|
81
|
+
)
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
) }) })
|
|
85
|
+
] });
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
ProductSalesChannelSection
|
|
89
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PencilSquare, Trash } from "@medusajs/icons";
|
|
3
|
+
import { createDataTableColumnHelper, Container, usePrompt, Tooltip, Badge } from "@medusajs/ui";
|
|
4
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
5
|
+
import { useMemo, useCallback } from "react";
|
|
6
|
+
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
7
|
+
import { DataTable } from "../../../../components/data-table.js";
|
|
8
|
+
import { useDataTableDateColumns } from "../../../../components/data-table/helpers/general/use-data-table-date-columns.js";
|
|
9
|
+
import { useProductVariants, useDeleteVariantLazy } from "../../../../hooks/api/products.js";
|
|
10
|
+
import { useDataTableDateFilters } from "../../../../hooks/common/use-data-table-date-filters.js";
|
|
11
|
+
import { useQueryParams } from "../../../../hooks/common/use-query-params.js";
|
|
12
|
+
const PAGE_SIZE = 10;
|
|
13
|
+
const PREFIX = "pv";
|
|
14
|
+
const ProductVariantSection = ({
|
|
15
|
+
product
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
q,
|
|
19
|
+
order,
|
|
20
|
+
offset,
|
|
21
|
+
allow_backorder,
|
|
22
|
+
manage_inventory,
|
|
23
|
+
created_at,
|
|
24
|
+
updated_at
|
|
25
|
+
} = useQueryParams(
|
|
26
|
+
[
|
|
27
|
+
"q",
|
|
28
|
+
"order",
|
|
29
|
+
"offset",
|
|
30
|
+
"manage_inventory",
|
|
31
|
+
"allow_backorder",
|
|
32
|
+
"created_at",
|
|
33
|
+
"updated_at"
|
|
34
|
+
],
|
|
35
|
+
PREFIX
|
|
36
|
+
);
|
|
37
|
+
const columns = useColumns(product);
|
|
38
|
+
const filters = useFilters();
|
|
39
|
+
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
40
|
+
product.id,
|
|
41
|
+
{
|
|
42
|
+
q,
|
|
43
|
+
order: order ? order : "variant_rank",
|
|
44
|
+
offset: offset ? parseInt(offset) : void 0,
|
|
45
|
+
limit: PAGE_SIZE,
|
|
46
|
+
allow_backorder: allow_backorder ? JSON.parse(allow_backorder) : void 0,
|
|
47
|
+
manage_inventory: manage_inventory ? JSON.parse(manage_inventory) : void 0,
|
|
48
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
49
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
50
|
+
fields: "title,sku,*options,created_at,updated_at"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
placeholderData: keepPreviousData
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
if (isError) {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsx(Container, { className: "divide-y p-0", children: /* @__PURE__ */ jsx(
|
|
60
|
+
DataTable,
|
|
61
|
+
{
|
|
62
|
+
data: variants,
|
|
63
|
+
columns,
|
|
64
|
+
filters,
|
|
65
|
+
rowCount: count,
|
|
66
|
+
getRowId: (row) => row.id,
|
|
67
|
+
pageSize: PAGE_SIZE,
|
|
68
|
+
isLoading: isPending,
|
|
69
|
+
heading: "Denominations",
|
|
70
|
+
emptyState: {
|
|
71
|
+
empty: {
|
|
72
|
+
heading: "No denominations",
|
|
73
|
+
description: "Add a denomination to get started"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
action: {
|
|
77
|
+
label: "Edit denomination",
|
|
78
|
+
to: `denominations`
|
|
79
|
+
},
|
|
80
|
+
actionMenu: {
|
|
81
|
+
groups: [
|
|
82
|
+
{
|
|
83
|
+
actions: [
|
|
84
|
+
{
|
|
85
|
+
label: "Edit prices",
|
|
86
|
+
to: `prices`,
|
|
87
|
+
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
prefix: PREFIX
|
|
94
|
+
}
|
|
95
|
+
) });
|
|
96
|
+
};
|
|
97
|
+
const columnHelper = createDataTableColumnHelper();
|
|
98
|
+
const useColumns = (product) => {
|
|
99
|
+
const navigate = useNavigate();
|
|
100
|
+
const { mutateAsync } = useDeleteVariantLazy(product.id);
|
|
101
|
+
const prompt = usePrompt();
|
|
102
|
+
const [searchParams] = useSearchParams();
|
|
103
|
+
const tableSearchParams = useMemo(() => {
|
|
104
|
+
const filtered = new URLSearchParams();
|
|
105
|
+
for (const [key, value] of searchParams.entries()) {
|
|
106
|
+
if (key.startsWith(`${PREFIX}_`)) {
|
|
107
|
+
filtered.append(key, value);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return filtered;
|
|
111
|
+
}, [searchParams]);
|
|
112
|
+
const dateColumns = useDataTableDateColumns();
|
|
113
|
+
const handleDelete = useCallback(
|
|
114
|
+
async (id, title) => {
|
|
115
|
+
const res = await prompt({
|
|
116
|
+
title: "Are you sure?",
|
|
117
|
+
description: `Are you sure you want to delete denomination ${title}?`,
|
|
118
|
+
confirmText: "Delete",
|
|
119
|
+
cancelText: "Cancel"
|
|
120
|
+
});
|
|
121
|
+
if (!res) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
await mutateAsync({ variantId: id });
|
|
125
|
+
},
|
|
126
|
+
[mutateAsync, prompt]
|
|
127
|
+
);
|
|
128
|
+
const optionColumns = useMemo(() => {
|
|
129
|
+
if (!(product == null ? void 0 : product.options)) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
return product.options.map((option) => {
|
|
133
|
+
return columnHelper.display({
|
|
134
|
+
id: option.id,
|
|
135
|
+
header: option.title,
|
|
136
|
+
cell: ({ row }) => {
|
|
137
|
+
var _a;
|
|
138
|
+
const variantOpt = (_a = row.original.options) == null ? void 0 : _a.find(
|
|
139
|
+
(opt) => opt.option_id === option.id
|
|
140
|
+
);
|
|
141
|
+
if (!variantOpt) {
|
|
142
|
+
return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "-" });
|
|
143
|
+
}
|
|
144
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(Tooltip, { content: variantOpt.value, children: /* @__PURE__ */ jsx(
|
|
145
|
+
Badge,
|
|
146
|
+
{
|
|
147
|
+
size: "2xsmall",
|
|
148
|
+
title: variantOpt.value,
|
|
149
|
+
className: "inline-flex min-w-[20px] max-w-[140px] items-center justify-center overflow-hidden truncate",
|
|
150
|
+
children: variantOpt.value
|
|
151
|
+
}
|
|
152
|
+
) }) });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}, [product]);
|
|
157
|
+
const getActions = useCallback(
|
|
158
|
+
(ctx) => {
|
|
159
|
+
const variant = ctx.row.original;
|
|
160
|
+
const mainActions = [
|
|
161
|
+
{
|
|
162
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
163
|
+
label: "Delete",
|
|
164
|
+
onClick: () => handleDelete(variant.id, variant.title)
|
|
165
|
+
}
|
|
166
|
+
];
|
|
167
|
+
return [mainActions];
|
|
168
|
+
},
|
|
169
|
+
[handleDelete, navigate, tableSearchParams]
|
|
170
|
+
);
|
|
171
|
+
return useMemo(() => {
|
|
172
|
+
return [
|
|
173
|
+
columnHelper.accessor("title", {
|
|
174
|
+
header: "Title",
|
|
175
|
+
enableSorting: true,
|
|
176
|
+
sortAscLabel: "Asc",
|
|
177
|
+
sortDescLabel: "Desc"
|
|
178
|
+
}),
|
|
179
|
+
columnHelper.accessor("sku", {
|
|
180
|
+
header: "SKU",
|
|
181
|
+
enableSorting: true,
|
|
182
|
+
sortAscLabel: "Asc",
|
|
183
|
+
sortDescLabel: "Desc"
|
|
184
|
+
}),
|
|
185
|
+
columnHelper.action({
|
|
186
|
+
actions: getActions
|
|
187
|
+
})
|
|
188
|
+
];
|
|
189
|
+
}, [optionColumns, dateColumns, getActions]);
|
|
190
|
+
};
|
|
191
|
+
const useFilters = () => {
|
|
192
|
+
const dateFilters = useDataTableDateFilters();
|
|
193
|
+
return useMemo(() => {
|
|
194
|
+
return [...dateFilters];
|
|
195
|
+
}, [dateFilters]);
|
|
196
|
+
};
|
|
197
|
+
export {
|
|
198
|
+
ProductVariantSection
|
|
199
|
+
};
|