@medusajs/loyalty-plugin 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/components/action-menu.js +63 -0
- package/.medusa/server/src/admin/components/chip-group.js +82 -0
- package/.medusa/server/src/admin/components/chip-input.js +157 -0
- package/.medusa/server/src/admin/components/combobox.js +324 -0
- package/.medusa/server/src/admin/components/conditional-tooltip.js +15 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +66 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +77 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +110 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +16 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +214 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +77 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +32 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +743 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +37 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +54 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +66 -0
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +166 -0
- package/.medusa/server/src/admin/components/data-grid/components/index.js +16 -0
- package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +7 -0
- package/.medusa/server/src/admin/components/data-grid/context/index.js +6 -0
- package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +14 -0
- package/.medusa/server/src/admin/components/data-grid/data-grid.js +31 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +28 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +85 -0
- package/.medusa/server/src/admin/components/data-grid/helpers/index.js +6 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/index.js +31 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +50 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +123 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +52 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +43 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +191 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +70 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +51 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +15 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +86 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +149 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +482 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +64 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +81 -0
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +14 -0
- package/.medusa/server/src/admin/components/data-grid/index.js +8 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +27 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +296 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +62 -0
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +25 -0
- package/.medusa/server/src/admin/components/data-grid/models/index.js +10 -0
- package/.medusa/server/src/admin/components/data-grid/types.js +1 -0
- package/.medusa/server/src/admin/components/data-grid/utils.js +18 -0
- package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +36 -0
- package/.medusa/server/src/admin/components/data-table/data-table.js +271 -0
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +51 -0
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +90 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +10 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +48 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +19 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +30 -0
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +23 -0
- package/.medusa/server/src/admin/components/data-table/index.js +4 -0
- package/.medusa/server/src/admin/components/data-table.js +249 -0
- package/.medusa/server/src/admin/components/display-id.js +18 -0
- package/.medusa/server/src/admin/components/file-upload.js +116 -0
- package/.medusa/server/src/admin/components/form.js +151 -0
- package/.medusa/server/src/admin/components/handle-input.js +22 -0
- package/.medusa/server/src/admin/components/header.js +41 -0
- package/.medusa/server/src/admin/components/icon-avatar.js +27 -0
- package/.medusa/server/src/admin/components/json-view-section.js +139 -0
- package/.medusa/server/src/admin/components/keybound-form.js +32 -0
- package/.medusa/server/src/admin/components/layouts/single-column.js +7 -0
- package/.medusa/server/src/admin/components/layouts/two-column.js +13 -0
- package/.medusa/server/src/admin/components/listicle.js +20 -0
- package/.medusa/server/src/admin/components/modals/index.js +19 -0
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +57 -0
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +71 -0
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +4 -0
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +60 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +6 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +5 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +30 -0
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +12 -0
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +55 -0
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +63 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +6 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +5 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +47 -0
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +14 -0
- package/.medusa/server/src/admin/components/placeholder-cell.js +7 -0
- package/.medusa/server/src/admin/components/product/product-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +15 -0
- package/.medusa/server/src/admin/components/product/product-status-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +18 -0
- package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +31 -0
- package/.medusa/server/src/admin/components/product/variant-cell/index.js +5 -0
- package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +15 -0
- package/.medusa/server/src/admin/components/section-row.js +32 -0
- package/.medusa/server/src/admin/components/sidebar-link.js +31 -0
- package/.medusa/server/src/admin/components/sortable-list.js +152 -0
- package/.medusa/server/src/admin/components/switch-box.js +43 -0
- package/.medusa/server/src/admin/components/tax-badge.js +18 -0
- package/.medusa/server/src/admin/components/thumbnail.js +28 -0
- package/.medusa/server/src/admin/components/upload-media-form-item.js +83 -0
- package/.medusa/server/src/admin/hooks/api/customers.js +26 -0
- package/.medusa/server/src/admin/hooks/api/gift-cards.js +107 -0
- package/.medusa/server/src/admin/hooks/api/order.js +16 -0
- package/.medusa/server/src/admin/hooks/api/price-preferences.js +19 -0
- package/.medusa/server/src/admin/hooks/api/products.js +127 -0
- package/.medusa/server/src/admin/hooks/api/regions.js +17 -0
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +28 -0
- package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +41 -0
- package/.medusa/server/src/admin/hooks/api/store.js +31 -0
- package/.medusa/server/src/admin/hooks/api/transaction-groups.js +23 -0
- package/.medusa/server/src/admin/hooks/api/transactions.js +23 -0
- package/.medusa/server/src/admin/hooks/commands/use-command-history.js +45 -0
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +59 -0
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +89 -0
- package/.medusa/server/src/admin/hooks/common/use-date.js +32 -0
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +22 -0
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +14 -0
- package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/sales-channels/index.js +10 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +48 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +19 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +30 -0
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +23 -0
- package/.medusa/server/src/admin/lib/currencies.js +729 -0
- package/.medusa/server/src/admin/lib/query-key.js +17 -0
- package/.medusa/server/src/admin/lib/sdk.js +10 -0
- package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +75 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +172 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +30 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +180 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +30 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +97 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +162 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +89 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +199 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +353 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +5 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +247 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +5 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +48 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +14 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +28 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +40 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +121 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +72 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +123 -0
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +1 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +98 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +28 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +96 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +90 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +288 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +111 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +285 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +124 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +4 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +112 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +1 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +35 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +11 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +61 -0
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-card-products/page.js +18 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +137 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +87 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +352 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +116 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +49 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +177 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +27 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +33 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +33 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +18 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +50 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +78 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +40 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +57 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +13 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +61 -0
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +23 -0
- package/.medusa/server/src/admin/routes/gift-cards/page.js +27 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +126 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +31 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +43 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +44 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +18 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +37 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +58 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +39 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +58 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +13 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +31 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +56 -0
- package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +19 -0
- package/.medusa/server/src/admin/utils/date-utils.js +27 -0
- package/.medusa/server/src/admin/utils/format-amount.js +9 -0
- package/.medusa/server/src/admin/utils/format-date.js +21 -0
- package/.medusa/server/src/admin/utils/refs.js +20 -0
- package/.medusa/server/src/admin/utils/statuses.js +23 -0
- package/.medusa/server/src/admin/utils/validations.js +71 -0
- package/.medusa/server/src/admin/utils/variants.js +92 -0
- package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +67 -0
- package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +42 -0
- package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +58 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/redeem/route.js +25 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.js +41 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/transfer/route.js +24 -0
- package/.medusa/server/src/api/admin/gift-cards/middlewares.js +55 -0
- package/.medusa/server/src/api/admin/gift-cards/query-config.js +29 -0
- package/.medusa/server/src/api/admin/gift-cards/route.js +42 -0
- package/.medusa/server/src/api/admin/gift-cards/validators.js +69 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.js +24 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.js +23 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.js +38 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.js +43 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/route.js +52 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.js +51 -0
- package/.medusa/server/src/api/admin/transaction-groups/middlewares.js +16 -0
- package/.medusa/server/src/api/admin/transaction-groups/query-config.js +13 -0
- package/.medusa/server/src/api/admin/transaction-groups/route.js +27 -0
- package/.medusa/server/src/api/admin/transaction-groups/validators.js +19 -0
- package/.medusa/server/src/api/middlewares.js +22 -0
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.js +43 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +26 -0
- package/.medusa/server/src/api/store/carts/query-config.js +9 -0
- package/.medusa/server/src/api/store/carts/validators.js +15 -0
- package/.medusa/server/src/api/store/gift-card-invitations/[code]/accept/route.js +24 -0
- package/.medusa/server/src/api/store/gift-card-invitations/[code]/reject/route.js +24 -0
- package/.medusa/server/src/api/store/gift-card-invitations/middlewares.js +30 -0
- package/.medusa/server/src/api/store/gift-card-invitations/query-config.js +17 -0
- package/.medusa/server/src/api/store/gift-card-invitations/validators.js +14 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/invitation/route.js +26 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/redeem/route.js +24 -0
- package/.medusa/server/src/api/store/gift-cards/[id]/route.js +16 -0
- package/.medusa/server/src/api/store/gift-cards/middlewares.js +46 -0
- package/.medusa/server/src/api/store/gift-cards/query-config.js +26 -0
- package/.medusa/server/src/api/store/gift-cards/route.js +28 -0
- package/.medusa/server/src/api/store/gift-cards/validators.js +26 -0
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.js +31 -0
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.js +28 -0
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.js +24 -0
- package/.medusa/server/src/api/store/store-credit-accounts/route.js +40 -0
- package/.medusa/server/src/api/store/store-credit-accounts/validators.js +17 -0
- package/.medusa/server/src/links/cart-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/customer-gift-card-link.js +13 -0
- package/.medusa/server/src/links/customer-store-credit-account-link.js +13 -0
- package/.medusa/server/src/links/order-gift-cards-link.js +13 -0
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +19 -0
- package/.medusa/server/src/modules/loyalty/index.js +12 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.js +17 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.js +19 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.js +14 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.js +14 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card-invitation.js +20 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card.js +28 -0
- package/.medusa/server/src/modules/loyalty/service.js +15 -0
- package/.medusa/server/src/modules/store-credit/index.js +12 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.js +16 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.js +18 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.js +19 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.js +14 -0
- package/.medusa/server/src/modules/store-credit/models/account-transaction.js +27 -0
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.js +29 -0
- package/.medusa/server/src/modules/store-credit/models/transaction-group.js +28 -0
- package/.medusa/server/src/modules/store-credit/service.js +412 -0
- package/.medusa/server/src/providers/index.js +12 -0
- package/.medusa/server/src/providers/store-credit-payment/index.js +12 -0
- package/.medusa/server/src/providers/store-credit-payment/service.js +181 -0
- package/.medusa/server/src/subscribers/create-gift-card.js +94 -0
- package/.medusa/server/src/types/cart/index.js +3 -0
- package/.medusa/server/src/types/http/gift-card.js +3 -0
- package/.medusa/server/src/types/http/index.js +21 -0
- package/.medusa/server/src/types/http/store-credit-account.js +3 -0
- package/.medusa/server/src/types/http/transaction-group.js +3 -0
- package/.medusa/server/src/types/http/transaction.js +3 -0
- package/.medusa/server/src/types/index.js +21 -0
- package/.medusa/server/src/types/loyalty/index.js +20 -0
- package/.medusa/server/src/types/loyalty/module.js +17 -0
- package/.medusa/server/src/types/loyalty/service.js +3 -0
- package/.medusa/server/src/types/loyalty/workflows.js +3 -0
- package/.medusa/server/src/types/modules.js +14 -0
- package/.medusa/server/src/types/store-credit/index.js +19 -0
- package/.medusa/server/src/types/store-credit/module.js +10 -0
- package/.medusa/server/src/types/store-credit/service.js +3 -0
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.js +167 -0
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.js +95 -0
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.js +136 -0
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.js +66 -0
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.js +11 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/create-gift-card-invitation.js +17 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/delete-gift-card-invitation.js +20 -0
- package/.medusa/server/src/workflows/gift-card-invitation/steps/update-gift-card-invitation.js +31 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/accept-gift-card-invitation.js +79 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/create-gift-card-invitation.js +66 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/delete-gift-card-invitation.js +10 -0
- package/.medusa/server/src/workflows/gift-card-invitation/workflows/reject-gift-card-invitation.js +70 -0
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.js +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.js +17 -0
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.js +20 -0
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.js +34 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.js +12 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.js +19 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.js +90 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/transfer-gift-card.js +48 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.js +12 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +31 -0
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +26 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +27 -0
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.js +58 -0
- package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +96 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-transaction-groups.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.js +17 -0
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.js +17 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.js +57 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-transaction-groups.js +12 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.js +12 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.js +12 -0
- package/.medusa/server/types/loyalty/module.js +8 -0
- package/README.md +62 -0
- package/package.json +94 -0
package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip, Badge } from "@medusajs/ui";
|
|
3
|
+
const DataGridRowErrorIndicator = ({
|
|
4
|
+
rowErrors
|
|
5
|
+
}) => {
|
|
6
|
+
const rowErrorCount = rowErrors ? rowErrors.length : 0;
|
|
7
|
+
if (!rowErrors || rowErrorCount <= 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
Tooltip,
|
|
12
|
+
{
|
|
13
|
+
content: /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-y-3", children: rowErrors.map((error, index) => /* @__PURE__ */ jsx(DataGridRowErrorLine, { error }, index)) }),
|
|
14
|
+
delayDuration: 0,
|
|
15
|
+
children: /* @__PURE__ */ jsx(Badge, { color: "red", size: "2xsmall", className: "cursor-default", children: rowErrorCount })
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
const DataGridRowErrorLine = ({
|
|
20
|
+
error
|
|
21
|
+
}) => {
|
|
22
|
+
return /* @__PURE__ */ jsxs("li", { className: "txt-compact-small flex flex-col items-start", children: [
|
|
23
|
+
error.message,
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
"button",
|
|
26
|
+
{
|
|
27
|
+
type: "button",
|
|
28
|
+
onClick: error.to,
|
|
29
|
+
className: "text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg",
|
|
30
|
+
children: "Fix error"
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
] });
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
DataGridRowErrorIndicator
|
|
37
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Skeleton } from "@medusajs/ui";
|
|
3
|
+
const DataGridSkeleton = ({
|
|
4
|
+
columns,
|
|
5
|
+
rows: rowCount = 10
|
|
6
|
+
}) => {
|
|
7
|
+
const rows = Array.from({ length: rowCount }, (_, i) => i);
|
|
8
|
+
const colCount = columns.length;
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle size-full", children: [
|
|
10
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-bg-base border-b p-4", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-button-neutral h-7 w-[116px] animate-pulse rounded-md" }) }),
|
|
11
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle size-full overflow-auto", children: [
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
className: "grid",
|
|
16
|
+
style: {
|
|
17
|
+
gridTemplateColumns: `repeat(${colCount}, 1fr)`
|
|
18
|
+
},
|
|
19
|
+
children: columns.map((_col, i) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: "bg-ui-bg-base flex h-10 w-[200px] items-center border-b border-r px-4 py-2.5 last:border-r-0",
|
|
24
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[14px] w-[164px]" })
|
|
25
|
+
},
|
|
26
|
+
i
|
|
27
|
+
);
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ jsx("div", { children: rows.map((_, j) => /* @__PURE__ */ jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className: "grid",
|
|
35
|
+
style: { gridTemplateColumns: `repeat(${colCount}, 1fr)` },
|
|
36
|
+
children: columns.map((_col, k) => {
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: "bg-ui-bg-base flex h-10 w-[200px] items-center border-b border-r px-4 py-2.5 last:border-r-0",
|
|
41
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[14px] w-[164px]" })
|
|
42
|
+
},
|
|
43
|
+
k
|
|
44
|
+
);
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
j
|
|
48
|
+
)) })
|
|
49
|
+
] })
|
|
50
|
+
] });
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
DataGridSkeleton
|
|
54
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { clx } from "@medusajs/ui";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { Controller } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
5
|
+
import { useCombinedRefs } from "../../../utils/refs.js";
|
|
6
|
+
import { useDataGridCell } from "../hooks/use-data-grid-cell.js";
|
|
7
|
+
import { useDataGridCellError } from "../hooks/use-data-grid-cell-error.js";
|
|
8
|
+
import "../context/data-grid-context.js";
|
|
9
|
+
import "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/get.js";
|
|
10
|
+
import "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/set.js";
|
|
11
|
+
import { DataGridCellContainer } from "./data-grid-cell-container.js";
|
|
12
|
+
const DataGridTextCell = ({
|
|
13
|
+
context
|
|
14
|
+
}) => {
|
|
15
|
+
const { field, control, renderProps } = useDataGridCell({
|
|
16
|
+
context
|
|
17
|
+
});
|
|
18
|
+
const errorProps = useDataGridCellError({ context });
|
|
19
|
+
const { container, input } = renderProps;
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
Controller,
|
|
22
|
+
{
|
|
23
|
+
control,
|
|
24
|
+
name: field,
|
|
25
|
+
render: ({ field: field2 }) => {
|
|
26
|
+
return /* @__PURE__ */ jsx(DataGridCellContainer, { ...container, ...errorProps, children: /* @__PURE__ */ jsx(Inner, { field: field2, inputProps: input }) });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
const Inner = ({
|
|
32
|
+
field,
|
|
33
|
+
inputProps
|
|
34
|
+
}) => {
|
|
35
|
+
const { onChange: _, onBlur, ref, value, ...rest } = field;
|
|
36
|
+
const { ref: inputRef, onBlur: onInputBlur, onChange, ...input } = inputProps;
|
|
37
|
+
const [localValue, setLocalValue] = useState(value);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setLocalValue(value);
|
|
40
|
+
}, [value]);
|
|
41
|
+
const combinedRefs = useCombinedRefs(inputRef, ref);
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"input",
|
|
44
|
+
{
|
|
45
|
+
className: clx(
|
|
46
|
+
"txt-compact-small text-ui-fg-subtle flex size-full cursor-pointer items-center justify-center bg-transparent outline-none",
|
|
47
|
+
"focus:cursor-text"
|
|
48
|
+
),
|
|
49
|
+
autoComplete: "off",
|
|
50
|
+
tabIndex: -1,
|
|
51
|
+
value: localValue,
|
|
52
|
+
onChange: (e) => setLocalValue(e.target.value),
|
|
53
|
+
ref: combinedRefs,
|
|
54
|
+
onBlur: () => {
|
|
55
|
+
onBlur();
|
|
56
|
+
onInputBlur();
|
|
57
|
+
onChange(localValue, value);
|
|
58
|
+
},
|
|
59
|
+
...input,
|
|
60
|
+
...rest
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
DataGridTextCell
|
|
66
|
+
};
|
package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch } from "@medusajs/ui";
|
|
3
|
+
import { useState, useEffect, useRef } from "react";
|
|
4
|
+
import CurrencyInput from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-currency-input-field/dist/index.esm.js";
|
|
5
|
+
import { Controller } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
6
|
+
import { useCombinedRefs } from "../../../utils/refs.js";
|
|
7
|
+
import { ConditionalTooltip } from "../../conditional-tooltip.js";
|
|
8
|
+
import { useDataGridCell } from "../hooks/use-data-grid-cell.js";
|
|
9
|
+
import { useDataGridCellError } from "../hooks/use-data-grid-cell-error.js";
|
|
10
|
+
import "../context/data-grid-context.js";
|
|
11
|
+
import "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/get.js";
|
|
12
|
+
import "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/lodash/set.js";
|
|
13
|
+
import { DataGridCellContainer } from "./data-grid-cell-container.js";
|
|
14
|
+
const DataGridTogglableNumberCell = ({
|
|
15
|
+
context,
|
|
16
|
+
disabledToggleTooltip,
|
|
17
|
+
...rest
|
|
18
|
+
}) => {
|
|
19
|
+
const { field, control, renderProps } = useDataGridCell({
|
|
20
|
+
context
|
|
21
|
+
});
|
|
22
|
+
const errorProps = useDataGridCellError({ context });
|
|
23
|
+
const { container, input } = renderProps;
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
Controller,
|
|
26
|
+
{
|
|
27
|
+
control,
|
|
28
|
+
name: field,
|
|
29
|
+
render: ({ field: field2 }) => {
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
DataGridCellContainer,
|
|
32
|
+
{
|
|
33
|
+
...container,
|
|
34
|
+
...errorProps,
|
|
35
|
+
outerComponent: /* @__PURE__ */ jsx(
|
|
36
|
+
OuterComponent,
|
|
37
|
+
{
|
|
38
|
+
field: field2,
|
|
39
|
+
inputProps: input,
|
|
40
|
+
isAnchor: container.isAnchor,
|
|
41
|
+
tooltip: disabledToggleTooltip
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
children: /* @__PURE__ */ jsx(Inner, { field: field2, inputProps: input, ...rest })
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
const OuterComponent = ({
|
|
52
|
+
field,
|
|
53
|
+
inputProps,
|
|
54
|
+
isAnchor,
|
|
55
|
+
tooltip
|
|
56
|
+
}) => {
|
|
57
|
+
const buttonRef = useRef(null);
|
|
58
|
+
const { value } = field;
|
|
59
|
+
const { onChange } = inputProps;
|
|
60
|
+
const [localValue, setLocalValue] = useState(value);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
setLocalValue(value);
|
|
63
|
+
}, [value]);
|
|
64
|
+
const handleCheckedChange = (update) => {
|
|
65
|
+
const newValue = { ...localValue, checked: update };
|
|
66
|
+
if (!update && !newValue.disabledToggle) {
|
|
67
|
+
newValue.quantity = "";
|
|
68
|
+
}
|
|
69
|
+
if (update && newValue.quantity === "") {
|
|
70
|
+
newValue.quantity = 0;
|
|
71
|
+
}
|
|
72
|
+
setLocalValue(newValue);
|
|
73
|
+
onChange(newValue, value);
|
|
74
|
+
};
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const handleKeyDown = (e) => {
|
|
77
|
+
var _a;
|
|
78
|
+
if (isAnchor && e.key.toLowerCase() === "x") {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
(_a = buttonRef.current) == null ? void 0 : _a.click();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
84
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
85
|
+
}, [isAnchor]);
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
ConditionalTooltip,
|
|
88
|
+
{
|
|
89
|
+
showTooltip: localValue.disabledToggle && tooltip,
|
|
90
|
+
content: tooltip,
|
|
91
|
+
children: /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-4 z-[3] flex w-fit items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
92
|
+
Switch,
|
|
93
|
+
{
|
|
94
|
+
ref: buttonRef,
|
|
95
|
+
size: "small",
|
|
96
|
+
className: "shrink-0",
|
|
97
|
+
checked: localValue.checked,
|
|
98
|
+
disabled: localValue.disabledToggle,
|
|
99
|
+
onCheckedChange: handleCheckedChange
|
|
100
|
+
}
|
|
101
|
+
) })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
const Inner = ({
|
|
106
|
+
field,
|
|
107
|
+
inputProps,
|
|
108
|
+
placeholder,
|
|
109
|
+
...props
|
|
110
|
+
}) => {
|
|
111
|
+
const { ref, value, onChange: _, onBlur, ...fieldProps } = field;
|
|
112
|
+
const {
|
|
113
|
+
ref: inputRef,
|
|
114
|
+
onChange,
|
|
115
|
+
onBlur: onInputBlur,
|
|
116
|
+
onFocus,
|
|
117
|
+
...attributes
|
|
118
|
+
} = inputProps;
|
|
119
|
+
const [localValue, setLocalValue] = useState(value);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
setLocalValue(value);
|
|
122
|
+
}, [value]);
|
|
123
|
+
const combinedRefs = useCombinedRefs(inputRef, ref);
|
|
124
|
+
const handleInputChange = (updatedValue, _name, _values) => {
|
|
125
|
+
const ensuredValue = updatedValue !== void 0 ? updatedValue : "";
|
|
126
|
+
const newValue = { ...localValue, quantity: ensuredValue };
|
|
127
|
+
if (ensuredValue !== "") {
|
|
128
|
+
newValue.checked = true;
|
|
129
|
+
} else if (newValue.checked && newValue.disabledToggle === false) {
|
|
130
|
+
newValue.checked = false;
|
|
131
|
+
}
|
|
132
|
+
setLocalValue(newValue);
|
|
133
|
+
};
|
|
134
|
+
const handleOnChange = () => {
|
|
135
|
+
if (localValue.disabledToggle && localValue.quantity === "") {
|
|
136
|
+
localValue.quantity = 0;
|
|
137
|
+
}
|
|
138
|
+
onChange(localValue, value);
|
|
139
|
+
};
|
|
140
|
+
return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center gap-x-2", children: /* @__PURE__ */ jsx(
|
|
141
|
+
CurrencyInput,
|
|
142
|
+
{
|
|
143
|
+
...fieldProps,
|
|
144
|
+
...attributes,
|
|
145
|
+
...props,
|
|
146
|
+
ref: combinedRefs,
|
|
147
|
+
className: "txt-compact-small w-full flex-1 cursor-default appearance-none bg-transparent pl-8 text-right outline-none",
|
|
148
|
+
value: localValue == null ? void 0 : localValue.quantity,
|
|
149
|
+
onValueChange: handleInputChange,
|
|
150
|
+
formatValueOnBlur: true,
|
|
151
|
+
onBlur: () => {
|
|
152
|
+
onBlur();
|
|
153
|
+
onInputBlur();
|
|
154
|
+
handleOnChange();
|
|
155
|
+
},
|
|
156
|
+
onFocus,
|
|
157
|
+
decimalsLimit: 0,
|
|
158
|
+
autoComplete: "off",
|
|
159
|
+
tabIndex: -1,
|
|
160
|
+
placeholder: !localValue.checked ? placeholder : void 0
|
|
161
|
+
}
|
|
162
|
+
) });
|
|
163
|
+
};
|
|
164
|
+
export {
|
|
165
|
+
DataGridTogglableNumberCell
|
|
166
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataGridBooleanCell } from "./data-grid-boolean-cell.js";
|
|
2
|
+
import { DataGridCurrencyCell } from "./data-grid-currency-cell.js";
|
|
3
|
+
import { DataGridNumberCell } from "./data-grid-number-cell.js";
|
|
4
|
+
import { DataGridReadonlyCell } from "./data-grid-readonly-cell.js";
|
|
5
|
+
import { DataGridRoot } from "./data-grid-root.js";
|
|
6
|
+
import { DataGridSkeleton } from "./data-grid-skeleton.js";
|
|
7
|
+
import { DataGridTextCell } from "./data-grid-text-cell.js";
|
|
8
|
+
export {
|
|
9
|
+
DataGridBooleanCell,
|
|
10
|
+
DataGridCurrencyCell,
|
|
11
|
+
DataGridNumberCell,
|
|
12
|
+
DataGridReadonlyCell as DataGridReadOnlyCell,
|
|
13
|
+
DataGridRoot,
|
|
14
|
+
DataGridSkeleton,
|
|
15
|
+
DataGridTextCell
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { DataGridContext } from "./data-grid-context.js";
|
|
3
|
+
const useDataGridContext = () => {
|
|
4
|
+
const context = useContext(DataGridContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
"useDataGridContext must be used within a DataGridContextProvider"
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useDataGridContext
|
|
14
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DataGridBooleanCell } from "./components/data-grid-boolean-cell.js";
|
|
3
|
+
import { DataGridCurrencyCell } from "./components/data-grid-currency-cell.js";
|
|
4
|
+
import { DataGridNumberCell } from "./components/data-grid-number-cell.js";
|
|
5
|
+
import { DataGridReadonlyCell } from "./components/data-grid-readonly-cell.js";
|
|
6
|
+
import { DataGridRoot } from "./components/data-grid-root.js";
|
|
7
|
+
import { DataGridSkeleton } from "./components/data-grid-skeleton.js";
|
|
8
|
+
import { DataGridTextCell } from "./components/data-grid-text-cell.js";
|
|
9
|
+
const _DataGrid = ({
|
|
10
|
+
isLoading,
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
13
|
+
var _a;
|
|
14
|
+
return isLoading ? /* @__PURE__ */ jsx(
|
|
15
|
+
DataGridSkeleton,
|
|
16
|
+
{
|
|
17
|
+
columns: props.columns,
|
|
18
|
+
rows: ((_a = props.data) == null ? void 0 : _a.length) && props.data.length > 0 ? props.data.length : 10
|
|
19
|
+
}
|
|
20
|
+
) : /* @__PURE__ */ jsx(DataGridRoot, { ...props });
|
|
21
|
+
};
|
|
22
|
+
const DataGrid = Object.assign(_DataGrid, {
|
|
23
|
+
BooleanCell: DataGridBooleanCell,
|
|
24
|
+
TextCell: DataGridTextCell,
|
|
25
|
+
NumberCell: DataGridNumberCell,
|
|
26
|
+
CurrencyCell: DataGridCurrencyCell,
|
|
27
|
+
ReadonlyCell: DataGridReadonlyCell
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
DataGrid
|
|
31
|
+
};
|
package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createColumnHelper } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@tanstack/react-table/build/lib/index.mjs";
|
|
2
|
+
function createDataGridHelper() {
|
|
3
|
+
const columnHelper = createColumnHelper();
|
|
4
|
+
return {
|
|
5
|
+
column: ({
|
|
6
|
+
id,
|
|
7
|
+
name,
|
|
8
|
+
header,
|
|
9
|
+
cell,
|
|
10
|
+
disableHiding = false,
|
|
11
|
+
field,
|
|
12
|
+
type
|
|
13
|
+
}) => columnHelper.display({
|
|
14
|
+
id,
|
|
15
|
+
header,
|
|
16
|
+
cell,
|
|
17
|
+
enableHiding: !disableHiding,
|
|
18
|
+
meta: {
|
|
19
|
+
name,
|
|
20
|
+
field,
|
|
21
|
+
type
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
createDataGridHelper
|
|
28
|
+
};
|
package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IncludesTaxTooltip } from "../../tax-badge.js";
|
|
3
|
+
import { DataGridCurrencyCell } from "../components/data-grid-currency-cell.js";
|
|
4
|
+
import { DataGridReadonlyCell } from "../components/data-grid-readonly-cell.js";
|
|
5
|
+
import { createDataGridHelper } from "./create-data-grid-column-helper.js";
|
|
6
|
+
const createDataGridPriceColumns = ({
|
|
7
|
+
currencies,
|
|
8
|
+
regions,
|
|
9
|
+
pricePreferences,
|
|
10
|
+
isReadyOnly,
|
|
11
|
+
getFieldName
|
|
12
|
+
}) => {
|
|
13
|
+
const columnHelper = createDataGridHelper();
|
|
14
|
+
return [
|
|
15
|
+
...(currencies == null ? void 0 : currencies.map((currency) => {
|
|
16
|
+
const preference = pricePreferences == null ? void 0 : pricePreferences.find(
|
|
17
|
+
(p) => p.attribute === "currency_code" && p.value === currency
|
|
18
|
+
);
|
|
19
|
+
const translatedCurrencyName = `Price ${currency.toUpperCase()}`;
|
|
20
|
+
return columnHelper.column({
|
|
21
|
+
id: `currency_prices.${currency}`,
|
|
22
|
+
name: translatedCurrencyName,
|
|
23
|
+
field: (context) => {
|
|
24
|
+
const isReadyOnlyValue = isReadyOnly == null ? void 0 : isReadyOnly(context);
|
|
25
|
+
if (isReadyOnlyValue) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return getFieldName(context, currency);
|
|
29
|
+
},
|
|
30
|
+
type: "number",
|
|
31
|
+
header: () => /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [
|
|
32
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", title: translatedCurrencyName, children: translatedCurrencyName }),
|
|
33
|
+
/* @__PURE__ */ jsx(IncludesTaxTooltip, { includesTax: preference == null ? void 0 : preference.is_tax_inclusive })
|
|
34
|
+
] }),
|
|
35
|
+
cell: (context) => {
|
|
36
|
+
if (isReadyOnly == null ? void 0 : isReadyOnly(context)) {
|
|
37
|
+
return /* @__PURE__ */ jsx(DataGridReadonlyCell, { context });
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx(DataGridCurrencyCell, { code: currency, context });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
})) ?? [],
|
|
43
|
+
...(regions == null ? void 0 : regions.map((region) => {
|
|
44
|
+
const preference = pricePreferences == null ? void 0 : pricePreferences.find(
|
|
45
|
+
(p) => p.attribute === "region_id" && p.value === region.id
|
|
46
|
+
);
|
|
47
|
+
const translatedRegionName = `Price ${region.name}`;
|
|
48
|
+
return columnHelper.column({
|
|
49
|
+
id: `region_prices.${region.id}`,
|
|
50
|
+
name: translatedRegionName,
|
|
51
|
+
field: (context) => {
|
|
52
|
+
const isReadyOnlyValue = isReadyOnly == null ? void 0 : isReadyOnly(context);
|
|
53
|
+
if (isReadyOnlyValue) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return getFieldName(context, region.id);
|
|
57
|
+
},
|
|
58
|
+
type: "number",
|
|
59
|
+
header: () => /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-3", children: [
|
|
60
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", title: translatedRegionName, children: translatedRegionName }),
|
|
61
|
+
/* @__PURE__ */ jsx(IncludesTaxTooltip, { includesTax: preference == null ? void 0 : preference.is_tax_inclusive })
|
|
62
|
+
] }),
|
|
63
|
+
cell: (context) => {
|
|
64
|
+
if (isReadyOnly == null ? void 0 : isReadyOnly(context)) {
|
|
65
|
+
return /* @__PURE__ */ jsx(DataGridReadonlyCell, { context });
|
|
66
|
+
}
|
|
67
|
+
const currency = currencies == null ? void 0 : currencies.find((c) => c === region.currency_code);
|
|
68
|
+
if (!currency) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
DataGridCurrencyCell,
|
|
73
|
+
{
|
|
74
|
+
code: region.currency_code,
|
|
75
|
+
context
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
})) ?? []
|
|
81
|
+
];
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
createDataGridPriceColumns
|
|
85
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useDataGridCell } from "./use-data-grid-cell.js";
|
|
2
|
+
import { useDataGridCellError } from "./use-data-grid-cell-error.js";
|
|
3
|
+
import { useDataGridCellHandlers } from "./use-data-grid-cell-handlers.js";
|
|
4
|
+
import { useDataGridCellMetadata } from "./use-data-grid-cell-metadata.js";
|
|
5
|
+
import { useDataGridCellSnapshot } from "./use-data-grid-cell-snapshot.js";
|
|
6
|
+
import { useDataGridClipboardEvents } from "./use-data-grid-clipboard-events.js";
|
|
7
|
+
import { useDataGridColumnVisibility } from "./use-data-grid-column-visibility.js";
|
|
8
|
+
import { useDataGridDuplicateCell } from "./use-data-grid-duplicate-cell.js";
|
|
9
|
+
import { useDataGridErrorHighlighting } from "./use-data-grid-error-highlighting.js";
|
|
10
|
+
import { convertArrayToPrimitive, useDataGridFormHandlers } from "./use-data-grid-form-handlers.js";
|
|
11
|
+
import { useDataGridKeydownEvent } from "./use-data-grid-keydown-event.js";
|
|
12
|
+
import { useDataGridMouseUpEvent } from "./use-data-grid-mouse-up-event.js";
|
|
13
|
+
import { useDataGridNavigation } from "./use-data-grid-navigation.js";
|
|
14
|
+
import { useDataGridQueryTool } from "./use-data-grid-query-tool.js";
|
|
15
|
+
export {
|
|
16
|
+
convertArrayToPrimitive,
|
|
17
|
+
useDataGridCell,
|
|
18
|
+
useDataGridCellError,
|
|
19
|
+
useDataGridCellHandlers,
|
|
20
|
+
useDataGridCellMetadata,
|
|
21
|
+
useDataGridCellSnapshot,
|
|
22
|
+
useDataGridClipboardEvents,
|
|
23
|
+
useDataGridColumnVisibility,
|
|
24
|
+
useDataGridDuplicateCell,
|
|
25
|
+
useDataGridErrorHighlighting,
|
|
26
|
+
useDataGridFormHandlers,
|
|
27
|
+
useDataGridKeydownEvent,
|
|
28
|
+
useDataGridMouseUpEvent,
|
|
29
|
+
useDataGridNavigation,
|
|
30
|
+
useDataGridQueryTool
|
|
31
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { get } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
3
|
+
import "../context/data-grid-context.js";
|
|
4
|
+
import { useDataGridContext } from "../context/use-data-grid-context.js";
|
|
5
|
+
const useDataGridCellError = ({
|
|
6
|
+
context
|
|
7
|
+
}) => {
|
|
8
|
+
const { errors, getCellErrorMetadata, navigateToField } = useDataGridContext();
|
|
9
|
+
const { rowIndex, columnIndex } = context;
|
|
10
|
+
const { accessor, field } = useMemo(() => {
|
|
11
|
+
return getCellErrorMetadata({ row: rowIndex, col: columnIndex });
|
|
12
|
+
}, [rowIndex, columnIndex, getCellErrorMetadata]);
|
|
13
|
+
const rowErrorsObject = accessor && columnIndex === 0 ? get(errors, accessor) : void 0;
|
|
14
|
+
const rowErrors = [];
|
|
15
|
+
function collectErrors(errorObject, baseAccessor) {
|
|
16
|
+
if (!errorObject) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (isFieldError(errorObject)) {
|
|
20
|
+
const message = errorObject.message;
|
|
21
|
+
const to = () => navigateToField(baseAccessor);
|
|
22
|
+
if (message) {
|
|
23
|
+
rowErrors.push({ message, to });
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
Object.keys(errorObject).forEach((key) => {
|
|
27
|
+
const nestedError = errorObject[key];
|
|
28
|
+
const fieldAccessor = `${baseAccessor}.${key}`;
|
|
29
|
+
if (nestedError && typeof nestedError === "object") {
|
|
30
|
+
collectErrors(nestedError, fieldAccessor);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (rowErrorsObject && accessor) {
|
|
36
|
+
collectErrors(rowErrorsObject, accessor);
|
|
37
|
+
}
|
|
38
|
+
const cellError = field ? get(errors, field) : void 0;
|
|
39
|
+
return {
|
|
40
|
+
errors,
|
|
41
|
+
rowErrors,
|
|
42
|
+
cellError
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
function isFieldError(errors) {
|
|
46
|
+
return typeof errors === "object" && "message" in errors && "type" in errors;
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
useDataGridCellError
|
|
50
|
+
};
|