@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,249 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useDataTable, DataTable as DataTable$1, clx, Heading, Text, Button } from "@medusajs/ui";
|
|
3
|
+
import { useState, useCallback } from "react";
|
|
4
|
+
import { useSearchParams, useNavigate, Link } from "react-router-dom";
|
|
5
|
+
import { useQueryParams } from "../hooks/common/use-query-params.js";
|
|
6
|
+
import { ActionMenu } from "./action-menu.js";
|
|
7
|
+
const DataTable = ({
|
|
8
|
+
data = [],
|
|
9
|
+
columns,
|
|
10
|
+
filters,
|
|
11
|
+
commands,
|
|
12
|
+
action,
|
|
13
|
+
actionMenu,
|
|
14
|
+
getRowId,
|
|
15
|
+
rowCount = 0,
|
|
16
|
+
enablePagination = true,
|
|
17
|
+
enableSearch = true,
|
|
18
|
+
autoFocusSearch = false,
|
|
19
|
+
rowHref,
|
|
20
|
+
heading,
|
|
21
|
+
subHeading,
|
|
22
|
+
prefix,
|
|
23
|
+
pageSize = 10,
|
|
24
|
+
emptyState,
|
|
25
|
+
rowSelection,
|
|
26
|
+
isLoading = false,
|
|
27
|
+
layout = "auto"
|
|
28
|
+
}) => {
|
|
29
|
+
const enableFiltering = filters && filters.length > 0;
|
|
30
|
+
const enableCommands = commands && commands.length > 0;
|
|
31
|
+
const enableSorting = columns.some((column) => column.enableSorting);
|
|
32
|
+
const filterIds = (filters == null ? void 0 : filters.map((f) => f.id)) ?? [];
|
|
33
|
+
const prefixedFilterIds = filterIds.map((id) => getQueryParamKey(id, prefix));
|
|
34
|
+
const { offset, q, order, ...filterParams } = useQueryParams(
|
|
35
|
+
[
|
|
36
|
+
...filterIds,
|
|
37
|
+
...enableSorting ? ["order"] : [],
|
|
38
|
+
...enableSearch ? ["q"] : [],
|
|
39
|
+
...enablePagination ? ["offset"] : []
|
|
40
|
+
],
|
|
41
|
+
prefix
|
|
42
|
+
);
|
|
43
|
+
const [_, setSearchParams] = useSearchParams();
|
|
44
|
+
const [search, setSearch] = useState(q ?? "");
|
|
45
|
+
const handleSearchChange = (value) => {
|
|
46
|
+
setSearch(value);
|
|
47
|
+
setSearchParams((prev) => {
|
|
48
|
+
if (value) {
|
|
49
|
+
prev.set(getQueryParamKey("q", prefix), value);
|
|
50
|
+
} else {
|
|
51
|
+
prev.delete(getQueryParamKey("q", prefix));
|
|
52
|
+
}
|
|
53
|
+
return prev;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const [pagination, setPagination] = useState(
|
|
57
|
+
offset ? parsePaginationState(offset, pageSize) : { pageIndex: 0, pageSize }
|
|
58
|
+
);
|
|
59
|
+
const handlePaginationChange = (value) => {
|
|
60
|
+
setPagination(value);
|
|
61
|
+
setSearchParams((prev) => {
|
|
62
|
+
if (value.pageIndex === 0) {
|
|
63
|
+
prev.delete(getQueryParamKey("offset", prefix));
|
|
64
|
+
} else {
|
|
65
|
+
prev.set(
|
|
66
|
+
getQueryParamKey("offset", prefix),
|
|
67
|
+
transformPaginationState(value).toString()
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return prev;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const [filtering, setFiltering] = useState(
|
|
74
|
+
parseFilterState(filterIds, filterParams)
|
|
75
|
+
);
|
|
76
|
+
const handleFilteringChange = (value) => {
|
|
77
|
+
setFiltering(value);
|
|
78
|
+
setSearchParams((prev) => {
|
|
79
|
+
Array.from(prev.keys()).forEach((key) => {
|
|
80
|
+
if (prefixedFilterIds.includes(key) && !(key in value)) {
|
|
81
|
+
prev.delete(key);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.entries(value).forEach(([key, filter]) => {
|
|
85
|
+
if (prefixedFilterIds.includes(getQueryParamKey(key, prefix)) && filter) {
|
|
86
|
+
prev.set(getQueryParamKey(key, prefix), JSON.stringify(filter));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return prev;
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const [sorting, setSorting] = useState(
|
|
93
|
+
order ? parseSortingState(order) : null
|
|
94
|
+
);
|
|
95
|
+
const handleSortingChange = (value) => {
|
|
96
|
+
setSorting(value);
|
|
97
|
+
setSearchParams((prev) => {
|
|
98
|
+
if (value) {
|
|
99
|
+
const valueToStore = transformSortingState(value);
|
|
100
|
+
prev.set(getQueryParamKey("order", prefix), valueToStore);
|
|
101
|
+
} else {
|
|
102
|
+
prev.delete(getQueryParamKey("order", prefix));
|
|
103
|
+
}
|
|
104
|
+
return prev;
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
const navigate = useNavigate();
|
|
108
|
+
const onRowClick = useCallback(
|
|
109
|
+
(event, row) => {
|
|
110
|
+
if (!rowHref) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const href = rowHref(row);
|
|
114
|
+
if (event.metaKey || event.ctrlKey || event.button === 1) {
|
|
115
|
+
window.open(href, "_blank", "noreferrer");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (event.shiftKey) {
|
|
119
|
+
window.open(href, void 0, "noreferrer");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
navigate(href);
|
|
123
|
+
},
|
|
124
|
+
[navigate, rowHref]
|
|
125
|
+
);
|
|
126
|
+
const instance = useDataTable({
|
|
127
|
+
data,
|
|
128
|
+
columns,
|
|
129
|
+
filters,
|
|
130
|
+
commands,
|
|
131
|
+
rowCount,
|
|
132
|
+
getRowId,
|
|
133
|
+
onRowClick: rowHref ? onRowClick : void 0,
|
|
134
|
+
pagination: enablePagination ? {
|
|
135
|
+
state: pagination,
|
|
136
|
+
onPaginationChange: handlePaginationChange
|
|
137
|
+
} : void 0,
|
|
138
|
+
filtering: enableFiltering ? {
|
|
139
|
+
state: filtering,
|
|
140
|
+
onFilteringChange: handleFilteringChange
|
|
141
|
+
} : void 0,
|
|
142
|
+
sorting: enableSorting ? {
|
|
143
|
+
state: sorting,
|
|
144
|
+
onSortingChange: handleSortingChange
|
|
145
|
+
} : void 0,
|
|
146
|
+
search: enableSearch ? {
|
|
147
|
+
state: search,
|
|
148
|
+
onSearchChange: handleSearchChange
|
|
149
|
+
} : void 0,
|
|
150
|
+
rowSelection,
|
|
151
|
+
isLoading
|
|
152
|
+
});
|
|
153
|
+
const shouldRenderHeading = heading || subHeading;
|
|
154
|
+
return /* @__PURE__ */ jsxs(
|
|
155
|
+
DataTable$1,
|
|
156
|
+
{
|
|
157
|
+
instance,
|
|
158
|
+
className: clx({
|
|
159
|
+
"h-full [&_tr]:last-of-type:!border-b": layout === "fill"
|
|
160
|
+
}),
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ jsxs(DataTable$1.Toolbar, { className: "flex flex-col items-start justify-between gap-2 md:flex-row md:items-center", children: [
|
|
163
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
164
|
+
shouldRenderHeading && /* @__PURE__ */ jsxs("div", { children: [
|
|
165
|
+
heading && /* @__PURE__ */ jsx(Heading, { children: heading }),
|
|
166
|
+
subHeading && /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: subHeading })
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2 md:hidden", children: [
|
|
169
|
+
enableFiltering && /* @__PURE__ */ jsx(DataTable$1.FilterMenu, { tooltip: "Filter" }),
|
|
170
|
+
enableSorting && /* @__PURE__ */ jsx(DataTable$1.SortingMenu, { tooltip: "Sort" }),
|
|
171
|
+
actionMenu && /* @__PURE__ */ jsx(ActionMenu, { variant: "primary", ...actionMenu }),
|
|
172
|
+
action && /* @__PURE__ */ jsx(DataTableAction, { ...action })
|
|
173
|
+
] })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-2 md:justify-end", children: [
|
|
176
|
+
enableSearch && /* @__PURE__ */ jsx("div", { className: "w-full md:w-auto", children: /* @__PURE__ */ jsx(
|
|
177
|
+
DataTable$1.Search,
|
|
178
|
+
{
|
|
179
|
+
"data-modal-id": "modal-search-input",
|
|
180
|
+
placeholder: "Search",
|
|
181
|
+
autoFocus: autoFocusSearch
|
|
182
|
+
}
|
|
183
|
+
) }),
|
|
184
|
+
/* @__PURE__ */ jsxs("div", { className: "hidden items-center gap-x-2 md:flex", children: [
|
|
185
|
+
enableFiltering && /* @__PURE__ */ jsx(DataTable$1.FilterMenu, { tooltip: "Filter" }),
|
|
186
|
+
enableSorting && /* @__PURE__ */ jsx(DataTable$1.SortingMenu, { tooltip: "Sort" }),
|
|
187
|
+
actionMenu && /* @__PURE__ */ jsx(ActionMenu, { ...actionMenu }),
|
|
188
|
+
action && /* @__PURE__ */ jsx(DataTableAction, { ...action })
|
|
189
|
+
] })
|
|
190
|
+
] })
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ jsx(DataTable$1.Table, { emptyState }),
|
|
193
|
+
enablePagination && /* @__PURE__ */ jsx(DataTable$1.Pagination, {}),
|
|
194
|
+
enableCommands && /* @__PURE__ */ jsx(DataTable$1.CommandBar, { selectedLabel: (count) => `${count} selected` })
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
function transformSortingState(value) {
|
|
200
|
+
return value.desc ? `-${value.id}` : value.id;
|
|
201
|
+
}
|
|
202
|
+
function parseSortingState(value) {
|
|
203
|
+
return value.startsWith("-") ? { id: value.slice(1), desc: true } : { id: value, desc: false };
|
|
204
|
+
}
|
|
205
|
+
function transformPaginationState(value) {
|
|
206
|
+
return value.pageIndex * value.pageSize;
|
|
207
|
+
}
|
|
208
|
+
function parsePaginationState(value, pageSize) {
|
|
209
|
+
const offset = parseInt(value);
|
|
210
|
+
return {
|
|
211
|
+
pageIndex: Math.floor(offset / pageSize),
|
|
212
|
+
pageSize
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function parseFilterState(filterIds, value) {
|
|
216
|
+
if (!value) {
|
|
217
|
+
return {};
|
|
218
|
+
}
|
|
219
|
+
const filters = {};
|
|
220
|
+
for (const id of filterIds) {
|
|
221
|
+
const filterValue = value[id];
|
|
222
|
+
if (filterValue) {
|
|
223
|
+
filters[id] = JSON.parse(filterValue);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return filters;
|
|
227
|
+
}
|
|
228
|
+
function getQueryParamKey(key, prefix) {
|
|
229
|
+
return prefix ? `${prefix}_${key}` : key;
|
|
230
|
+
}
|
|
231
|
+
const DataTableAction = ({
|
|
232
|
+
label,
|
|
233
|
+
disabled,
|
|
234
|
+
...props
|
|
235
|
+
}) => {
|
|
236
|
+
const buttonProps = {
|
|
237
|
+
size: "small",
|
|
238
|
+
disabled: disabled ?? false,
|
|
239
|
+
type: "button",
|
|
240
|
+
variant: "secondary"
|
|
241
|
+
};
|
|
242
|
+
if ("to" in props) {
|
|
243
|
+
return /* @__PURE__ */ jsx(Button, { ...buttonProps, asChild: true, children: /* @__PURE__ */ jsx(Link, { to: props.to, children: label }) });
|
|
244
|
+
}
|
|
245
|
+
return /* @__PURE__ */ jsx(Button, { ...buttonProps, onClick: props.onClick, children: label });
|
|
246
|
+
};
|
|
247
|
+
export {
|
|
248
|
+
DataTable
|
|
249
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import copy from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/copy-to-clipboard/index.js";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Tooltip, clx, toast } from "@medusajs/ui";
|
|
5
|
+
function DisplayId({ id, className }) {
|
|
6
|
+
const [open, setOpen] = useState(false);
|
|
7
|
+
const onClick = () => {
|
|
8
|
+
copy(id);
|
|
9
|
+
toast.success("Copied to clipboard");
|
|
10
|
+
};
|
|
11
|
+
return /* @__PURE__ */ jsx(Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs("span", { onClick, className: clx("cursor-pointer", className), children: [
|
|
12
|
+
"#",
|
|
13
|
+
id.slice(-7)
|
|
14
|
+
] }) });
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
DisplayId as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowDownTray } from "@medusajs/icons";
|
|
3
|
+
import { clx, Text } from "@medusajs/ui";
|
|
4
|
+
import { useState, useRef } from "react";
|
|
5
|
+
const FileUpload = ({
|
|
6
|
+
label,
|
|
7
|
+
hint,
|
|
8
|
+
multiple = true,
|
|
9
|
+
hasError,
|
|
10
|
+
formats,
|
|
11
|
+
onUploaded
|
|
12
|
+
}) => {
|
|
13
|
+
const [isDragOver, setIsDragOver] = useState(false);
|
|
14
|
+
const inputRef = useRef(null);
|
|
15
|
+
const dropZoneRef = useRef(null);
|
|
16
|
+
const handleOpenFileSelector = () => {
|
|
17
|
+
var _a;
|
|
18
|
+
(_a = inputRef.current) == null ? void 0 : _a.click();
|
|
19
|
+
};
|
|
20
|
+
const handleDragEnter = (event) => {
|
|
21
|
+
var _a;
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
const files = (_a = event.dataTransfer) == null ? void 0 : _a.files;
|
|
25
|
+
if (!files) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setIsDragOver(true);
|
|
29
|
+
};
|
|
30
|
+
const handleDragLeave = (event) => {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
event.stopPropagation();
|
|
33
|
+
if (!dropZoneRef.current || dropZoneRef.current.contains(event.relatedTarget)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
setIsDragOver(false);
|
|
37
|
+
};
|
|
38
|
+
const handleUploaded = (files) => {
|
|
39
|
+
if (!files) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const fileList = Array.from(files);
|
|
43
|
+
const fileObj = fileList.map((file) => {
|
|
44
|
+
const id = Math.random().toString(36).substring(7);
|
|
45
|
+
const previewUrl = URL.createObjectURL(file);
|
|
46
|
+
return {
|
|
47
|
+
id,
|
|
48
|
+
url: previewUrl,
|
|
49
|
+
file
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
onUploaded(fileObj);
|
|
53
|
+
};
|
|
54
|
+
const handleDrop = (event) => {
|
|
55
|
+
var _a;
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
setIsDragOver(false);
|
|
59
|
+
handleUploaded((_a = event.dataTransfer) == null ? void 0 : _a.files);
|
|
60
|
+
};
|
|
61
|
+
const handleFileChange = async (event) => {
|
|
62
|
+
handleUploaded(event.target.files);
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
65
|
+
/* @__PURE__ */ jsxs(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
ref: dropZoneRef,
|
|
69
|
+
type: "button",
|
|
70
|
+
onClick: handleOpenFileSelector,
|
|
71
|
+
onDrop: handleDrop,
|
|
72
|
+
onDragOver: (e) => e.preventDefault(),
|
|
73
|
+
onDragEnter: handleDragEnter,
|
|
74
|
+
onDragLeave: handleDragLeave,
|
|
75
|
+
className: clx(
|
|
76
|
+
"bg-ui-bg-component border-ui-border-strong transition-fg group flex w-full flex-col items-center gap-y-2 rounded-lg border border-dashed p-8",
|
|
77
|
+
"hover:border-ui-border-interactive focus:border-ui-border-interactive",
|
|
78
|
+
"focus:shadow-borders-focus outline-none focus:border-solid",
|
|
79
|
+
{
|
|
80
|
+
"!border-ui-border-error": hasError,
|
|
81
|
+
"!border-ui-border-interactive": isDragOver
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
children: [
|
|
85
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle group-disabled:text-ui-fg-disabled flex items-center gap-x-2", children: [
|
|
86
|
+
/* @__PURE__ */ jsx(ArrowDownTray, {}),
|
|
87
|
+
/* @__PURE__ */ jsx(Text, { children: label })
|
|
88
|
+
] }),
|
|
89
|
+
!!hint && /* @__PURE__ */ jsx(
|
|
90
|
+
Text,
|
|
91
|
+
{
|
|
92
|
+
size: "small",
|
|
93
|
+
leading: "compact",
|
|
94
|
+
className: "text-ui-fg-muted group-disabled:text-ui-fg-disabled",
|
|
95
|
+
children: hint
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
),
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
"input",
|
|
103
|
+
{
|
|
104
|
+
hidden: true,
|
|
105
|
+
ref: inputRef,
|
|
106
|
+
onChange: handleFileChange,
|
|
107
|
+
type: "file",
|
|
108
|
+
accept: formats.join(","),
|
|
109
|
+
multiple
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] });
|
|
113
|
+
};
|
|
114
|
+
export {
|
|
115
|
+
FileUpload
|
|
116
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { InformationCircleSolid } from "@medusajs/icons";
|
|
3
|
+
import { clx, Label as Label$1, Tooltip, Text, Hint as Hint$1 } from "@medusajs/ui";
|
|
4
|
+
import { Slot } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/radix-ui/dist/index.mjs";
|
|
5
|
+
import { createContext, forwardRef, useId, useContext } from "react";
|
|
6
|
+
import { FormProvider, useFormContext, useFormState, Controller } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
7
|
+
const Provider = FormProvider;
|
|
8
|
+
const FormFieldContext = createContext(
|
|
9
|
+
{}
|
|
10
|
+
);
|
|
11
|
+
const Field = ({
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
15
|
+
};
|
|
16
|
+
const FormItemContext = createContext(
|
|
17
|
+
{}
|
|
18
|
+
);
|
|
19
|
+
const useFormField = () => {
|
|
20
|
+
const fieldContext = useContext(FormFieldContext);
|
|
21
|
+
const itemContext = useContext(FormItemContext);
|
|
22
|
+
const { getFieldState } = useFormContext();
|
|
23
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
24
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
25
|
+
if (!fieldContext) {
|
|
26
|
+
throw new Error("useFormField should be used within a FormField");
|
|
27
|
+
}
|
|
28
|
+
const { id } = itemContext;
|
|
29
|
+
return {
|
|
30
|
+
id,
|
|
31
|
+
name: fieldContext.name,
|
|
32
|
+
formItemId: `${id}-form-item`,
|
|
33
|
+
formLabelId: `${id}-form-item-label`,
|
|
34
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
35
|
+
formErrorMessageId: `${id}-form-item-message`,
|
|
36
|
+
...fieldState
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const Item = forwardRef(
|
|
40
|
+
({ className, ...props }, ref) => {
|
|
41
|
+
const id = useId();
|
|
42
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
ref,
|
|
46
|
+
className: clx("flex flex-col space-y-2", className),
|
|
47
|
+
...props
|
|
48
|
+
}
|
|
49
|
+
) });
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
Item.displayName = "Form.Item";
|
|
53
|
+
const Label = forwardRef(
|
|
54
|
+
({
|
|
55
|
+
className,
|
|
56
|
+
optional = false,
|
|
57
|
+
tooltip,
|
|
58
|
+
icon,
|
|
59
|
+
variant = "default",
|
|
60
|
+
...props
|
|
61
|
+
}, ref) => {
|
|
62
|
+
const { formLabelId, formItemId } = useFormField();
|
|
63
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
Label$1,
|
|
66
|
+
{
|
|
67
|
+
id: formLabelId,
|
|
68
|
+
ref,
|
|
69
|
+
className: clx(
|
|
70
|
+
{
|
|
71
|
+
"text-ui-fg-subtle": variant === "subtle"
|
|
72
|
+
},
|
|
73
|
+
className
|
|
74
|
+
),
|
|
75
|
+
htmlFor: formItemId,
|
|
76
|
+
size: "small",
|
|
77
|
+
weight: variant === "default" ? "plus" : "regular",
|
|
78
|
+
...props
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { content: tooltip, children: /* @__PURE__ */ jsx(InformationCircleSolid, { className: "text-ui-fg-muted" }) }),
|
|
82
|
+
icon,
|
|
83
|
+
optional && /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-muted", children: "(Optional)" })
|
|
84
|
+
] });
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
Label.displayName = "Form.Label";
|
|
88
|
+
const Control = forwardRef(({ ...props }, ref) => {
|
|
89
|
+
const {
|
|
90
|
+
error,
|
|
91
|
+
formItemId,
|
|
92
|
+
formDescriptionId,
|
|
93
|
+
formErrorMessageId,
|
|
94
|
+
formLabelId
|
|
95
|
+
} = useFormField();
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
Slot.Root,
|
|
98
|
+
{
|
|
99
|
+
ref,
|
|
100
|
+
id: formItemId,
|
|
101
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formErrorMessageId}`,
|
|
102
|
+
"aria-invalid": !!error,
|
|
103
|
+
"aria-labelledby": formLabelId,
|
|
104
|
+
...props
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
Control.displayName = "Form.Control";
|
|
109
|
+
const Hint = forwardRef(({ className, ...props }, ref) => {
|
|
110
|
+
const { formDescriptionId } = useFormField();
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
Hint$1,
|
|
113
|
+
{
|
|
114
|
+
ref,
|
|
115
|
+
id: formDescriptionId,
|
|
116
|
+
className,
|
|
117
|
+
...props
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
Hint.displayName = "Form.Hint";
|
|
122
|
+
const ErrorMessage = forwardRef(({ className, children, ...props }, ref) => {
|
|
123
|
+
const { error, formErrorMessageId } = useFormField();
|
|
124
|
+
const msg = error ? String(error == null ? void 0 : error.message) : children;
|
|
125
|
+
if (!msg || msg === "undefined") {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
Hint$1,
|
|
130
|
+
{
|
|
131
|
+
ref,
|
|
132
|
+
id: formErrorMessageId,
|
|
133
|
+
className,
|
|
134
|
+
variant: error ? "error" : "info",
|
|
135
|
+
...props,
|
|
136
|
+
children: msg
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
ErrorMessage.displayName = "Form.ErrorMessage";
|
|
141
|
+
const Form = Object.assign(Provider, {
|
|
142
|
+
Item,
|
|
143
|
+
Label,
|
|
144
|
+
Control,
|
|
145
|
+
Hint,
|
|
146
|
+
ErrorMessage,
|
|
147
|
+
Field
|
|
148
|
+
});
|
|
149
|
+
export {
|
|
150
|
+
Form
|
|
151
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text, Input } from "@medusajs/ui";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
const HandleInput = forwardRef((props, ref) => {
|
|
5
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
6
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
|
|
7
|
+
Text,
|
|
8
|
+
{
|
|
9
|
+
className: "text-ui-fg-muted",
|
|
10
|
+
size: "small",
|
|
11
|
+
leading: "compact",
|
|
12
|
+
weight: "plus",
|
|
13
|
+
children: "/"
|
|
14
|
+
}
|
|
15
|
+
) }),
|
|
16
|
+
/* @__PURE__ */ jsx(Input, { ref, ...props, className: "pl-10" })
|
|
17
|
+
] });
|
|
18
|
+
});
|
|
19
|
+
HandleInput.displayName = "HandleInput";
|
|
20
|
+
export {
|
|
21
|
+
HandleInput
|
|
22
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { InformationCircleSolid } from "@medusajs/icons";
|
|
4
|
+
import { Heading, Text, Tooltip, Button } from "@medusajs/ui";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
import { ActionMenu } from "./action-menu.js";
|
|
7
|
+
const Header = ({
|
|
8
|
+
title,
|
|
9
|
+
subtitle,
|
|
10
|
+
actions = [],
|
|
11
|
+
tooltip
|
|
12
|
+
}) => {
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex px-6 py-4", children: [
|
|
14
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between w-full", children: [
|
|
15
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
16
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: title }),
|
|
17
|
+
subtitle && /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", size: "small", children: subtitle })
|
|
18
|
+
] }),
|
|
19
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { content: tooltip, children: /* @__PURE__ */ jsx(InformationCircleSolid, { className: "text-ui-fg-muted" }) })
|
|
20
|
+
] }),
|
|
21
|
+
actions.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-x-2", children: actions.map((action, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
action.type === "button" && /* @__PURE__ */ createElement(
|
|
23
|
+
Button,
|
|
24
|
+
{
|
|
25
|
+
...action.props,
|
|
26
|
+
size: action.props.size || "small",
|
|
27
|
+
key: index
|
|
28
|
+
},
|
|
29
|
+
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
+
action.props.children,
|
|
31
|
+
action.link && /* @__PURE__ */ jsx(Link, { ...action.link })
|
|
32
|
+
] })
|
|
33
|
+
),
|
|
34
|
+
action.type === "action-menu" && /* @__PURE__ */ jsx(ActionMenu, { ...action.props }),
|
|
35
|
+
action.type === "custom" && action.children
|
|
36
|
+
] })) })
|
|
37
|
+
] });
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
Header
|
|
41
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { clx } from "@medusajs/ui";
|
|
3
|
+
const IconAvatar = ({
|
|
4
|
+
size = "small",
|
|
5
|
+
children,
|
|
6
|
+
className
|
|
7
|
+
}) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: clx(
|
|
12
|
+
"shadow-borders-base flex size-7 items-center justify-center",
|
|
13
|
+
"[&>div]:bg-ui-bg-field [&>div]:text-ui-fg-subtle [&>div]:flex [&>div]:size-6 [&>div]:items-center [&>div]:justify-center",
|
|
14
|
+
{
|
|
15
|
+
"size-7 rounded-md [&>div]:size-6 [&>div]:rounded-[4px]": size === "small",
|
|
16
|
+
"size-10 rounded-lg [&>div]:size-9 [&>div]:rounded-[6px]": size === "large",
|
|
17
|
+
"size-12 rounded-xl [&>div]:size-11 [&>div]:rounded-[10px]": size === "xlarge"
|
|
18
|
+
},
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
children: /* @__PURE__ */ jsx("div", { children })
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
IconAvatar
|
|
27
|
+
};
|