@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,139 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowUpRightOnBox, XMarkMini, TriangleDownMini, Check, SquareTwoStack } from "@medusajs/icons";
|
|
3
|
+
import { Container, Heading, Badge, Drawer, IconButton, Kbd } from "@medusajs/ui";
|
|
4
|
+
import Primitive from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@uiw/react-json-view/esm/index.js";
|
|
5
|
+
import { Suspense, useState } from "react";
|
|
6
|
+
const JsonViewSection = ({ data }) => {
|
|
7
|
+
const numberOfKeys = Object.keys(data).length;
|
|
8
|
+
return /* @__PURE__ */ jsxs(Container, { className: "flex items-center justify-between px-6 py-4", children: [
|
|
9
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
10
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "JSON" }),
|
|
11
|
+
/* @__PURE__ */ jsxs(Badge, { size: "2xsmall", rounded: "full", children: [
|
|
12
|
+
numberOfKeys,
|
|
13
|
+
" keys"
|
|
14
|
+
] })
|
|
15
|
+
] }),
|
|
16
|
+
/* @__PURE__ */ jsxs(Drawer, { children: [
|
|
17
|
+
/* @__PURE__ */ jsx(Drawer.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
18
|
+
IconButton,
|
|
19
|
+
{
|
|
20
|
+
size: "small",
|
|
21
|
+
variant: "transparent",
|
|
22
|
+
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
23
|
+
children: /* @__PURE__ */ jsx(ArrowUpRightOnBox, {})
|
|
24
|
+
}
|
|
25
|
+
) }),
|
|
26
|
+
/* @__PURE__ */ jsxs(Drawer.Content, { className: "bg-ui-contrast-bg-base text-ui-code-fg-subtle !shadow-elevation-commandbar overflow-hidden border border-none max-md:inset-x-2 max-md:max-w-[calc(100%-16px)]", children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-code-bg-base flex items-center justify-between px-6 py-4", children: [
|
|
28
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsx(Drawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { className: "text-ui-contrast-fg-primary", children: /* @__PURE__ */ jsx("span", { className: "text-ui-fg-subtle", children: numberOfKeys }) }) }) }),
|
|
29
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
30
|
+
/* @__PURE__ */ jsx(Kbd, { className: "bg-ui-contrast-bg-subtle border-ui-contrast-border-base text-ui-contrast-fg-secondary", children: "esc" }),
|
|
31
|
+
/* @__PURE__ */ jsx(Drawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
32
|
+
IconButton,
|
|
33
|
+
{
|
|
34
|
+
size: "small",
|
|
35
|
+
variant: "transparent",
|
|
36
|
+
className: "text-ui-contrast-fg-secondary hover:text-ui-contrast-fg-primary hover:bg-ui-contrast-bg-base-hover active:bg-ui-contrast-bg-base-pressed focus-visible:bg-ui-contrast-bg-base-hover focus-visible:shadow-borders-interactive-with-active",
|
|
37
|
+
children: /* @__PURE__ */ jsx(XMarkMini, {})
|
|
38
|
+
}
|
|
39
|
+
) })
|
|
40
|
+
] })
|
|
41
|
+
] }),
|
|
42
|
+
/* @__PURE__ */ jsx(Drawer.Body, { className: "flex flex-1 flex-col overflow-hidden px-[5px] py-0 pb-[5px]", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-contrast-bg-subtle flex-1 overflow-auto rounded-b-[4px] rounded-t-lg p-3", children: /* @__PURE__ */ jsx(
|
|
43
|
+
Suspense,
|
|
44
|
+
{
|
|
45
|
+
fallback: /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col" }),
|
|
46
|
+
children: /* @__PURE__ */ jsxs(
|
|
47
|
+
Primitive,
|
|
48
|
+
{
|
|
49
|
+
value: data,
|
|
50
|
+
displayDataTypes: false,
|
|
51
|
+
style: {
|
|
52
|
+
"--w-rjv-font-family": "Roboto Mono, monospace",
|
|
53
|
+
"--w-rjv-line-color": "var(--contrast-border-base)",
|
|
54
|
+
"--w-rjv-curlybraces-color": "var(--contrast-fg-secondary)",
|
|
55
|
+
"--w-rjv-brackets-color": "var(--contrast-fg-secondary)",
|
|
56
|
+
"--w-rjv-key-string": "var(--contrast-fg-primary)",
|
|
57
|
+
"--w-rjv-info-color": "var(--contrast-fg-secondary)",
|
|
58
|
+
"--w-rjv-type-string-color": "var(--tag-green-icon)",
|
|
59
|
+
"--w-rjv-quotes-string-color": "var(--tag-green-icon)",
|
|
60
|
+
"--w-rjv-type-boolean-color": "var(--tag-orange-icon)",
|
|
61
|
+
"--w-rjv-type-int-color": "var(--tag-orange-icon)",
|
|
62
|
+
"--w-rjv-type-float-color": "var(--tag-orange-icon)",
|
|
63
|
+
"--w-rjv-type-bigint-color": "var(--tag-orange-icon)",
|
|
64
|
+
"--w-rjv-key-number": "var(--contrast-fg-secondary)",
|
|
65
|
+
"--w-rjv-arrow-color": "var(--contrast-fg-secondary)",
|
|
66
|
+
"--w-rjv-copied-color": "var(--contrast-fg-secondary)",
|
|
67
|
+
"--w-rjv-copied-success-color": "var(--contrast-fg-primary)",
|
|
68
|
+
"--w-rjv-colon-color": "var(--contrast-fg-primary)",
|
|
69
|
+
"--w-rjv-ellipsis-color": "var(--contrast-fg-secondary)"
|
|
70
|
+
},
|
|
71
|
+
collapsed: 1,
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(Primitive.Quote, { render: () => /* @__PURE__ */ jsx("span", {}) }),
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
Primitive.Null,
|
|
76
|
+
{
|
|
77
|
+
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-red-icon", children: "null" })
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
Primitive.Undefined,
|
|
82
|
+
{
|
|
83
|
+
render: () => /* @__PURE__ */ jsx("span", { className: "text-ui-tag-blue-icon", children: "undefined" })
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
Primitive.CountInfo,
|
|
88
|
+
{
|
|
89
|
+
render: (_props, { value }) => {
|
|
90
|
+
return /* @__PURE__ */ jsxs("span", { className: "text-ui-contrast-fg-secondary ml-2", children: [
|
|
91
|
+
Object.keys(value).length,
|
|
92
|
+
" items"
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
/* @__PURE__ */ jsx(Primitive.Arrow, { children: /* @__PURE__ */ jsx(TriangleDownMini, { className: "text-ui-contrast-fg-secondary -ml-[0.5px]" }) }),
|
|
98
|
+
/* @__PURE__ */ jsx(Primitive.Colon, { children: /* @__PURE__ */ jsx("span", { className: "mr-1", children: ":" }) }),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
Primitive.Copied,
|
|
101
|
+
{
|
|
102
|
+
render: ({ style }, { value }) => {
|
|
103
|
+
return /* @__PURE__ */ jsx(Copied, { style, value });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
) }) })
|
|
112
|
+
] })
|
|
113
|
+
] })
|
|
114
|
+
] });
|
|
115
|
+
};
|
|
116
|
+
const Copied = ({ style, value }) => {
|
|
117
|
+
const [copied, setCopied] = useState(false);
|
|
118
|
+
const handler = (e) => {
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
setCopied(true);
|
|
121
|
+
if (typeof value === "string") {
|
|
122
|
+
navigator.clipboard.writeText(value);
|
|
123
|
+
} else {
|
|
124
|
+
const json = JSON.stringify(value, null, 2);
|
|
125
|
+
navigator.clipboard.writeText(json);
|
|
126
|
+
}
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
setCopied(false);
|
|
129
|
+
}, 2e3);
|
|
130
|
+
};
|
|
131
|
+
const styl = { whiteSpace: "nowrap", width: "20px" };
|
|
132
|
+
if (copied) {
|
|
133
|
+
return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, children: /* @__PURE__ */ jsx(Check, { className: "text-ui-contrast-fg-primary" }) });
|
|
134
|
+
}
|
|
135
|
+
return /* @__PURE__ */ jsx("span", { style: { ...style, ...styl }, onClick: handler, children: /* @__PURE__ */ jsx(SquareTwoStack, { className: "text-ui-contrast-fg-secondary" }) });
|
|
136
|
+
};
|
|
137
|
+
export {
|
|
138
|
+
JsonViewSection
|
|
139
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
const KeyboundForm = React.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
|
|
4
|
+
const handleSubmit = (event) => {
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
onSubmit == null ? void 0 : onSubmit(event);
|
|
7
|
+
};
|
|
8
|
+
const handleKeyDown = (event) => {
|
|
9
|
+
if (event.key === "Enter") {
|
|
10
|
+
if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
if (event.metaKey || event.ctrlKey) {
|
|
15
|
+
handleSubmit(event);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
"form",
|
|
21
|
+
{
|
|
22
|
+
...rest,
|
|
23
|
+
onSubmit: handleSubmit,
|
|
24
|
+
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
25
|
+
ref
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
KeyboundForm.displayName = "KeyboundForm";
|
|
30
|
+
export {
|
|
31
|
+
KeyboundForm
|
|
32
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
const TwoColumnLayout = ({
|
|
3
|
+
firstCol,
|
|
4
|
+
secondCol
|
|
5
|
+
}) => {
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start", children: [
|
|
7
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-y-3", children: firstCol }),
|
|
8
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]", children: secondCol })
|
|
9
|
+
] });
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
TwoColumnLayout
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "@medusajs/ui";
|
|
3
|
+
const Listicle = ({
|
|
4
|
+
labelKey,
|
|
5
|
+
descriptionKey,
|
|
6
|
+
children,
|
|
7
|
+
icon
|
|
8
|
+
}) => {
|
|
9
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
|
|
10
|
+
icon && /* @__PURE__ */ jsx("div", { children: icon }),
|
|
11
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col", children: [
|
|
12
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", children: labelKey }),
|
|
13
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: descriptionKey })
|
|
14
|
+
] }),
|
|
15
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-7 items-center justify-center", children })
|
|
16
|
+
] }) }) });
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
Listicle
|
|
20
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RouteDrawer } from "./route-drawer/route-drawer.js";
|
|
2
|
+
import { RouteFocusModal } from "./route-focus-modal/route-focus-modal.js";
|
|
3
|
+
import "react/jsx-runtime";
|
|
4
|
+
import "react";
|
|
5
|
+
import "react-router-dom";
|
|
6
|
+
import "./route-modal-provider/route-modal-context.js";
|
|
7
|
+
import { useRouteModal } from "./route-modal-provider/use-route-modal.js";
|
|
8
|
+
import { StackedDrawer } from "./stacked-drawer/stacked-drawer.js";
|
|
9
|
+
import { StackedFocusModal } from "./stacked-focus-modal/stacked-focus-modal.js";
|
|
10
|
+
import "./stacked-modal-provider/stacked-modal-context.js";
|
|
11
|
+
import { useStackedModal } from "./stacked-modal-provider/use-stacked-modal.js";
|
|
12
|
+
export {
|
|
13
|
+
RouteDrawer,
|
|
14
|
+
RouteFocusModal,
|
|
15
|
+
StackedDrawer,
|
|
16
|
+
StackedFocusModal,
|
|
17
|
+
useRouteModal,
|
|
18
|
+
useStackedModal
|
|
19
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Drawer, clx } from "@medusajs/ui";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { useNavigate } from "react-router-dom";
|
|
5
|
+
import { RouteModalForm } from "../route-modal-form/route-modal-form.js";
|
|
6
|
+
import { RouteModalProvider } from "../route-modal-provider/route-provider.js";
|
|
7
|
+
import { StackedModalProvider } from "../stacked-modal-provider/stacked-modal-provider.js";
|
|
8
|
+
import "../stacked-modal-provider/stacked-modal-context.js";
|
|
9
|
+
const Root = ({ prev = "..", children }) => {
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
const [open, setOpen] = useState(false);
|
|
12
|
+
const [stackedModalOpen, onStackedModalOpen] = useState(false);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
setOpen(true);
|
|
15
|
+
return () => {
|
|
16
|
+
setOpen(false);
|
|
17
|
+
onStackedModalOpen(false);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
const handleOpenChange = (open2) => {
|
|
21
|
+
if (!open2) {
|
|
22
|
+
document.body.style.pointerEvents = "auto";
|
|
23
|
+
navigate(prev, { replace: true });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
setOpen(open2);
|
|
27
|
+
};
|
|
28
|
+
return /* @__PURE__ */ jsx(Drawer, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsx(RouteModalProvider, { prev, children: /* @__PURE__ */ jsx(StackedModalProvider, { onOpenChange: onStackedModalOpen, children: /* @__PURE__ */ jsx(
|
|
29
|
+
Drawer.Content,
|
|
30
|
+
{
|
|
31
|
+
"aria-describedby": void 0,
|
|
32
|
+
className: clx({
|
|
33
|
+
"!bg-ui-bg-disabled !inset-y-5 !right-5": stackedModalOpen
|
|
34
|
+
}),
|
|
35
|
+
children
|
|
36
|
+
}
|
|
37
|
+
) }) }) });
|
|
38
|
+
};
|
|
39
|
+
const Header = Drawer.Header;
|
|
40
|
+
const Title = Drawer.Title;
|
|
41
|
+
const Description = Drawer.Description;
|
|
42
|
+
const Body = Drawer.Body;
|
|
43
|
+
const Footer = Drawer.Footer;
|
|
44
|
+
const Close = Drawer.Close;
|
|
45
|
+
const Form = RouteModalForm;
|
|
46
|
+
const RouteDrawer = Object.assign(Root, {
|
|
47
|
+
Header,
|
|
48
|
+
Title,
|
|
49
|
+
Body,
|
|
50
|
+
Description,
|
|
51
|
+
Footer,
|
|
52
|
+
Close,
|
|
53
|
+
Form
|
|
54
|
+
});
|
|
55
|
+
export {
|
|
56
|
+
RouteDrawer
|
|
57
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FocusModal, clx } from "@medusajs/ui";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { useNavigate } from "react-router-dom";
|
|
5
|
+
import { RouteModalForm } from "../route-modal-form/route-modal-form.js";
|
|
6
|
+
import { RouteModalProvider } from "../route-modal-provider/route-provider.js";
|
|
7
|
+
import { useRouteModal } from "../route-modal-provider/use-route-modal.js";
|
|
8
|
+
import { StackedModalProvider } from "../stacked-modal-provider/stacked-modal-provider.js";
|
|
9
|
+
import "../stacked-modal-provider/stacked-modal-context.js";
|
|
10
|
+
const Root = ({ prev = "..", onClose, children }) => {
|
|
11
|
+
const navigate = useNavigate();
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const [stackedModalOpen, onStackedModalOpen] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setOpen(true);
|
|
16
|
+
return () => {
|
|
17
|
+
setOpen(false);
|
|
18
|
+
onStackedModalOpen(false);
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
const handleOpenChange = async (open2) => {
|
|
22
|
+
if (!open2) {
|
|
23
|
+
if (onClose) {
|
|
24
|
+
const ret = await onClose();
|
|
25
|
+
if (!ret) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
document.body.style.pointerEvents = "auto";
|
|
30
|
+
navigate(prev, { replace: true });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
setOpen(open2);
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ jsx(FocusModal, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsx(RouteModalProvider, { prev, children: /* @__PURE__ */ jsx(StackedModalProvider, { onOpenChange: onStackedModalOpen, children: /* @__PURE__ */ jsx(Content, { stackedModalOpen, children }) }) }) });
|
|
36
|
+
};
|
|
37
|
+
const Content = ({ stackedModalOpen, children }) => {
|
|
38
|
+
const { __internal } = useRouteModal();
|
|
39
|
+
const shouldPreventClose = !__internal.closeOnEscape;
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
FocusModal.Content,
|
|
42
|
+
{
|
|
43
|
+
onEscapeKeyDown: shouldPreventClose ? (e) => {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
} : void 0,
|
|
46
|
+
className: clx({
|
|
47
|
+
"!bg-ui-bg-disabled !inset-x-5 !inset-y-3": stackedModalOpen
|
|
48
|
+
}),
|
|
49
|
+
children
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
const Header = FocusModal.Header;
|
|
54
|
+
const Title = FocusModal.Title;
|
|
55
|
+
const Description = FocusModal.Description;
|
|
56
|
+
const Footer = FocusModal.Footer;
|
|
57
|
+
const Body = FocusModal.Body;
|
|
58
|
+
const Close = FocusModal.Close;
|
|
59
|
+
const Form = RouteModalForm;
|
|
60
|
+
const RouteFocusModal = Object.assign(Root, {
|
|
61
|
+
Header,
|
|
62
|
+
Title,
|
|
63
|
+
Body,
|
|
64
|
+
Description,
|
|
65
|
+
Footer,
|
|
66
|
+
Close,
|
|
67
|
+
Form
|
|
68
|
+
});
|
|
69
|
+
export {
|
|
70
|
+
RouteFocusModal
|
|
71
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Prompt } from "@medusajs/ui";
|
|
3
|
+
import { useBlocker } from "react-router-dom";
|
|
4
|
+
import { Form } from "../../form.js";
|
|
5
|
+
const RouteModalForm = ({
|
|
6
|
+
form,
|
|
7
|
+
blockSearchParams: blockSearch = false,
|
|
8
|
+
children,
|
|
9
|
+
onClose
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
formState: { isDirty }
|
|
13
|
+
} = form;
|
|
14
|
+
const blocker = useBlocker(({ currentLocation, nextLocation }) => {
|
|
15
|
+
const { isSubmitSuccessful } = nextLocation.state || {};
|
|
16
|
+
if (isSubmitSuccessful) {
|
|
17
|
+
onClose == null ? void 0 : onClose(true);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const isPathChanged = currentLocation.pathname !== nextLocation.pathname;
|
|
21
|
+
const isSearchChanged = currentLocation.search !== nextLocation.search;
|
|
22
|
+
if (blockSearch) {
|
|
23
|
+
const ret2 = isDirty && (isPathChanged || isSearchChanged);
|
|
24
|
+
if (!ret2) {
|
|
25
|
+
onClose == null ? void 0 : onClose(isSubmitSuccessful);
|
|
26
|
+
}
|
|
27
|
+
return ret2;
|
|
28
|
+
}
|
|
29
|
+
const ret = isDirty && isPathChanged;
|
|
30
|
+
if (!ret) {
|
|
31
|
+
onClose == null ? void 0 : onClose(isSubmitSuccessful);
|
|
32
|
+
}
|
|
33
|
+
return ret;
|
|
34
|
+
});
|
|
35
|
+
const handleCancel = () => {
|
|
36
|
+
var _a;
|
|
37
|
+
(_a = blocker == null ? void 0 : blocker.reset) == null ? void 0 : _a.call(blocker);
|
|
38
|
+
};
|
|
39
|
+
const handleContinue = () => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = blocker == null ? void 0 : blocker.proceed) == null ? void 0 : _a.call(blocker);
|
|
42
|
+
onClose == null ? void 0 : onClose(false);
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ jsxs(Form, { ...form, children: [
|
|
45
|
+
children,
|
|
46
|
+
/* @__PURE__ */ jsx(Prompt, { open: blocker.state === "blocked", variant: "confirmation", children: /* @__PURE__ */ jsxs(Prompt.Content, { children: [
|
|
47
|
+
/* @__PURE__ */ jsxs(Prompt.Header, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Prompt.Title, { children: "Unsaved Changes" }),
|
|
49
|
+
/* @__PURE__ */ jsx(Prompt.Description, { children: "You have unsaved changes. Are you sure you want to leave?" })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ jsxs(Prompt.Footer, { children: [
|
|
52
|
+
/* @__PURE__ */ jsx(Prompt.Cancel, { onClick: handleCancel, type: "button", children: "Cancel" }),
|
|
53
|
+
/* @__PURE__ */ jsx(Prompt.Action, { onClick: handleContinue, type: "button", children: "Continue" })
|
|
54
|
+
] })
|
|
55
|
+
] }) })
|
|
56
|
+
] });
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
RouteModalForm
|
|
60
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useCallback, useMemo } from "react";
|
|
3
|
+
import { useNavigate } from "react-router-dom";
|
|
4
|
+
import { RouteModalProviderContext } from "./route-modal-context.js";
|
|
5
|
+
const RouteModalProvider = ({
|
|
6
|
+
prev,
|
|
7
|
+
children
|
|
8
|
+
}) => {
|
|
9
|
+
const navigate = useNavigate();
|
|
10
|
+
const [closeOnEscape, setCloseOnEscape] = useState(true);
|
|
11
|
+
const handleSuccess = useCallback(
|
|
12
|
+
(path) => {
|
|
13
|
+
const to = path || prev;
|
|
14
|
+
navigate(to, { replace: true, state: { isSubmitSuccessful: true } });
|
|
15
|
+
},
|
|
16
|
+
[navigate, prev]
|
|
17
|
+
);
|
|
18
|
+
const value = useMemo(
|
|
19
|
+
() => ({
|
|
20
|
+
handleSuccess,
|
|
21
|
+
setCloseOnEscape,
|
|
22
|
+
__internal: { closeOnEscape }
|
|
23
|
+
}),
|
|
24
|
+
[handleSuccess, setCloseOnEscape, closeOnEscape]
|
|
25
|
+
);
|
|
26
|
+
return /* @__PURE__ */ jsx(RouteModalProviderContext.Provider, { value, children });
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
RouteModalProvider
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { RouteModalProviderContext } from "./route-modal-context.js";
|
|
3
|
+
const useRouteModal = () => {
|
|
4
|
+
const context = useContext(RouteModalProviderContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error("useRouteModal must be used within a RouteModalProvider");
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
useRouteModal
|
|
12
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Drawer, clx } from "@medusajs/ui";
|
|
3
|
+
import { forwardRef, useEffect } from "react";
|
|
4
|
+
import "../stacked-modal-provider/stacked-modal-context.js";
|
|
5
|
+
import { useStackedModal } from "../stacked-modal-provider/use-stacked-modal.js";
|
|
6
|
+
const Root = ({ id, children }) => {
|
|
7
|
+
const { register, unregister, getIsOpen, setIsOpen } = useStackedModal();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
register(id);
|
|
10
|
+
return () => unregister(id);
|
|
11
|
+
}, []);
|
|
12
|
+
return /* @__PURE__ */ jsx(Drawer, { open: getIsOpen(id), onOpenChange: (open) => setIsOpen(id, open), children });
|
|
13
|
+
};
|
|
14
|
+
const Close = Drawer.Close;
|
|
15
|
+
Close.displayName = "StackedDrawer.Close";
|
|
16
|
+
const Header = Drawer.Header;
|
|
17
|
+
Header.displayName = "StackedDrawer.Header";
|
|
18
|
+
const Body = Drawer.Body;
|
|
19
|
+
Body.displayName = "StackedDrawer.Body";
|
|
20
|
+
const Trigger = Drawer.Trigger;
|
|
21
|
+
Trigger.displayName = "StackedDrawer.Trigger";
|
|
22
|
+
const Footer = Drawer.Footer;
|
|
23
|
+
Footer.displayName = "StackedDrawer.Footer";
|
|
24
|
+
const Title = Drawer.Title;
|
|
25
|
+
Title.displayName = "StackedDrawer.Title";
|
|
26
|
+
const Description = Drawer.Description;
|
|
27
|
+
Description.displayName = "StackedDrawer.Description";
|
|
28
|
+
const Content = forwardRef(({ className, ...props }, ref) => {
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
Drawer.Content,
|
|
31
|
+
{
|
|
32
|
+
ref,
|
|
33
|
+
className: clx(className),
|
|
34
|
+
overlayProps: {
|
|
35
|
+
className: "bg-transparent"
|
|
36
|
+
},
|
|
37
|
+
...props
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
Content.displayName = "StackedDrawer.Content";
|
|
42
|
+
const StackedDrawer = Object.assign(Root, {
|
|
43
|
+
Close,
|
|
44
|
+
Header,
|
|
45
|
+
Body,
|
|
46
|
+
Content,
|
|
47
|
+
Trigger,
|
|
48
|
+
Footer,
|
|
49
|
+
Description,
|
|
50
|
+
Title
|
|
51
|
+
});
|
|
52
|
+
export {
|
|
53
|
+
Root,
|
|
54
|
+
StackedDrawer
|
|
55
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { FocusModal, clx } from "@medusajs/ui";
|
|
3
|
+
import { forwardRef, useEffect } from "react";
|
|
4
|
+
import "../stacked-modal-provider/stacked-modal-context.js";
|
|
5
|
+
import { useStackedModal } from "../stacked-modal-provider/use-stacked-modal.js";
|
|
6
|
+
const Root = ({
|
|
7
|
+
id,
|
|
8
|
+
onOpenChangeCallback,
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const { register, unregister, getIsOpen, setIsOpen } = useStackedModal();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
register(id);
|
|
14
|
+
return () => unregister(id);
|
|
15
|
+
}, []);
|
|
16
|
+
const handleOpenChange = (open) => {
|
|
17
|
+
setIsOpen(id, open);
|
|
18
|
+
onOpenChangeCallback == null ? void 0 : onOpenChangeCallback(open);
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsx(FocusModal, { open: getIsOpen(id), onOpenChange: handleOpenChange, children });
|
|
21
|
+
};
|
|
22
|
+
const Close = FocusModal.Close;
|
|
23
|
+
Close.displayName = "StackedFocusModal.Close";
|
|
24
|
+
const Header = FocusModal.Header;
|
|
25
|
+
Header.displayName = "StackedFocusModal.Header";
|
|
26
|
+
const Body = FocusModal.Body;
|
|
27
|
+
Body.displayName = "StackedFocusModal.Body";
|
|
28
|
+
const Trigger = FocusModal.Trigger;
|
|
29
|
+
Trigger.displayName = "StackedFocusModal.Trigger";
|
|
30
|
+
const Footer = FocusModal.Footer;
|
|
31
|
+
Footer.displayName = "StackedFocusModal.Footer";
|
|
32
|
+
const Title = FocusModal.Title;
|
|
33
|
+
Title.displayName = "StackedFocusModal.Title";
|
|
34
|
+
const Description = FocusModal.Description;
|
|
35
|
+
Description.displayName = "StackedFocusModal.Description";
|
|
36
|
+
const Content = forwardRef(({ className, ...props }, ref) => {
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
FocusModal.Content,
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
className: clx("!top-6", className),
|
|
42
|
+
overlayProps: {
|
|
43
|
+
className: "bg-transparent"
|
|
44
|
+
},
|
|
45
|
+
...props
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
Content.displayName = "StackedFocusModal.Content";
|
|
50
|
+
const StackedFocusModal = Object.assign(Root, {
|
|
51
|
+
Close,
|
|
52
|
+
Header,
|
|
53
|
+
Body,
|
|
54
|
+
Content,
|
|
55
|
+
Trigger,
|
|
56
|
+
Footer,
|
|
57
|
+
Description,
|
|
58
|
+
Title
|
|
59
|
+
});
|
|
60
|
+
export {
|
|
61
|
+
Root,
|
|
62
|
+
StackedFocusModal
|
|
63
|
+
};
|