@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,116 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@hookform/resolvers/zod/dist/zod.mjs";
|
|
3
|
+
import { Heading, toast, Input, Select, Button } from "@medusajs/ui";
|
|
4
|
+
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
5
|
+
import { useParams } from "react-router-dom";
|
|
6
|
+
import { z } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
7
|
+
import { Form } from "../../../../components/form.js";
|
|
8
|
+
import { KeyboundForm } from "../../../../components/keybound-form.js";
|
|
9
|
+
import { RouteDrawer } from "../../../../components/modals/route-drawer/route-drawer.js";
|
|
10
|
+
import "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
11
|
+
import "react";
|
|
12
|
+
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
13
|
+
import { useRouteModal } from "../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
14
|
+
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
15
|
+
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
16
|
+
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
17
|
+
import { useCustomers } from "../../../../hooks/api/customers.js";
|
|
18
|
+
import { useGiftCard, useTransferGiftCard } from "../../../../hooks/api/gift-cards.js";
|
|
19
|
+
import { TransferIcon } from "./components/transfer-icon.js";
|
|
20
|
+
const Note = () => {
|
|
21
|
+
const { id } = useParams();
|
|
22
|
+
const {
|
|
23
|
+
gift_card: giftCard,
|
|
24
|
+
isPending,
|
|
25
|
+
isError,
|
|
26
|
+
error
|
|
27
|
+
} = useGiftCard(id, {});
|
|
28
|
+
if (isError) {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
const isReady = !isPending && !!giftCard;
|
|
32
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
33
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
34
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Gift Card" }) }),
|
|
35
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the gift card to a new owner" }) })
|
|
36
|
+
] }),
|
|
37
|
+
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
38
|
+
] });
|
|
39
|
+
};
|
|
40
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
41
|
+
const { customers } = useCustomers();
|
|
42
|
+
const form = useForm({
|
|
43
|
+
defaultValues: {
|
|
44
|
+
customer_id: giftCard.customer.id
|
|
45
|
+
},
|
|
46
|
+
resolver: zodResolver(schema)
|
|
47
|
+
});
|
|
48
|
+
const { mutateAsync, isPending } = useTransferGiftCard(giftCard.id);
|
|
49
|
+
const { handleSuccess } = useRouteModal();
|
|
50
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
51
|
+
await mutateAsync(
|
|
52
|
+
{ customer_id: data.customer_id },
|
|
53
|
+
{
|
|
54
|
+
onSuccess: () => {
|
|
55
|
+
toast.success("Gift card transferred successfully");
|
|
56
|
+
handleSuccess();
|
|
57
|
+
},
|
|
58
|
+
onError: (error) => toast.error(error.message)
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
63
|
+
KeyboundForm,
|
|
64
|
+
{
|
|
65
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
66
|
+
onSubmit,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
69
|
+
/* @__PURE__ */ jsx(TransferIcon, {}),
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
71
|
+
/* @__PURE__ */ jsx(Form.Label, { children: "Current Owner" }),
|
|
72
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { value: giftCard.customer.email, readOnly: true, disabled: true }) }),
|
|
73
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
74
|
+
] }) }),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
Form.Field,
|
|
77
|
+
{
|
|
78
|
+
control: form.control,
|
|
79
|
+
name: "customer_id",
|
|
80
|
+
render: ({ field: { onChange, ref, ...field } }) => {
|
|
81
|
+
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
82
|
+
/* @__PURE__ */ jsx(Form.Label, { children: "New Owner" }),
|
|
83
|
+
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
|
|
84
|
+
/* @__PURE__ */ jsx(Select.Trigger, { ref, children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
85
|
+
/* @__PURE__ */ jsx(Select.Content, { children: customers == null ? void 0 : customers.map((customer) => {
|
|
86
|
+
const customerName = [
|
|
87
|
+
customer.first_name,
|
|
88
|
+
customer.last_name
|
|
89
|
+
];
|
|
90
|
+
return /* @__PURE__ */ jsxs(Select.Item, { value: customer.id, children: [
|
|
91
|
+
customer.email,
|
|
92
|
+
" ",
|
|
93
|
+
customerName.join("").length ? `(${customerName.join(" ")})` : ""
|
|
94
|
+
] }, customer.id);
|
|
95
|
+
}) })
|
|
96
|
+
] }) }),
|
|
97
|
+
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
104
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
105
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
106
|
+
] }) })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
) });
|
|
110
|
+
};
|
|
111
|
+
const schema = z.object({
|
|
112
|
+
customer_id: z.string()
|
|
113
|
+
});
|
|
114
|
+
export {
|
|
115
|
+
Note as default
|
|
116
|
+
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Container, Text } from "@medusajs/ui";
|
|
3
|
+
import { formatAmount } from "../../../../utils/format-amount.js";
|
|
4
|
+
const GiftCardBalanceSection = ({
|
|
5
|
+
storeCreditAccount,
|
|
6
|
+
giftCard
|
|
7
|
+
}) => {
|
|
8
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: [
|
|
12
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
14
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
15
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
16
|
+
/* @__PURE__ */ jsx(
|
|
17
|
+
Text,
|
|
18
|
+
{
|
|
19
|
+
weight: "plus",
|
|
20
|
+
size: "xlarge",
|
|
21
|
+
className: "tabular-nums text-ui-fg-base",
|
|
22
|
+
children: formatAmount(
|
|
23
|
+
storeCreditAccount.balance,
|
|
24
|
+
giftCard.currency_code
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
] })
|
|
29
|
+
] }),
|
|
30
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
|
|
31
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-tag-neutral-icon h-8 w-1 rounded-full" }),
|
|
32
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Initial Balance" }),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
Text,
|
|
36
|
+
{
|
|
37
|
+
weight: "plus",
|
|
38
|
+
size: "xlarge",
|
|
39
|
+
className: "tabular-nums text-ui-fg-base",
|
|
40
|
+
children: formatAmount(giftCard.value, giftCard.currency_code)
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
] })
|
|
44
|
+
] })
|
|
45
|
+
] });
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
GiftCardBalanceSection as default
|
|
49
|
+
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Gift, Calendar, Trash } from "@medusajs/icons";
|
|
3
|
+
import { usePrompt, Container, Heading, Copy, Text, StatusBadge, Badge, toast } from "@medusajs/ui";
|
|
4
|
+
import { useNavigate, Link } from "react-router-dom";
|
|
5
|
+
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
6
|
+
import { SectionRow } from "../../../../components/section-row.js";
|
|
7
|
+
import { Thumbnail } from "../../../../components/thumbnail.js";
|
|
8
|
+
import { useRedeemGiftCard, useDeleteGiftCard } from "../../../../hooks/api/gift-cards.js";
|
|
9
|
+
import { getFullDate } from "../../../../utils/date-utils.js";
|
|
10
|
+
import { formatAmount } from "../../../../utils/format-amount.js";
|
|
11
|
+
import { formatDate, getRelativeDate } from "../../../../utils/format-date.js";
|
|
12
|
+
import { getGiftCardStatus, getGiftCardStatusColor } from "../../../../utils/statuses.js";
|
|
13
|
+
const GiftCardGeneralSection = ({ giftCard }) => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
15
|
+
const prompt = usePrompt();
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
const { mutateAsync: redeemGiftCard, isPending } = useRedeemGiftCard(
|
|
18
|
+
giftCard.id
|
|
19
|
+
);
|
|
20
|
+
const { mutateAsync: deleteGiftCard, isPending: isDeleting } = useDeleteGiftCard(giftCard.id);
|
|
21
|
+
const handleRedeem = async () => {
|
|
22
|
+
const res = await prompt({
|
|
23
|
+
title: "Redeem gift card",
|
|
24
|
+
description: `Are you sure? This cannot be undone. Once you confirm the gift card value will be added to the customers store credit account.`,
|
|
25
|
+
confirmText: "Redeem",
|
|
26
|
+
cancelText: "Cancel"
|
|
27
|
+
});
|
|
28
|
+
if (!res) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
await redeemGiftCard(
|
|
32
|
+
{ customer_id: giftCard == null ? void 0 : giftCard.customer_id },
|
|
33
|
+
{
|
|
34
|
+
onSuccess: () => {
|
|
35
|
+
toast.success("Successfully redeemed gift card");
|
|
36
|
+
navigate("..", { replace: true });
|
|
37
|
+
},
|
|
38
|
+
onError: (err) => {
|
|
39
|
+
toast.error(err.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
const handleDelete = async () => {
|
|
45
|
+
const res = await prompt({
|
|
46
|
+
title: "Delete gift card",
|
|
47
|
+
description: "Are you sure? This cannot be undone.",
|
|
48
|
+
verificationText: giftCard.value.toString(),
|
|
49
|
+
verificationInstruction: "Confirmation",
|
|
50
|
+
confirmText: "Delete",
|
|
51
|
+
cancelText: "Cancel"
|
|
52
|
+
});
|
|
53
|
+
if (!res) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
await deleteGiftCard(void 0, {
|
|
57
|
+
onSuccess: () => toast.success("Gift card deleted successfully"),
|
|
58
|
+
onError: (error) => toast.error(error.message)
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const status = getGiftCardStatus(giftCard);
|
|
62
|
+
const statusColor = getGiftCardStatusColor(status);
|
|
63
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
64
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
65
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
66
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
67
|
+
/* @__PURE__ */ jsxs(Heading, { children: [
|
|
68
|
+
"#",
|
|
69
|
+
giftCard.code
|
|
70
|
+
] }),
|
|
71
|
+
/* @__PURE__ */ jsx(Copy, { content: `${giftCard.code}`, className: "text-ui-fg-muted" })
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: getFullDate({
|
|
74
|
+
date: giftCard.created_at,
|
|
75
|
+
includeTime: true
|
|
76
|
+
}) })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
79
|
+
/* @__PURE__ */ jsx(StatusBadge, { color: statusColor, children: status }),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
ActionMenu,
|
|
82
|
+
{
|
|
83
|
+
groups: [
|
|
84
|
+
{
|
|
85
|
+
actions: [
|
|
86
|
+
{
|
|
87
|
+
icon: /* @__PURE__ */ jsx(Gift, {}),
|
|
88
|
+
label: "Redeem gift card",
|
|
89
|
+
onClick: () => handleRedeem(),
|
|
90
|
+
disabled: isPending
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
icon: /* @__PURE__ */ jsx(Calendar, {}),
|
|
94
|
+
label: "Edit expiration date",
|
|
95
|
+
to: "expiration",
|
|
96
|
+
disabled: isPending
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
actions: [
|
|
102
|
+
{
|
|
103
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
104
|
+
label: "Delete",
|
|
105
|
+
onClick: handleDelete,
|
|
106
|
+
disabled: isDeleting || true
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] })
|
|
114
|
+
] }),
|
|
115
|
+
((_a = giftCard.line_item) == null ? void 0 : _a.product) && /* @__PURE__ */ jsx(
|
|
116
|
+
SectionRow,
|
|
117
|
+
{
|
|
118
|
+
title: "Gift card product",
|
|
119
|
+
value: /* @__PURE__ */ jsx(
|
|
120
|
+
Link,
|
|
121
|
+
{
|
|
122
|
+
to: `/products/${(_c = (_b = giftCard.line_item) == null ? void 0 : _b.product) == null ? void 0 : _c.id}`,
|
|
123
|
+
className: "text-ui-fg-base text-sm",
|
|
124
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full max-w-[250px] items-center gap-x-3 overflow-hidden", children: [
|
|
125
|
+
/* @__PURE__ */ jsx("div", { className: "w-fit flex-shrink-0", children: /* @__PURE__ */ jsx(
|
|
126
|
+
Thumbnail,
|
|
127
|
+
{
|
|
128
|
+
size: "small",
|
|
129
|
+
src: (_e = (_d = giftCard.line_item) == null ? void 0 : _d.product) == null ? void 0 : _e.thumbnail
|
|
130
|
+
}
|
|
131
|
+
) }),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
"span",
|
|
134
|
+
{
|
|
135
|
+
title: (_g = (_f = giftCard.line_item) == null ? void 0 : _f.product) == null ? void 0 : _g.title,
|
|
136
|
+
className: "truncate",
|
|
137
|
+
children: (_i = (_h = giftCard.line_item) == null ? void 0 : _h.product) == null ? void 0 : _i.title
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] })
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
SectionRow,
|
|
147
|
+
{
|
|
148
|
+
title: "Currency",
|
|
149
|
+
value: /* @__PURE__ */ jsx(Badge, { size: "xsmall", className: "text-ui-fg-base rounded-xl px-2", children: giftCard.currency_code.toUpperCase() })
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
SectionRow,
|
|
154
|
+
{
|
|
155
|
+
title: "Value",
|
|
156
|
+
value: formatAmount(giftCard.value, giftCard.currency_code)
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
/* @__PURE__ */ jsx(
|
|
160
|
+
SectionRow,
|
|
161
|
+
{
|
|
162
|
+
title: "Expiration Date",
|
|
163
|
+
value: formatDate(giftCard.expires_at)
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
/* @__PURE__ */ jsx(
|
|
167
|
+
SectionRow,
|
|
168
|
+
{
|
|
169
|
+
title: "Creation Date",
|
|
170
|
+
value: getRelativeDate(giftCard.created_at)
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
] });
|
|
174
|
+
};
|
|
175
|
+
export {
|
|
176
|
+
GiftCardGeneralSection as default
|
|
177
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Container, Text } from "@medusajs/ui";
|
|
3
|
+
import { Link } from "react-router-dom";
|
|
4
|
+
import { Header } from "../../../../components/header.js";
|
|
5
|
+
const GiftCardNoteSection = ({ giftCard }) => {
|
|
6
|
+
if (!giftCard) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
10
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
11
|
+
/* @__PURE__ */ jsx(Header, { title: "Note" }),
|
|
12
|
+
/* @__PURE__ */ jsx(Link, { to: "note", className: "text-ui-fg-muted text-sm px-6", children: "Edit note" })
|
|
13
|
+
] }),
|
|
14
|
+
giftCard.note && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col", children: /* @__PURE__ */ jsx(
|
|
15
|
+
Text,
|
|
16
|
+
{
|
|
17
|
+
size: "small",
|
|
18
|
+
leading: "compact",
|
|
19
|
+
className: "text-ui-fg-subtle",
|
|
20
|
+
children: giftCard.note ?? ""
|
|
21
|
+
}
|
|
22
|
+
) }) }) }) })
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
GiftCardNoteSection as default
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ShoppingCart } from "@medusajs/icons";
|
|
3
|
+
import { Container } from "@medusajs/ui";
|
|
4
|
+
import { Header } from "../../../../components/header.js";
|
|
5
|
+
import { SidebarLink } from "../../../../components/sidebar-link.js";
|
|
6
|
+
import { useOrder } from "../../../../hooks/api/order.js";
|
|
7
|
+
const GiftCardOrderSection = ({ giftCard }) => {
|
|
8
|
+
if (!giftCard || giftCard.reference !== "order") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const { order, isLoading, isError, error } = useOrder(giftCard.reference_id);
|
|
12
|
+
if (isError) {
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
if (isLoading) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
19
|
+
/* @__PURE__ */ jsx(Header, { title: "Order" }),
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
SidebarLink,
|
|
22
|
+
{
|
|
23
|
+
to: `/orders/${order.id}`,
|
|
24
|
+
labelKey: `#${order.display_id}`,
|
|
25
|
+
icon: /* @__PURE__ */ jsx(ShoppingCart, {}),
|
|
26
|
+
descriptionKey: `Order #${order.display_id}`
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
GiftCardOrderSection as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { UserMini } from "@medusajs/icons";
|
|
3
|
+
import { Container } from "@medusajs/ui";
|
|
4
|
+
import { Link } from "react-router-dom";
|
|
5
|
+
import { GiftCardStatus } from "../../../../../../types/loyalty/module.js";
|
|
6
|
+
import { Header } from "../../../../components/header.js";
|
|
7
|
+
import { SidebarLink } from "../../../../components/sidebar-link.js";
|
|
8
|
+
const GiftCardOwnerSection = ({ giftCard }) => {
|
|
9
|
+
if (!giftCard) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
13
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
14
|
+
/* @__PURE__ */ jsx(Header, { title: "Owner" }),
|
|
15
|
+
giftCard.status !== GiftCardStatus.REDEEMED && /* @__PURE__ */ jsx(Link, { to: `owner`, className: "text-ui-fg-muted text-sm px-6", children: "Transfer ownership" })
|
|
16
|
+
] }),
|
|
17
|
+
/* @__PURE__ */ jsx(
|
|
18
|
+
SidebarLink,
|
|
19
|
+
{
|
|
20
|
+
to: `/customers/${giftCard.customer.id}`,
|
|
21
|
+
labelKey: `${[
|
|
22
|
+
giftCard.customer.first_name,
|
|
23
|
+
giftCard.customer.last_name
|
|
24
|
+
].join(" ")}`,
|
|
25
|
+
descriptionKey: giftCard.customer.email,
|
|
26
|
+
icon: /* @__PURE__ */ jsx(UserMini, {})
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] });
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
GiftCardOwnerSection as default
|
|
33
|
+
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Container } from "@medusajs/ui";
|
|
3
|
+
import { TransactionsTable } from "../../../store-credit-accounts/_id_/components/transactions-table/table.js";
|
|
4
|
+
const GiftCardTransactionsSection = ({
|
|
5
|
+
storeCreditAccount,
|
|
6
|
+
transactionGroup
|
|
7
|
+
}) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(Container, { className: "divide-y p-0", children: /* @__PURE__ */ jsx(
|
|
9
|
+
TransactionsTable,
|
|
10
|
+
{
|
|
11
|
+
id: storeCreditAccount.id,
|
|
12
|
+
transactionGroup
|
|
13
|
+
}
|
|
14
|
+
) }, storeCreditAccount.id);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
GiftCardTransactionsSection as default
|
|
18
|
+
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createDataTableColumnHelper, Badge } from "@medusajs/ui";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { getRelativeDate } from "../../../../../utils/date-utils.js";
|
|
5
|
+
import { formatAmount } from "../../../../../utils/format-amount.js";
|
|
6
|
+
const columnHelper = createDataTableColumnHelper();
|
|
7
|
+
const useTransactionColumns = () => {
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
return [
|
|
10
|
+
columnHelper.accessor("type", {
|
|
11
|
+
header: "Type",
|
|
12
|
+
cell: ({ row }) => {
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
Badge,
|
|
15
|
+
{
|
|
16
|
+
size: "2xsmall",
|
|
17
|
+
color: row.original.type === "debit" ? "orange" : "green",
|
|
18
|
+
children: row.original.type
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
columnHelper.accessor("amount", {
|
|
24
|
+
header: "Amount",
|
|
25
|
+
cell: ({ row }) => {
|
|
26
|
+
return row.original.account.currency_code && formatAmount(
|
|
27
|
+
row.original.amount,
|
|
28
|
+
row.original.account.currency_code
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
columnHelper.accessor("reference", {
|
|
33
|
+
header: "Reference",
|
|
34
|
+
cell: ({ row }) => {
|
|
35
|
+
return /* @__PURE__ */ jsx(Badge, { size: "2xsmall", children: row.original.reference });
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
columnHelper.accessor("reference_id", {
|
|
39
|
+
header: "Reference ID"
|
|
40
|
+
}),
|
|
41
|
+
columnHelper.accessor("created_at", {
|
|
42
|
+
header: "Created At",
|
|
43
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
44
|
+
})
|
|
45
|
+
];
|
|
46
|
+
}, []);
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
useTransactionColumns
|
|
50
|
+
};
|
package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useQueryParams } from "../../../../../hooks/common/use-query-params.js";
|
|
2
|
+
const useTransactionTableQuery = ({
|
|
3
|
+
prefix,
|
|
4
|
+
pageSize = 10
|
|
5
|
+
}) => {
|
|
6
|
+
const queryObject = useQueryParams(
|
|
7
|
+
["offset", "transaction_group_id", "created_at", "updated_at"],
|
|
8
|
+
prefix
|
|
9
|
+
);
|
|
10
|
+
const { offset, created_at, updated_at, transaction_group_id, ...rest } = queryObject;
|
|
11
|
+
const searchParams = {
|
|
12
|
+
limit: pageSize,
|
|
13
|
+
offset: offset ? Number(offset) : 0,
|
|
14
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
15
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
16
|
+
transaction_group_id: transaction_group_id ? JSON.parse(transaction_group_id) : void 0,
|
|
17
|
+
...rest
|
|
18
|
+
};
|
|
19
|
+
return searchParams;
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useTransactionTableQuery
|
|
23
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useParams, Outlet } from "react-router-dom";
|
|
3
|
+
import { JsonViewSection } from "../../../components/json-view-section.js";
|
|
4
|
+
import { TwoColumnLayout } from "../../../components/layouts/two-column.js";
|
|
5
|
+
import { useGiftCard } from "../../../hooks/api/gift-cards.js";
|
|
6
|
+
import { useStoreCreditAccounts, useStoreCreditAccount } from "../../../hooks/api/store-credit-accounts.js";
|
|
7
|
+
import { useTransactionGroups } from "../../../hooks/api/transaction-groups.js";
|
|
8
|
+
import GiftCardBalanceSection from "./components/gift-card-balance-section.js";
|
|
9
|
+
import GiftCardGeneralSection from "./components/gift-card-general-section.js";
|
|
10
|
+
import GiftCardNoteSection from "./components/gift-card-note-section.js";
|
|
11
|
+
import GiftCardOrderSection from "./components/gift-card-order-section.js";
|
|
12
|
+
import GiftCardOwnerSection from "./components/gift-card-owner-section.js";
|
|
13
|
+
import GiftCardTransactionsSection from "./components/gift-card-transactions-section.js";
|
|
14
|
+
const GiftCardDetailsPage = () => {
|
|
15
|
+
var _a;
|
|
16
|
+
const { id } = useParams();
|
|
17
|
+
const { gift_card: giftCard, isLoading } = useGiftCard(id, {
|
|
18
|
+
fields: "*line_item.product"
|
|
19
|
+
});
|
|
20
|
+
const { store_credit_accounts: storeCreditAccounts } = useStoreCreditAccounts(
|
|
21
|
+
{
|
|
22
|
+
customer_id: giftCard == null ? void 0 : giftCard.customer_id,
|
|
23
|
+
currency_code: giftCard == null ? void 0 : giftCard.currency_code
|
|
24
|
+
},
|
|
25
|
+
{ enabled: !isLoading && !!(giftCard == null ? void 0 : giftCard.customer_id) }
|
|
26
|
+
);
|
|
27
|
+
const { transaction_groups: transactionGroups } = useTransactionGroups(
|
|
28
|
+
{ code: giftCard == null ? void 0 : giftCard.code },
|
|
29
|
+
{ enabled: !isLoading && !!(giftCard == null ? void 0 : giftCard.code) }
|
|
30
|
+
);
|
|
31
|
+
const transactionGroup = transactionGroups == null ? void 0 : transactionGroups[0];
|
|
32
|
+
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
33
|
+
(_a = storeCreditAccounts == null ? void 0 : storeCreditAccounts[0]) == null ? void 0 : _a.id,
|
|
34
|
+
{
|
|
35
|
+
transaction_group_id: transactionGroup == null ? void 0 : transactionGroup.id
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
enabled: !isLoading && !!(giftCard == null ? void 0 : giftCard.customer_id) && !!(transactionGroup == null ? void 0 : transactionGroup.id) && !!(storeCreditAccounts == null ? void 0 : storeCreditAccounts.length)
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
if (!giftCard) {
|
|
42
|
+
return /* @__PURE__ */ jsx(Fragment, { children: "Loading" });
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
+
/* @__PURE__ */ jsx(
|
|
46
|
+
TwoColumnLayout,
|
|
47
|
+
{
|
|
48
|
+
firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
49
|
+
/* @__PURE__ */ jsx(GiftCardGeneralSection, { giftCard }),
|
|
50
|
+
storeCreditAccount && transactionGroup && /* @__PURE__ */ jsx(
|
|
51
|
+
GiftCardTransactionsSection,
|
|
52
|
+
{
|
|
53
|
+
storeCreditAccount,
|
|
54
|
+
transactionGroup
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
/* @__PURE__ */ jsx(JsonViewSection, { data: giftCard })
|
|
58
|
+
] }),
|
|
59
|
+
secondCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
+
storeCreditAccount && /* @__PURE__ */ jsx(
|
|
61
|
+
GiftCardBalanceSection,
|
|
62
|
+
{
|
|
63
|
+
storeCreditAccount,
|
|
64
|
+
giftCard
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx(GiftCardOwnerSection, { giftCard }),
|
|
68
|
+
/* @__PURE__ */ jsx(GiftCardNoteSection, { giftCard }),
|
|
69
|
+
/* @__PURE__ */ jsx(GiftCardOrderSection, { giftCard })
|
|
70
|
+
] })
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx(Outlet, {})
|
|
74
|
+
] });
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
GiftCardDetailsPage as default
|
|
78
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tag } from "@medusajs/icons";
|
|
3
|
+
import { Container } from "@medusajs/ui";
|
|
4
|
+
import { Link } from "react-router-dom";
|
|
5
|
+
import { Header } from "../../../components/header.js";
|
|
6
|
+
import { SidebarLink } from "../../../components/sidebar-link.js";
|
|
7
|
+
import { useProducts } from "../../../hooks/api/products.js";
|
|
8
|
+
const GiftCardProductsSection = () => {
|
|
9
|
+
const { products: giftCardProducts } = useProducts({
|
|
10
|
+
is_giftcard: true
|
|
11
|
+
});
|
|
12
|
+
if (!(giftCardProducts == null ? void 0 : giftCardProducts.length)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ jsxs(Container, { className: "p-0", children: [
|
|
16
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
17
|
+
/* @__PURE__ */ jsx(Header, { title: "Gift Card Products" }),
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
Link,
|
|
20
|
+
{
|
|
21
|
+
to: `/gift-card-products/create`,
|
|
22
|
+
className: "text-ui-fg-muted text-sm px-6",
|
|
23
|
+
children: "Create gift card product"
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
] }),
|
|
27
|
+
giftCardProducts.map((giftCardProduct) => /* @__PURE__ */ jsx(
|
|
28
|
+
SidebarLink,
|
|
29
|
+
{
|
|
30
|
+
to: `/gift-card-products/${giftCardProduct.id}`,
|
|
31
|
+
labelKey: giftCardProduct.title,
|
|
32
|
+
descriptionKey: giftCardProduct.title,
|
|
33
|
+
icon: /* @__PURE__ */ jsx(Tag, {})
|
|
34
|
+
}
|
|
35
|
+
))
|
|
36
|
+
] });
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
GiftCardProductsSection as default
|
|
40
|
+
};
|