@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,107 @@
|
|
|
1
|
+
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const giftCardQueryKey = queryKeysFactory("gift-card");
|
|
5
|
+
const useGiftCards = (query, options) => {
|
|
6
|
+
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
7
|
+
query: query2,
|
|
8
|
+
headers
|
|
9
|
+
});
|
|
10
|
+
const { data, ...rest } = useQuery({
|
|
11
|
+
...options,
|
|
12
|
+
queryFn: () => fetchGiftCards(query),
|
|
13
|
+
queryKey: giftCardQueryKey.list(query)
|
|
14
|
+
});
|
|
15
|
+
return { ...data, ...rest };
|
|
16
|
+
};
|
|
17
|
+
const useGiftCard = (id, query, options) => {
|
|
18
|
+
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
19
|
+
query: query2,
|
|
20
|
+
headers
|
|
21
|
+
});
|
|
22
|
+
const { data, ...rest } = useQuery({
|
|
23
|
+
queryFn: () => fetchGiftCard(id, query),
|
|
24
|
+
queryKey: giftCardQueryKey.detail(id),
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
return { ...data, ...rest };
|
|
28
|
+
};
|
|
29
|
+
const useRedeemGiftCard = (id, options) => {
|
|
30
|
+
const queryClient = useQueryClient();
|
|
31
|
+
const redeemGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}/redeem`, {
|
|
32
|
+
body,
|
|
33
|
+
method: "POST"
|
|
34
|
+
});
|
|
35
|
+
return useMutation({
|
|
36
|
+
mutationFn: (body) => redeemGiftCard(id, body),
|
|
37
|
+
onSuccess: (data, variables, context) => {
|
|
38
|
+
var _a;
|
|
39
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
40
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.detail(id) });
|
|
41
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const useTransferGiftCard = (id, options) => {
|
|
46
|
+
const queryClient = useQueryClient();
|
|
47
|
+
const transferGiftCard = async (id2, body) => sdk.client.fetch(
|
|
48
|
+
`/admin/gift-cards/${id2}/transfer`,
|
|
49
|
+
{
|
|
50
|
+
body,
|
|
51
|
+
method: "POST"
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
return useMutation({
|
|
55
|
+
mutationFn: (body) => transferGiftCard(id, body),
|
|
56
|
+
onSuccess: (data, variables, context) => {
|
|
57
|
+
var _a;
|
|
58
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
59
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.detail(id) });
|
|
60
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const useUpdateGiftCard = (id, options) => {
|
|
65
|
+
const queryClient = useQueryClient();
|
|
66
|
+
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
67
|
+
body,
|
|
68
|
+
method: "POST"
|
|
69
|
+
});
|
|
70
|
+
return useMutation({
|
|
71
|
+
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
72
|
+
onSuccess: (data, variables, context) => {
|
|
73
|
+
var _a;
|
|
74
|
+
queryClient.invalidateQueries({
|
|
75
|
+
queryKey: giftCardQueryKey.detail(id)
|
|
76
|
+
});
|
|
77
|
+
queryClient.invalidateQueries({
|
|
78
|
+
queryKey: giftCardQueryKey.lists()
|
|
79
|
+
});
|
|
80
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
81
|
+
},
|
|
82
|
+
...options
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const useDeleteGiftCard = (id, options) => {
|
|
86
|
+
const queryClient = useQueryClient();
|
|
87
|
+
const deleteGiftCard = async (id2) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
88
|
+
method: "DELETE"
|
|
89
|
+
});
|
|
90
|
+
return useMutation({
|
|
91
|
+
mutationFn: () => deleteGiftCard(id),
|
|
92
|
+
onSuccess: (data, variables, context) => {
|
|
93
|
+
var _a;
|
|
94
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
95
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
giftCardQueryKey,
|
|
101
|
+
useDeleteGiftCard,
|
|
102
|
+
useGiftCard,
|
|
103
|
+
useGiftCards,
|
|
104
|
+
useRedeemGiftCard,
|
|
105
|
+
useTransferGiftCard,
|
|
106
|
+
useUpdateGiftCard
|
|
107
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const ORDERS_QUERY_KEY = "orders";
|
|
5
|
+
const orderQueryKeys = queryKeysFactory(ORDERS_QUERY_KEY);
|
|
6
|
+
const useOrder = (id, query, options) => {
|
|
7
|
+
const { data, ...rest } = useQuery({
|
|
8
|
+
queryFn: async () => sdk.admin.order.retrieve(id, query),
|
|
9
|
+
queryKey: orderQueryKeys.detail(id, query),
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
12
|
+
return { ...data, ...rest };
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useOrder
|
|
16
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const PRICE_PREFERENCES_QUERY_KEY = "price-preferences";
|
|
5
|
+
const pricePreferencesQueryKeys = queryKeysFactory(
|
|
6
|
+
PRICE_PREFERENCES_QUERY_KEY
|
|
7
|
+
);
|
|
8
|
+
const usePricePreferences = (query, options) => {
|
|
9
|
+
const { data, ...rest } = useQuery({
|
|
10
|
+
queryFn: () => sdk.admin.pricePreference.list(query),
|
|
11
|
+
queryKey: pricePreferencesQueryKeys.list(query),
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
14
|
+
return { ...data, ...rest };
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
pricePreferencesQueryKeys,
|
|
18
|
+
usePricePreferences
|
|
19
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const PRODUCTS_QUERY_KEY = "products";
|
|
5
|
+
const productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY);
|
|
6
|
+
const VARIANTS_QUERY_KEY = "product_variants";
|
|
7
|
+
const variantsQueryKeys = queryKeysFactory(VARIANTS_QUERY_KEY);
|
|
8
|
+
const useProducts = (query, options) => {
|
|
9
|
+
const { data, ...rest } = useQuery({
|
|
10
|
+
queryFn: () => sdk.admin.product.list(query),
|
|
11
|
+
queryKey: productsQueryKeys.list(query),
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
14
|
+
return { ...data, ...rest };
|
|
15
|
+
};
|
|
16
|
+
const useProduct = (id, query, options) => {
|
|
17
|
+
const { data, ...rest } = useQuery({
|
|
18
|
+
queryFn: () => sdk.admin.product.retrieve(id, query),
|
|
19
|
+
queryKey: productsQueryKeys.detail(id, query),
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
22
|
+
return { ...data, ...rest };
|
|
23
|
+
};
|
|
24
|
+
const useCreateProduct = (options) => {
|
|
25
|
+
const queryClient = useQueryClient();
|
|
26
|
+
return useMutation({
|
|
27
|
+
mutationFn: (payload) => sdk.admin.product.create(payload),
|
|
28
|
+
onSuccess: (data, variables, context) => {
|
|
29
|
+
var _a;
|
|
30
|
+
queryClient.invalidateQueries({ queryKey: productsQueryKeys.lists() });
|
|
31
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
32
|
+
},
|
|
33
|
+
...options
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const useDeleteProduct = (id, options) => {
|
|
37
|
+
const queryClient = useQueryClient();
|
|
38
|
+
return useMutation({
|
|
39
|
+
mutationFn: () => sdk.admin.product.delete(id),
|
|
40
|
+
onSuccess: (data, variables, context) => {
|
|
41
|
+
var _a;
|
|
42
|
+
queryClient.invalidateQueries({ queryKey: productsQueryKeys.lists() });
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: productsQueryKeys.detail(id) });
|
|
44
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
45
|
+
},
|
|
46
|
+
...options
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const useProductVariants = (productId, query, options) => {
|
|
50
|
+
const { data, ...rest } = useQuery({
|
|
51
|
+
queryFn: () => sdk.admin.product.listVariants(productId, query),
|
|
52
|
+
queryKey: variantsQueryKeys.list({ productId, ...query }),
|
|
53
|
+
...options
|
|
54
|
+
});
|
|
55
|
+
return { ...data, ...rest };
|
|
56
|
+
};
|
|
57
|
+
const useDeleteVariantLazy = (productId, options) => {
|
|
58
|
+
const queryClient = useQueryClient();
|
|
59
|
+
return useMutation({
|
|
60
|
+
mutationFn: ({ variantId }) => sdk.admin.product.deleteVariant(productId, variantId),
|
|
61
|
+
onSuccess: (data, variables, context) => {
|
|
62
|
+
var _a;
|
|
63
|
+
queryClient.invalidateQueries({ queryKey: variantsQueryKeys.lists() });
|
|
64
|
+
queryClient.invalidateQueries({
|
|
65
|
+
queryKey: variantsQueryKeys.detail(variables.variantId)
|
|
66
|
+
});
|
|
67
|
+
queryClient.invalidateQueries({
|
|
68
|
+
queryKey: productsQueryKeys.detail(productId)
|
|
69
|
+
});
|
|
70
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
71
|
+
},
|
|
72
|
+
...options
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const useUpdateProduct = (id, options) => {
|
|
76
|
+
const queryClient = useQueryClient();
|
|
77
|
+
return useMutation({
|
|
78
|
+
mutationFn: (payload) => sdk.admin.product.update(id, payload),
|
|
79
|
+
onSuccess: async (data, variables, context) => {
|
|
80
|
+
var _a;
|
|
81
|
+
await queryClient.invalidateQueries({
|
|
82
|
+
queryKey: productsQueryKeys.lists()
|
|
83
|
+
});
|
|
84
|
+
await queryClient.invalidateQueries({
|
|
85
|
+
queryKey: productsQueryKeys.details()
|
|
86
|
+
});
|
|
87
|
+
await queryClient.invalidateQueries({
|
|
88
|
+
queryKey: variantsQueryKeys.lists()
|
|
89
|
+
});
|
|
90
|
+
await queryClient.invalidateQueries({
|
|
91
|
+
queryKey: variantsQueryKeys.details()
|
|
92
|
+
});
|
|
93
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
94
|
+
},
|
|
95
|
+
...options
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const useUpdateProductVariantsBatch = (productId, options) => {
|
|
99
|
+
const queryClient = useQueryClient();
|
|
100
|
+
return useMutation({
|
|
101
|
+
mutationFn: (payload) => sdk.admin.product.batchVariants(productId, {
|
|
102
|
+
update: payload
|
|
103
|
+
}),
|
|
104
|
+
onSuccess: (data, variables, context) => {
|
|
105
|
+
var _a;
|
|
106
|
+
queryClient.invalidateQueries({ queryKey: variantsQueryKeys.lists() });
|
|
107
|
+
queryClient.invalidateQueries({ queryKey: variantsQueryKeys.details() });
|
|
108
|
+
queryClient.invalidateQueries({
|
|
109
|
+
queryKey: productsQueryKeys.detail(productId)
|
|
110
|
+
});
|
|
111
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options, data, variables, context);
|
|
112
|
+
},
|
|
113
|
+
...options
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
productsQueryKeys,
|
|
118
|
+
useCreateProduct,
|
|
119
|
+
useDeleteProduct,
|
|
120
|
+
useDeleteVariantLazy,
|
|
121
|
+
useProduct,
|
|
122
|
+
useProductVariants,
|
|
123
|
+
useProducts,
|
|
124
|
+
useUpdateProduct,
|
|
125
|
+
useUpdateProductVariantsBatch,
|
|
126
|
+
variantsQueryKeys
|
|
127
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const REGIONS_QUERY_KEY = "regions";
|
|
5
|
+
const regionsQueryKeys = queryKeysFactory(REGIONS_QUERY_KEY);
|
|
6
|
+
const useRegions = (query, options) => {
|
|
7
|
+
const { data, ...rest } = useQuery({
|
|
8
|
+
queryFn: () => sdk.admin.region.list(query),
|
|
9
|
+
queryKey: regionsQueryKeys.list(query),
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
12
|
+
return { ...data, ...rest };
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
regionsQueryKeys,
|
|
16
|
+
useRegions
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const SALES_CHANNELS_QUERY_KEY = "sales-channels";
|
|
5
|
+
const salesChannelsQueryKeys = queryKeysFactory(
|
|
6
|
+
SALES_CHANNELS_QUERY_KEY
|
|
7
|
+
);
|
|
8
|
+
const useSalesChannel = (id, options) => {
|
|
9
|
+
const { data, ...rest } = useQuery({
|
|
10
|
+
queryKey: salesChannelsQueryKeys.detail(id),
|
|
11
|
+
queryFn: async () => sdk.admin.salesChannel.retrieve(id),
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
14
|
+
return { ...data, ...rest };
|
|
15
|
+
};
|
|
16
|
+
const useSalesChannels = (query, options) => {
|
|
17
|
+
const { data, ...rest } = useQuery({
|
|
18
|
+
queryFn: () => sdk.admin.salesChannel.list(query),
|
|
19
|
+
queryKey: salesChannelsQueryKeys.list(query),
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
22
|
+
return { ...data, ...rest };
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
salesChannelsQueryKeys,
|
|
26
|
+
useSalesChannel,
|
|
27
|
+
useSalesChannels
|
|
28
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const storeCreditAccountQueryKey = queryKeysFactory(
|
|
5
|
+
"store-credit-account"
|
|
6
|
+
);
|
|
7
|
+
const useStoreCreditAccounts = (query, options) => {
|
|
8
|
+
const fetchStoreCreditAccounts = (query2, headers) => sdk.client.fetch(
|
|
9
|
+
`/admin/store-credit-accounts`,
|
|
10
|
+
{
|
|
11
|
+
query: query2,
|
|
12
|
+
headers
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
const { data, ...rest } = useQuery({
|
|
16
|
+
queryFn: () => fetchStoreCreditAccounts(query),
|
|
17
|
+
queryKey: storeCreditAccountQueryKey.list(query),
|
|
18
|
+
...options
|
|
19
|
+
});
|
|
20
|
+
return { ...data, ...rest };
|
|
21
|
+
};
|
|
22
|
+
const useStoreCreditAccount = (id, query, options) => {
|
|
23
|
+
const fetchStoreCreditAccount = (query2, headers) => sdk.client.fetch(
|
|
24
|
+
`/admin/store-credit-accounts/${id}`,
|
|
25
|
+
{
|
|
26
|
+
query: query2,
|
|
27
|
+
headers
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
const { data, ...rest } = useQuery({
|
|
31
|
+
queryFn: () => fetchStoreCreditAccount(query),
|
|
32
|
+
queryKey: storeCreditAccountQueryKey.list(query),
|
|
33
|
+
...options
|
|
34
|
+
});
|
|
35
|
+
return { ...data, ...rest };
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
storeCreditAccountQueryKey,
|
|
39
|
+
useStoreCreditAccount,
|
|
40
|
+
useStoreCreditAccounts
|
|
41
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FetchError } from "@medusajs/js-sdk";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
4
|
+
import { sdk } from "../../lib/sdk.js";
|
|
5
|
+
const STORE_QUERY_KEY = "store";
|
|
6
|
+
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
7
|
+
async function retrieveActiveStore(query) {
|
|
8
|
+
var _a;
|
|
9
|
+
const response = await sdk.admin.store.list(query);
|
|
10
|
+
const activeStore = (_a = response.stores) == null ? void 0 : _a[0];
|
|
11
|
+
if (!activeStore) {
|
|
12
|
+
throw new FetchError("No active store found", "Not Found", 404);
|
|
13
|
+
}
|
|
14
|
+
return { store: activeStore };
|
|
15
|
+
}
|
|
16
|
+
const useStore = (query, options) => {
|
|
17
|
+
const { data, ...rest } = useQuery({
|
|
18
|
+
queryFn: () => retrieveActiveStore(query),
|
|
19
|
+
queryKey: storeQueryKeys.details(),
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
...data,
|
|
24
|
+
...rest
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
retrieveActiveStore,
|
|
29
|
+
storeQueryKeys,
|
|
30
|
+
useStore
|
|
31
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const transactionGroupQueryKey = queryKeysFactory("transaction-group");
|
|
5
|
+
const useTransactionGroups = (query, options) => {
|
|
6
|
+
const fetchTransactionGroups = (query2, headers) => sdk.client.fetch(
|
|
7
|
+
`/admin/transaction-groups`,
|
|
8
|
+
{
|
|
9
|
+
query: query2,
|
|
10
|
+
headers
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
const { data, ...rest } = useQuery({
|
|
14
|
+
queryFn: () => fetchTransactionGroups(query),
|
|
15
|
+
queryKey: transactionGroupQueryKey.list(query),
|
|
16
|
+
...options
|
|
17
|
+
});
|
|
18
|
+
return { ...data, ...rest };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
transactionGroupQueryKey,
|
|
22
|
+
useTransactionGroups
|
|
23
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { queryKeysFactory } from "../../lib/query-key.js";
|
|
3
|
+
import { sdk } from "../../lib/sdk.js";
|
|
4
|
+
const transactionQueryKey = queryKeysFactory("transaction");
|
|
5
|
+
const useStoreCreditAccountTransactions = (id, query, options) => {
|
|
6
|
+
const fetchStoreCreditAccountTransactions = (query2, headers) => sdk.client.fetch(
|
|
7
|
+
`/admin/store-credit-accounts/${id}/transactions`,
|
|
8
|
+
{
|
|
9
|
+
query: query2,
|
|
10
|
+
headers
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
const { data, ...rest } = useQuery({
|
|
14
|
+
queryFn: () => fetchStoreCreditAccountTransactions(query),
|
|
15
|
+
queryKey: transactionQueryKey.list(query),
|
|
16
|
+
...options
|
|
17
|
+
});
|
|
18
|
+
return { ...data, ...rest };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
transactionQueryKey,
|
|
22
|
+
useStoreCreditAccountTransactions
|
|
23
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
const useCommandHistory = (maxHistory = 20) => {
|
|
3
|
+
const [past, setPast] = useState([]);
|
|
4
|
+
const [future, setFuture] = useState([]);
|
|
5
|
+
const canUndo = past.length > 0;
|
|
6
|
+
const canRedo = future.length > 0;
|
|
7
|
+
const undo = useCallback(() => {
|
|
8
|
+
if (!canUndo) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const previous = past[past.length - 1];
|
|
12
|
+
const newPast = past.slice(0, past.length - 1);
|
|
13
|
+
previous.undo();
|
|
14
|
+
setPast(newPast);
|
|
15
|
+
setFuture([previous, ...future.slice(0, maxHistory - 1)]);
|
|
16
|
+
}, [canUndo, future, past, maxHistory]);
|
|
17
|
+
const redo = useCallback(() => {
|
|
18
|
+
if (!canRedo) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const next = future[0];
|
|
22
|
+
const newFuture = future.slice(1);
|
|
23
|
+
next.redo();
|
|
24
|
+
setPast([...past, next].slice(0, maxHistory - 1));
|
|
25
|
+
setFuture(newFuture);
|
|
26
|
+
}, [canRedo, future, past, maxHistory]);
|
|
27
|
+
const execute = useCallback(
|
|
28
|
+
(command) => {
|
|
29
|
+
command.execute();
|
|
30
|
+
setPast((past2) => [...past2, command].slice(0, maxHistory - 1));
|
|
31
|
+
setFuture([]);
|
|
32
|
+
},
|
|
33
|
+
[maxHistory]
|
|
34
|
+
);
|
|
35
|
+
return {
|
|
36
|
+
undo,
|
|
37
|
+
redo,
|
|
38
|
+
execute,
|
|
39
|
+
canUndo,
|
|
40
|
+
canRedo
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
useCommandHistory
|
|
45
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useQuery, useInfiniteQuery, keepPreviousData } from "@tanstack/react-query";
|
|
2
|
+
import { useDebouncedSearch } from "./use-debounced-search.js";
|
|
3
|
+
const useComboboxData = ({
|
|
4
|
+
queryKey,
|
|
5
|
+
queryFn,
|
|
6
|
+
getOptions,
|
|
7
|
+
defaultValue,
|
|
8
|
+
defaultValueKey,
|
|
9
|
+
pageSize = 10
|
|
10
|
+
}) => {
|
|
11
|
+
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
12
|
+
const queryInitialDataBy = defaultValueKey || "id";
|
|
13
|
+
const { data: initialData } = useQuery({
|
|
14
|
+
queryKey,
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
return queryFn({
|
|
17
|
+
[queryInitialDataBy]: defaultValue,
|
|
18
|
+
limit: Array.isArray(defaultValue) ? defaultValue.length : 1
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
enabled: !!defaultValue
|
|
22
|
+
});
|
|
23
|
+
const { data, ...rest } = useInfiniteQuery({
|
|
24
|
+
queryKey: [...queryKey, query],
|
|
25
|
+
queryFn: async ({ pageParam = 0 }) => {
|
|
26
|
+
return await queryFn({
|
|
27
|
+
q: query,
|
|
28
|
+
limit: pageSize,
|
|
29
|
+
offset: pageParam
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
initialPageParam: 0,
|
|
33
|
+
getNextPageParam: (lastPage) => {
|
|
34
|
+
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
35
|
+
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
36
|
+
},
|
|
37
|
+
placeholderData: keepPreviousData
|
|
38
|
+
});
|
|
39
|
+
const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
|
|
40
|
+
const defaultOptions = initialData ? getOptions(initialData) : [];
|
|
41
|
+
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
42
|
+
if (defaultValue && defaultOptions.length && !searchValue) {
|
|
43
|
+
defaultOptions.forEach((option) => {
|
|
44
|
+
if (!options.find((o) => o.value === option.value)) {
|
|
45
|
+
options.unshift(option);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
options,
|
|
51
|
+
searchValue,
|
|
52
|
+
onSearchValueChange,
|
|
53
|
+
disabled,
|
|
54
|
+
...rest
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
useComboboxData
|
|
59
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createDataTableFilterHelper } from "@medusajs/ui";
|
|
2
|
+
import { subDays, subMonths } from "date-fns";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { getFullDate } from "../../utils/date-utils.js";
|
|
5
|
+
const filterHelper = createDataTableFilterHelper();
|
|
6
|
+
const useDateFilterOptions = () => {
|
|
7
|
+
const today = useMemo(() => {
|
|
8
|
+
const date = /* @__PURE__ */ new Date();
|
|
9
|
+
date.setHours(0, 0, 0, 0);
|
|
10
|
+
return date;
|
|
11
|
+
}, []);
|
|
12
|
+
return useMemo(() => {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
label: "Today",
|
|
16
|
+
value: {
|
|
17
|
+
$gte: today.toISOString()
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Last 7 days",
|
|
22
|
+
value: {
|
|
23
|
+
$gte: subDays(today, 7).toISOString()
|
|
24
|
+
// 7 days ago
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "Last 30 days",
|
|
29
|
+
value: {
|
|
30
|
+
$gte: subDays(today, 30).toISOString()
|
|
31
|
+
// 30 days ago
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Last 90 days",
|
|
36
|
+
value: {
|
|
37
|
+
$gte: subDays(today, 90).toISOString()
|
|
38
|
+
// 90 days ago
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: "Last 12 months",
|
|
43
|
+
value: {
|
|
44
|
+
$gte: subMonths(today, 12).toISOString()
|
|
45
|
+
// 12 months ago
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
}, [today]);
|
|
50
|
+
};
|
|
51
|
+
const useDataTableDateFilters = (disableRangeOption) => {
|
|
52
|
+
const dateFilterOptions = useDateFilterOptions();
|
|
53
|
+
const rangeOptions = useMemo(() => {
|
|
54
|
+
if (disableRangeOption) {
|
|
55
|
+
return {
|
|
56
|
+
disableRangeOption: true
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
rangeOptionStartLabel: "Starting",
|
|
61
|
+
rangeOptionEndLabel: "Ending",
|
|
62
|
+
rangeOptionLabel: "Custom",
|
|
63
|
+
options: dateFilterOptions
|
|
64
|
+
};
|
|
65
|
+
}, [disableRangeOption, dateFilterOptions]);
|
|
66
|
+
return useMemo(() => {
|
|
67
|
+
return [
|
|
68
|
+
filterHelper.accessor("created_at", {
|
|
69
|
+
type: "date",
|
|
70
|
+
label: "Created at",
|
|
71
|
+
format: "date",
|
|
72
|
+
formatDateValue: (date) => getFullDate({ date }),
|
|
73
|
+
options: dateFilterOptions,
|
|
74
|
+
...rangeOptions
|
|
75
|
+
}),
|
|
76
|
+
filterHelper.accessor("updated_at", {
|
|
77
|
+
type: "date",
|
|
78
|
+
label: "Updated at",
|
|
79
|
+
format: "date",
|
|
80
|
+
formatDateValue: (date) => getFullDate({ date }),
|
|
81
|
+
options: dateFilterOptions,
|
|
82
|
+
...rangeOptions
|
|
83
|
+
})
|
|
84
|
+
];
|
|
85
|
+
}, [dateFilterOptions, getFullDate, rangeOptions]);
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
useDataTableDateFilters
|
|
89
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { formatDistance, sub, format } from "date-fns";
|
|
2
|
+
import { enUS } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/date-fns/locale.mjs";
|
|
3
|
+
const useDate = () => {
|
|
4
|
+
const locale = enUS;
|
|
5
|
+
const getFullDate = ({
|
|
6
|
+
date,
|
|
7
|
+
includeTime = false
|
|
8
|
+
}) => {
|
|
9
|
+
const ensuredDate = new Date(date);
|
|
10
|
+
if (isNaN(ensuredDate.getTime())) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
const timeFormat = includeTime ? "p" : "";
|
|
14
|
+
return format(ensuredDate, `PP ${timeFormat}`, {
|
|
15
|
+
locale
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
function getRelativeDate(date) {
|
|
19
|
+
const now = /* @__PURE__ */ new Date();
|
|
20
|
+
return formatDistance(sub(new Date(date), { minutes: 0 }), now, {
|
|
21
|
+
addSuffix: true,
|
|
22
|
+
locale
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
getFullDate,
|
|
27
|
+
getRelativeDate
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
useDate
|
|
32
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import debounce from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/debounce.js";
|
|
2
|
+
import { useState, useCallback, useEffect } from "react";
|
|
3
|
+
const useDebouncedSearch = () => {
|
|
4
|
+
const [searchValue, onSearchValueChange] = useState("");
|
|
5
|
+
const [debouncedQuery, setDebouncedQuery] = useState("");
|
|
6
|
+
const debouncedUpdate = useCallback(
|
|
7
|
+
debounce((query) => setDebouncedQuery(query), 300),
|
|
8
|
+
[]
|
|
9
|
+
);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
debouncedUpdate(searchValue);
|
|
12
|
+
return () => debouncedUpdate.cancel();
|
|
13
|
+
}, [searchValue, debouncedUpdate]);
|
|
14
|
+
return {
|
|
15
|
+
searchValue,
|
|
16
|
+
onSearchValueChange,
|
|
17
|
+
query: debouncedQuery || void 0
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
useDebouncedSearch
|
|
22
|
+
};
|