@medusajs/loyalty-plugin 0.0.1 → 0.0.3
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/index.js +30277 -0
- package/.medusa/server/src/admin/index.mjs +30256 -0
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.js +24 -0
- package/.medusa/server/src/api/store/carts/middlewares.js +9 -1
- package/.medusa/server/src/api/store/carts/validators.js +5 -2
- package/.medusa/server/src/links/customer-gift-card-link.js +2 -2
- package/.medusa/server/src/links/customer-store-credit-account-link.js +2 -2
- package/.medusa/server/src/links/order-line-item-gift-card-link.js +2 -2
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.js +104 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.js +2 -2
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.js +3 -3
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.js +1 -1
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.js +1 -1
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.js +115 -0
- package/package.json +14 -9
- package/.medusa/server/src/admin/components/action-menu.js +0 -63
- package/.medusa/server/src/admin/components/chip-group.js +0 -82
- package/.medusa/server/src/admin/components/chip-input.js +0 -157
- package/.medusa/server/src/admin/components/combobox.js +0 -324
- package/.medusa/server/src/admin/components/conditional-tooltip.js +0 -15
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-boolean-cell.js +0 -66
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-cell-container.js +0 -77
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-currency-cell.js +0 -110
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-duplicate-cell.js +0 -16
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-keyboard-shortcut-modal.js +0 -214
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-number-cell.js +0 -77
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-readonly-cell.js +0 -32
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-root.js +0 -743
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-row-error-indicator.js +0 -37
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-skeleton.js +0 -54
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-text-cell.js +0 -66
- package/.medusa/server/src/admin/components/data-grid/components/data-grid-toggleable-number-cell.js +0 -166
- package/.medusa/server/src/admin/components/data-grid/components/index.js +0 -16
- package/.medusa/server/src/admin/components/data-grid/context/data-grid-context.js +0 -7
- package/.medusa/server/src/admin/components/data-grid/context/index.js +0 -6
- package/.medusa/server/src/admin/components/data-grid/context/use-data-grid-context.js +0 -14
- package/.medusa/server/src/admin/components/data-grid/data-grid.js +0 -31
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-column-helper.js +0 -28
- package/.medusa/server/src/admin/components/data-grid/helpers/create-data-grid-price-columns.js +0 -85
- package/.medusa/server/src/admin/components/data-grid/helpers/index.js +0 -6
- package/.medusa/server/src/admin/components/data-grid/hooks/index.js +0 -31
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-error.js +0 -50
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-handlers.js +0 -123
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-metadata.js +0 -52
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell-snapshot.js +0 -43
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-cell.js +0 -191
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-clipboard-events.js +0 -70
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-column-visibility.js +0 -51
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-duplicate-cell.js +0 -15
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-error-highlighting.js +0 -86
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-form-handlers.js +0 -149
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-keydown-event.js +0 -482
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-mouse-up-event.js +0 -64
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-navigation.js +0 -81
- package/.medusa/server/src/admin/components/data-grid/hooks/use-data-grid-query-tool.js +0 -14
- package/.medusa/server/src/admin/components/data-grid/index.js +0 -8
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-bulk-update-command.js +0 -27
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-matrix.js +0 -296
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-query-tool.js +0 -62
- package/.medusa/server/src/admin/components/data-grid/models/data-grid-update-command.js +0 -25
- package/.medusa/server/src/admin/components/data-grid/models/index.js +0 -10
- package/.medusa/server/src/admin/components/data-grid/types.js +0 -1
- package/.medusa/server/src/admin/components/data-grid/utils.js +0 -18
- package/.medusa/server/src/admin/components/data-table/components/data-table-status-cell/data-table-status-cell.js +0 -36
- package/.medusa/server/src/admin/components/data-table/data-table.js +0 -271
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-columns.js +0 -51
- package/.medusa/server/src/admin/components/data-table/helpers/general/use-data-table-date-filters.js +0 -90
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/index.js +0 -10
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js +0 -48
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js +0 -19
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js +0 -30
- package/.medusa/server/src/admin/components/data-table/helpers/sales-channels/use-sales-channel-table-query.js +0 -23
- package/.medusa/server/src/admin/components/data-table/index.js +0 -4
- package/.medusa/server/src/admin/components/data-table.js +0 -249
- package/.medusa/server/src/admin/components/display-id.js +0 -18
- package/.medusa/server/src/admin/components/file-upload.js +0 -116
- package/.medusa/server/src/admin/components/form.js +0 -151
- package/.medusa/server/src/admin/components/handle-input.js +0 -22
- package/.medusa/server/src/admin/components/header.js +0 -41
- package/.medusa/server/src/admin/components/icon-avatar.js +0 -27
- package/.medusa/server/src/admin/components/json-view-section.js +0 -139
- package/.medusa/server/src/admin/components/keybound-form.js +0 -32
- package/.medusa/server/src/admin/components/layouts/single-column.js +0 -7
- package/.medusa/server/src/admin/components/layouts/two-column.js +0 -13
- package/.medusa/server/src/admin/components/listicle.js +0 -20
- package/.medusa/server/src/admin/components/modals/index.js +0 -19
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +0 -57
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +0 -71
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +0 -60
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +0 -30
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +0 -12
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +0 -55
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +0 -63
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +0 -47
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +0 -14
- package/.medusa/server/src/admin/components/placeholder-cell.js +0 -7
- package/.medusa/server/src/admin/components/product/product-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/product-cell/product-cell.js +0 -15
- package/.medusa/server/src/admin/components/product/product-status-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/product-status-cell/product-status-cell.js +0 -18
- package/.medusa/server/src/admin/components/product/sales-channels-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/sales-channels-cell/sales-channels-cell.js +0 -31
- package/.medusa/server/src/admin/components/product/variant-cell/index.js +0 -5
- package/.medusa/server/src/admin/components/product/variant-cell/variant-cell.js +0 -15
- package/.medusa/server/src/admin/components/section-row.js +0 -32
- package/.medusa/server/src/admin/components/sidebar-link.js +0 -31
- package/.medusa/server/src/admin/components/sortable-list.js +0 -152
- package/.medusa/server/src/admin/components/switch-box.js +0 -43
- package/.medusa/server/src/admin/components/tax-badge.js +0 -18
- package/.medusa/server/src/admin/components/thumbnail.js +0 -28
- package/.medusa/server/src/admin/components/upload-media-form-item.js +0 -83
- package/.medusa/server/src/admin/hooks/api/customers.js +0 -26
- package/.medusa/server/src/admin/hooks/api/gift-cards.js +0 -107
- package/.medusa/server/src/admin/hooks/api/order.js +0 -16
- package/.medusa/server/src/admin/hooks/api/price-preferences.js +0 -19
- package/.medusa/server/src/admin/hooks/api/products.js +0 -127
- package/.medusa/server/src/admin/hooks/api/regions.js +0 -17
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +0 -28
- package/.medusa/server/src/admin/hooks/api/store-credit-accounts.js +0 -41
- package/.medusa/server/src/admin/hooks/api/store.js +0 -31
- package/.medusa/server/src/admin/hooks/api/transaction-groups.js +0 -23
- package/.medusa/server/src/admin/hooks/api/transactions.js +0 -23
- package/.medusa/server/src/admin/hooks/commands/use-command-history.js +0 -45
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +0 -59
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +0 -89
- package/.medusa/server/src/admin/hooks/common/use-date.js +0 -32
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +0 -22
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +0 -14
- package/.medusa/server/src/admin/hooks/query/use-customers-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/query/use-transaction-groups-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/sales-channels/index.js +0 -10
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-columns.js +0 -48
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-empty-state.js +0 -19
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-filters.js +0 -30
- package/.medusa/server/src/admin/hooks/sales-channels/use-sales-channel-table-query.js +0 -23
- package/.medusa/server/src/admin/lib/currencies.js +0 -729
- package/.medusa/server/src/admin/lib/query-key.js +0 -17
- package/.medusa/server/src/admin/lib/sdk.js +0 -10
- package/.medusa/server/src/admin/routes/gift-card-products/@create/page.js +0 -75
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/components/gift-card-product-edit-denominations-form.js +0 -172
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@denominations/page.js +0 -30
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/components/gift-card-product-edit-form.js +0 -180
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/@edit/page.js +0 -30
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-general-section.js +0 -97
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js +0 -162
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-sales-channel-section.js +0 -89
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-variant-section.js +0 -199
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/edit-product-media-form.js +0 -353
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/edit-product-media-form/index.js +0 -5
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-gallery/product-media-gallery.js +0 -247
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view-context.js +0 -5
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/product-media-view.js +0 -48
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/components/product-media-view/use-product-media-view.js +0 -14
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/media/page.js +0 -28
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/page.js +0 -40
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js +0 -121
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/variant-pricing-form.js +0 -72
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/page.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/components/edit-sales-channel-form.js +0 -123
- package/.medusa/server/src/admin/routes/gift-card-products/_id_/sales-channels/page.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/general-form-section.js +0 -1
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-denominations-form.js +0 -98
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-details-form.js +0 -28
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-denominations.js +0 -96
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-general.js +0 -90
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-media.js +0 -288
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize-section.js +0 -111
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form-organize.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-create-form.js +0 -285
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/gift-card-product-sales-channel-stacked-modal.js +0 -124
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/index.js +0 -4
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/schema.js +0 -112
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-product-create-form/types.js +0 -1
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/columns.js +0 -35
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/filters.js +0 -11
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/gift-card-products-table.js +0 -61
- package/.medusa/server/src/admin/routes/gift-card-products/components/gift-card-products-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-card-products/page.js +0 -18
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@expiration/page.js +0 -137
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@note/page.js +0 -87
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/components/transfer-icon.js +0 -352
- package/.medusa/server/src/admin/routes/gift-cards/_id_/@owner/page.js +0 -116
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-balance-section.js +0 -49
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-general-section.js +0 -177
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-note-section.js +0 -27
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-order-section.js +0 -33
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-owner-section.js +0 -33
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/gift-card-transactions-section.js +0 -18
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/columns.js +0 -50
- package/.medusa/server/src/admin/routes/gift-cards/_id_/components/transactions-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-cards/_id_/page.js +0 -78
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-card-products-section.js +0 -40
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/columns.js +0 -57
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/filters.js +0 -13
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/gift-cards-table.js +0 -61
- package/.medusa/server/src/admin/routes/gift-cards/components/gift-cards-table/query.js +0 -23
- package/.medusa/server/src/admin/routes/gift-cards/page.js +0 -27
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/credit-card-icon.js +0 -126
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-balance-section.js +0 -31
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/store-credit-account-details-section.js +0 -43
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/columns.js +0 -44
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/filters.js +0 -18
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/query.js +0 -37
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/components/transactions-table/table.js +0 -58
- package/.medusa/server/src/admin/routes/store-credit-accounts/_id_/page.js +0 -39
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/columns.js +0 -58
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/filters.js +0 -13
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/query.js +0 -31
- package/.medusa/server/src/admin/routes/store-credit-accounts/components/store-credit-accounts-table/table.js +0 -56
- package/.medusa/server/src/admin/routes/store-credit-accounts/page.js +0 -19
- package/.medusa/server/src/admin/utils/date-utils.js +0 -27
- package/.medusa/server/src/admin/utils/format-amount.js +0 -9
- package/.medusa/server/src/admin/utils/format-date.js +0 -21
- package/.medusa/server/src/admin/utils/refs.js +0 -20
- package/.medusa/server/src/admin/utils/statuses.js +0 -23
- package/.medusa/server/src/admin/utils/validations.js +0 -71
- package/.medusa/server/src/admin/utils/variants.js +0 -92
- package/.medusa/server/src/admin/widgets/customer-gift-cards-widget.js +0 -67
- package/.medusa/server/src/admin/widgets/customer-store-credit-widget.js +0 -42
- package/.medusa/server/src/admin/widgets/order-gift-cards-widget.js +0 -58
- package/.medusa/server/src/workflows/orders/workflows/refund-gift-card-credit-lines.js +0 -96
- package/.medusa/server/types/loyalty/module.js +0 -8
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { zodResolver } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@hookform/resolvers/zod/dist/zod.mjs";
|
|
3
|
-
import { toast, ProgressTabs, Button } from "@medusajs/ui";
|
|
4
|
-
import { useState, useMemo, useEffect } from "react";
|
|
5
|
-
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
6
|
-
import { KeyboundForm } from "../../../../components/keybound-form.js";
|
|
7
|
-
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
8
|
-
import { RouteFocusModal } from "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
9
|
-
import "react-router-dom";
|
|
10
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
11
|
-
import { useRouteModal } from "../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
12
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
13
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
14
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
15
|
-
import { useCreateProduct } from "../../../../hooks/api/products.js";
|
|
16
|
-
import { sdk } from "../../../../lib/sdk.js";
|
|
17
|
-
import { normalizeProductFormValues } from "../../../../utils/variants.js";
|
|
18
|
-
import { GiftCardProductCreateDenominationsForm } from "./gift-card-product-create-denominations-form.js";
|
|
19
|
-
import { GiftCardProductCreateDetailsForm } from "./gift-card-product-create-details-form.js";
|
|
20
|
-
import { PRODUCT_CREATE_FORM_DEFAULTS, ProductCreateSchema } from "./schema.js";
|
|
21
|
-
const SAVE_DRAFT_BUTTON = "save-draft-button";
|
|
22
|
-
const GiftCardProductCreateForm = ({
|
|
23
|
-
defaultChannel,
|
|
24
|
-
regions,
|
|
25
|
-
store,
|
|
26
|
-
pricePreferences
|
|
27
|
-
}) => {
|
|
28
|
-
const [tab, setTab] = useState(
|
|
29
|
-
"details"
|
|
30
|
-
/* DETAILS */
|
|
31
|
-
);
|
|
32
|
-
const [tabState, setTabState] = useState({
|
|
33
|
-
[
|
|
34
|
-
"details"
|
|
35
|
-
/* DETAILS */
|
|
36
|
-
]: "in-progress",
|
|
37
|
-
[
|
|
38
|
-
"prices"
|
|
39
|
-
/* PRICES */
|
|
40
|
-
]: "not-started"
|
|
41
|
-
});
|
|
42
|
-
const { handleSuccess } = useRouteModal();
|
|
43
|
-
const form = useForm({
|
|
44
|
-
defaultValues: {
|
|
45
|
-
...PRODUCT_CREATE_FORM_DEFAULTS,
|
|
46
|
-
sales_channels: defaultChannel ? [{ id: defaultChannel.id, name: defaultChannel.name }] : []
|
|
47
|
-
},
|
|
48
|
-
resolver: zodResolver(ProductCreateSchema)
|
|
49
|
-
});
|
|
50
|
-
const { mutateAsync, isPending } = useCreateProduct();
|
|
51
|
-
const regionsCurrencyMap = useMemo(() => {
|
|
52
|
-
if (!(regions == null ? void 0 : regions.length)) {
|
|
53
|
-
return {};
|
|
54
|
-
}
|
|
55
|
-
return regions.reduce((acc, reg) => {
|
|
56
|
-
acc[reg.id] = reg.currency_code;
|
|
57
|
-
return acc;
|
|
58
|
-
}, {});
|
|
59
|
-
}, [regions]);
|
|
60
|
-
const handleSubmit = form.handleSubmit(async (values, e) => {
|
|
61
|
-
var _a;
|
|
62
|
-
let isDraftSubmission = false;
|
|
63
|
-
if ((e == null ? void 0 : e.nativeEvent) instanceof SubmitEvent) {
|
|
64
|
-
const submitter = (_a = e == null ? void 0 : e.nativeEvent) == null ? void 0 : _a.submitter;
|
|
65
|
-
isDraftSubmission = submitter.dataset.name === SAVE_DRAFT_BUTTON;
|
|
66
|
-
}
|
|
67
|
-
const media = values.media || [];
|
|
68
|
-
const payload = { ...values, media: void 0 };
|
|
69
|
-
let uploadedMedia = [];
|
|
70
|
-
try {
|
|
71
|
-
if (media.length) {
|
|
72
|
-
const thumbnailReq = media.find((m) => m.isThumbnail);
|
|
73
|
-
const otherMediaReq = media.filter((m) => !m.isThumbnail);
|
|
74
|
-
const fileReqs = [];
|
|
75
|
-
if (thumbnailReq) {
|
|
76
|
-
fileReqs.push(
|
|
77
|
-
sdk.admin.upload.create({ files: [thumbnailReq.file] }).then((r) => r.files.map((f) => ({ ...f, isThumbnail: true })))
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
if (otherMediaReq == null ? void 0 : otherMediaReq.length) {
|
|
81
|
-
fileReqs.push(
|
|
82
|
-
sdk.admin.upload.create({
|
|
83
|
-
files: otherMediaReq.map((m) => m.file)
|
|
84
|
-
}).then((r) => r.files.map((f) => ({ ...f, isThumbnail: false })))
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
uploadedMedia = (await Promise.all(fileReqs)).flat();
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
if (error instanceof Error) {
|
|
91
|
-
toast.error(error.message);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
await mutateAsync(
|
|
95
|
-
normalizeProductFormValues({
|
|
96
|
-
...payload,
|
|
97
|
-
media: uploadedMedia,
|
|
98
|
-
status: isDraftSubmission ? "draft" : "published",
|
|
99
|
-
regionsCurrencyMap
|
|
100
|
-
}),
|
|
101
|
-
{
|
|
102
|
-
onSuccess: (data) => {
|
|
103
|
-
toast.success(
|
|
104
|
-
`Product ${data.product.title} was successfully created.`
|
|
105
|
-
);
|
|
106
|
-
handleSuccess(`../${data.product.id}`);
|
|
107
|
-
},
|
|
108
|
-
onError: (error) => {
|
|
109
|
-
toast.error(error.message);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
});
|
|
114
|
-
const onNext = async (currentTab) => {
|
|
115
|
-
const valid = await form.trigger();
|
|
116
|
-
if (!valid) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (currentTab === "details") {
|
|
120
|
-
setTab(
|
|
121
|
-
"prices"
|
|
122
|
-
/* PRICES */
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
const currentState = { ...tabState };
|
|
128
|
-
if (tab === "details") {
|
|
129
|
-
currentState[
|
|
130
|
-
"details"
|
|
131
|
-
/* DETAILS */
|
|
132
|
-
] = "in-progress";
|
|
133
|
-
}
|
|
134
|
-
if (tab === "prices") {
|
|
135
|
-
currentState[
|
|
136
|
-
"details"
|
|
137
|
-
/* DETAILS */
|
|
138
|
-
] = "completed";
|
|
139
|
-
currentState[
|
|
140
|
-
"prices"
|
|
141
|
-
/* PRICES */
|
|
142
|
-
] = "in-progress";
|
|
143
|
-
}
|
|
144
|
-
setTabState({ ...currentState });
|
|
145
|
-
}, [tab]);
|
|
146
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
147
|
-
KeyboundForm,
|
|
148
|
-
{
|
|
149
|
-
onKeyDown: (e) => {
|
|
150
|
-
if (e.key === "Enter") {
|
|
151
|
-
if (e.target instanceof HTMLTextAreaElement && !(e.metaKey || e.ctrlKey)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
e.preventDefault();
|
|
155
|
-
if (e.metaKey || e.ctrlKey) {
|
|
156
|
-
if (tab !== "prices") {
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
e.stopPropagation();
|
|
159
|
-
onNext(tab);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
handleSubmit();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
onSubmit: handleSubmit,
|
|
167
|
-
className: "flex h-full flex-col",
|
|
168
|
-
children: [
|
|
169
|
-
/* @__PURE__ */ jsxs(
|
|
170
|
-
ProgressTabs,
|
|
171
|
-
{
|
|
172
|
-
value: tab,
|
|
173
|
-
onValueChange: async (tab2) => {
|
|
174
|
-
const valid = await form.trigger();
|
|
175
|
-
if (!valid) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
setTab(tab2);
|
|
179
|
-
},
|
|
180
|
-
className: "flex h-full flex-col overflow-hidden",
|
|
181
|
-
children: [
|
|
182
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsx("div", { className: "-my-2 w-full border-l", children: /* @__PURE__ */ jsxs(ProgressTabs.List, { className: "justify-start-start flex w-full items-center", children: [
|
|
183
|
-
/* @__PURE__ */ jsx(
|
|
184
|
-
ProgressTabs.Trigger,
|
|
185
|
-
{
|
|
186
|
-
status: tabState[
|
|
187
|
-
"details"
|
|
188
|
-
/* DETAILS */
|
|
189
|
-
],
|
|
190
|
-
value: "details",
|
|
191
|
-
className: "max-w-[200px] truncate",
|
|
192
|
-
children: "Details"
|
|
193
|
-
}
|
|
194
|
-
),
|
|
195
|
-
/* @__PURE__ */ jsx(
|
|
196
|
-
ProgressTabs.Trigger,
|
|
197
|
-
{
|
|
198
|
-
status: tabState[
|
|
199
|
-
"prices"
|
|
200
|
-
/* PRICES */
|
|
201
|
-
],
|
|
202
|
-
value: "prices",
|
|
203
|
-
className: "max-w-[200px] truncate",
|
|
204
|
-
children: "Prices"
|
|
205
|
-
}
|
|
206
|
-
)
|
|
207
|
-
] }) }) }),
|
|
208
|
-
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: [
|
|
209
|
-
/* @__PURE__ */ jsx(
|
|
210
|
-
ProgressTabs.Content,
|
|
211
|
-
{
|
|
212
|
-
className: "size-full overflow-y-auto",
|
|
213
|
-
value: "details",
|
|
214
|
-
children: /* @__PURE__ */ jsx(GiftCardProductCreateDetailsForm, { form })
|
|
215
|
-
}
|
|
216
|
-
),
|
|
217
|
-
/* @__PURE__ */ jsx(
|
|
218
|
-
ProgressTabs.Content,
|
|
219
|
-
{
|
|
220
|
-
className: "size-full overflow-y-auto",
|
|
221
|
-
value: "prices",
|
|
222
|
-
children: /* @__PURE__ */ jsx(
|
|
223
|
-
GiftCardProductCreateDenominationsForm,
|
|
224
|
-
{
|
|
225
|
-
form,
|
|
226
|
-
store,
|
|
227
|
-
regions,
|
|
228
|
-
pricePreferences
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
] })
|
|
234
|
-
]
|
|
235
|
-
}
|
|
236
|
-
),
|
|
237
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
238
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
239
|
-
/* @__PURE__ */ jsx(
|
|
240
|
-
Button,
|
|
241
|
-
{
|
|
242
|
-
"data-name": SAVE_DRAFT_BUTTON,
|
|
243
|
-
size: "small",
|
|
244
|
-
type: "submit",
|
|
245
|
-
isLoading: isPending,
|
|
246
|
-
className: "whitespace-nowrap",
|
|
247
|
-
children: "Save as draft"
|
|
248
|
-
}
|
|
249
|
-
),
|
|
250
|
-
/* @__PURE__ */ jsx(PrimaryButton, { tab, next: onNext, isLoading: isPending })
|
|
251
|
-
] }) })
|
|
252
|
-
]
|
|
253
|
-
}
|
|
254
|
-
) });
|
|
255
|
-
};
|
|
256
|
-
const PrimaryButton = ({ tab, next, isLoading }) => {
|
|
257
|
-
if (tab === "prices") {
|
|
258
|
-
return /* @__PURE__ */ jsx(
|
|
259
|
-
Button,
|
|
260
|
-
{
|
|
261
|
-
"data-name": "publish-button",
|
|
262
|
-
type: "submit",
|
|
263
|
-
variant: "primary",
|
|
264
|
-
size: "small",
|
|
265
|
-
isLoading,
|
|
266
|
-
children: "Publish"
|
|
267
|
-
},
|
|
268
|
-
"submit-button"
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
return /* @__PURE__ */ jsx(
|
|
272
|
-
Button,
|
|
273
|
-
{
|
|
274
|
-
type: "button",
|
|
275
|
-
variant: "primary",
|
|
276
|
-
size: "small",
|
|
277
|
-
onClick: () => next(tab),
|
|
278
|
-
children: "Continue"
|
|
279
|
-
},
|
|
280
|
-
"next-button"
|
|
281
|
-
);
|
|
282
|
-
};
|
|
283
|
-
export {
|
|
284
|
-
GiftCardProductCreateForm
|
|
285
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createDataTableColumnHelper, Button } from "@medusajs/ui";
|
|
3
|
-
import { useState, useEffect, useMemo } from "react";
|
|
4
|
-
import { keepPreviousData } from "@tanstack/react-query";
|
|
5
|
-
import { DataTable } from "../../../../components/data-table.js";
|
|
6
|
-
import { useSalesChannelTableColumns } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js";
|
|
7
|
-
import { useSalesChannelTableEmptyState } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js";
|
|
8
|
-
import { useSalesChannelTableFilters } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js";
|
|
9
|
-
import { useSalesChannelTableQuery } from "../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-query.js";
|
|
10
|
-
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
11
|
-
import "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
12
|
-
import "react-router-dom";
|
|
13
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
14
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
15
|
-
import { StackedFocusModal } from "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
16
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
17
|
-
import { useStackedModal } from "../../../../components/modals/stacked-modal-provider/use-stacked-modal.js";
|
|
18
|
-
import { useSalesChannels } from "../../../../hooks/api/sales-channels.js";
|
|
19
|
-
import { SC_STACKED_MODAL_ID } from "./schema.js";
|
|
20
|
-
const PAGE_SIZE = 50;
|
|
21
|
-
const GiftCardProductSalesChannelStackedModal = ({
|
|
22
|
-
form
|
|
23
|
-
}) => {
|
|
24
|
-
const { getValues, setValue } = form;
|
|
25
|
-
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
26
|
-
const [rowSelection, setRowSelection] = useState(
|
|
27
|
-
{}
|
|
28
|
-
);
|
|
29
|
-
const [state, setState] = useState([]);
|
|
30
|
-
const searchParams = useSalesChannelTableQuery({
|
|
31
|
-
pageSize: PAGE_SIZE,
|
|
32
|
-
prefix: SC_STACKED_MODAL_ID
|
|
33
|
-
});
|
|
34
|
-
const { sales_channels, count, isLoading, isError, error } = useSalesChannels(
|
|
35
|
-
searchParams,
|
|
36
|
-
{ placeholderData: keepPreviousData }
|
|
37
|
-
);
|
|
38
|
-
const open = getIsOpen(SC_STACKED_MODAL_ID);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!open) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const salesChannels = getValues("sales_channels");
|
|
44
|
-
if (salesChannels) {
|
|
45
|
-
setState(
|
|
46
|
-
salesChannels.map((channel) => ({
|
|
47
|
-
id: channel.id,
|
|
48
|
-
name: channel.name
|
|
49
|
-
}))
|
|
50
|
-
);
|
|
51
|
-
setRowSelection(
|
|
52
|
-
salesChannels.reduce(
|
|
53
|
-
(acc, channel) => ({
|
|
54
|
-
...acc,
|
|
55
|
-
[channel.id]: true
|
|
56
|
-
}),
|
|
57
|
-
{}
|
|
58
|
-
)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}, [open, getValues]);
|
|
62
|
-
const onRowSelectionChange = (state2) => {
|
|
63
|
-
const ids = Object.keys(state2);
|
|
64
|
-
const addedIdsSet = new Set(
|
|
65
|
-
ids.filter((id) => state2[id] && !rowSelection[id])
|
|
66
|
-
);
|
|
67
|
-
let addedSalesChannels = [];
|
|
68
|
-
if (addedIdsSet.size > 0) {
|
|
69
|
-
addedSalesChannels = (sales_channels == null ? void 0 : sales_channels.filter((channel) => addedIdsSet.has(channel.id))) ?? [];
|
|
70
|
-
}
|
|
71
|
-
setState((prev) => {
|
|
72
|
-
const filteredPrev = prev.filter((channel) => state2[channel.id]);
|
|
73
|
-
return Array.from(/* @__PURE__ */ new Set([...filteredPrev, ...addedSalesChannels]));
|
|
74
|
-
});
|
|
75
|
-
setRowSelection(state2);
|
|
76
|
-
};
|
|
77
|
-
const handleAdd = () => {
|
|
78
|
-
setValue("sales_channels", state, {
|
|
79
|
-
shouldDirty: true,
|
|
80
|
-
shouldTouch: true
|
|
81
|
-
});
|
|
82
|
-
setIsOpen(SC_STACKED_MODAL_ID, false);
|
|
83
|
-
};
|
|
84
|
-
const filters = useSalesChannelTableFilters();
|
|
85
|
-
const columns = useColumns();
|
|
86
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
87
|
-
if (isError) {
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
return /* @__PURE__ */ jsxs(StackedFocusModal.Content, { className: "flex flex-col overflow-hidden", children: [
|
|
91
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
|
|
92
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
93
|
-
DataTable,
|
|
94
|
-
{
|
|
95
|
-
data: sales_channels,
|
|
96
|
-
columns,
|
|
97
|
-
filters,
|
|
98
|
-
emptyState,
|
|
99
|
-
rowCount: count,
|
|
100
|
-
pageSize: PAGE_SIZE,
|
|
101
|
-
getRowId: (row) => row.id,
|
|
102
|
-
rowSelection: {
|
|
103
|
-
state: rowSelection,
|
|
104
|
-
onRowSelectionChange
|
|
105
|
-
},
|
|
106
|
-
isLoading,
|
|
107
|
-
layout: "fill",
|
|
108
|
-
prefix: SC_STACKED_MODAL_ID
|
|
109
|
-
}
|
|
110
|
-
) }),
|
|
111
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
112
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
113
|
-
/* @__PURE__ */ jsx(Button, { size: "small", onClick: handleAdd, type: "button", children: "Save" })
|
|
114
|
-
] }) })
|
|
115
|
-
] });
|
|
116
|
-
};
|
|
117
|
-
const columnHelper = createDataTableColumnHelper();
|
|
118
|
-
const useColumns = () => {
|
|
119
|
-
const base = useSalesChannelTableColumns();
|
|
120
|
-
return useMemo(() => [columnHelper.select(), ...base], [base]);
|
|
121
|
-
};
|
|
122
|
-
export {
|
|
123
|
-
GiftCardProductSalesChannelStackedModal
|
|
124
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { z } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
2
|
-
import { optionalInt, optionalFloat } from "../../../../utils/validations.js";
|
|
3
|
-
const SC_STACKED_MODAL_ID = "sc";
|
|
4
|
-
const MediaSchema = z.object({
|
|
5
|
-
id: z.string().optional(),
|
|
6
|
-
url: z.string(),
|
|
7
|
-
isThumbnail: z.boolean(),
|
|
8
|
-
file: z.any().nullable()
|
|
9
|
-
// File
|
|
10
|
-
});
|
|
11
|
-
z.object({
|
|
12
|
-
should_create: z.boolean(),
|
|
13
|
-
is_default: z.boolean().optional(),
|
|
14
|
-
title: z.string(),
|
|
15
|
-
upc: z.string().optional(),
|
|
16
|
-
ean: z.string().optional(),
|
|
17
|
-
barcode: z.string().optional(),
|
|
18
|
-
mid_code: z.string().optional(),
|
|
19
|
-
hs_code: z.string().optional(),
|
|
20
|
-
width: optionalInt,
|
|
21
|
-
height: optionalInt,
|
|
22
|
-
length: optionalInt,
|
|
23
|
-
weight: optionalInt,
|
|
24
|
-
material: z.string().optional(),
|
|
25
|
-
origin_country: z.string().optional(),
|
|
26
|
-
sku: z.string().optional(),
|
|
27
|
-
manage_inventory: z.boolean().optional(),
|
|
28
|
-
allow_backorder: z.boolean().optional(),
|
|
29
|
-
inventory_kit: z.boolean().optional(),
|
|
30
|
-
options: z.record(z.string(), z.string()),
|
|
31
|
-
variant_rank: z.number(),
|
|
32
|
-
prices: z.record(z.string(), optionalFloat).optional(),
|
|
33
|
-
inventory: z.array(
|
|
34
|
-
z.object({
|
|
35
|
-
inventory_item_id: z.string(),
|
|
36
|
-
required_quantity: optionalInt
|
|
37
|
-
})
|
|
38
|
-
).optional()
|
|
39
|
-
});
|
|
40
|
-
z.object({
|
|
41
|
-
title: z.string(),
|
|
42
|
-
values: z.array(z.string()).min(1)
|
|
43
|
-
});
|
|
44
|
-
const ProductCreateSchema = z.object({
|
|
45
|
-
title: z.string().min(1),
|
|
46
|
-
subtitle: z.string().optional(),
|
|
47
|
-
handle: z.string().optional(),
|
|
48
|
-
description: z.string().optional(),
|
|
49
|
-
discountable: z.boolean(),
|
|
50
|
-
type_id: z.string().optional(),
|
|
51
|
-
collection_id: z.string().optional(),
|
|
52
|
-
shipping_profile_id: z.string().optional(),
|
|
53
|
-
categories: z.array(z.string()),
|
|
54
|
-
tags: z.array(z.string()).optional(),
|
|
55
|
-
sales_channels: z.array(
|
|
56
|
-
z.object({
|
|
57
|
-
id: z.string(),
|
|
58
|
-
name: z.string()
|
|
59
|
-
})
|
|
60
|
-
).optional(),
|
|
61
|
-
origin_country: z.string().optional(),
|
|
62
|
-
material: z.string().optional(),
|
|
63
|
-
width: z.string().optional(),
|
|
64
|
-
length: z.string().optional(),
|
|
65
|
-
height: z.string().optional(),
|
|
66
|
-
weight: z.string().optional(),
|
|
67
|
-
mid_code: z.string().optional(),
|
|
68
|
-
hs_code: z.string().optional(),
|
|
69
|
-
denominations: z.array(
|
|
70
|
-
z.object({
|
|
71
|
-
value: z.string().min(1),
|
|
72
|
-
sku: z.string().optional(),
|
|
73
|
-
prices: z.record(z.string(), optionalFloat).optional()
|
|
74
|
-
})
|
|
75
|
-
).min(1),
|
|
76
|
-
enable_variants: z.boolean(),
|
|
77
|
-
media: z.array(MediaSchema).optional()
|
|
78
|
-
});
|
|
79
|
-
const EditProductMediaSchema = z.object({
|
|
80
|
-
media: z.array(MediaSchema)
|
|
81
|
-
});
|
|
82
|
-
const PRODUCT_CREATE_FORM_DEFAULTS = {
|
|
83
|
-
discountable: true,
|
|
84
|
-
tags: [],
|
|
85
|
-
sales_channels: [],
|
|
86
|
-
denominations: [],
|
|
87
|
-
enable_variants: true,
|
|
88
|
-
media: [],
|
|
89
|
-
categories: [],
|
|
90
|
-
collection_id: "",
|
|
91
|
-
shipping_profile_id: "",
|
|
92
|
-
description: "",
|
|
93
|
-
handle: "",
|
|
94
|
-
height: "",
|
|
95
|
-
hs_code: "",
|
|
96
|
-
length: "",
|
|
97
|
-
material: "",
|
|
98
|
-
mid_code: "",
|
|
99
|
-
origin_country: "",
|
|
100
|
-
subtitle: "",
|
|
101
|
-
title: "",
|
|
102
|
-
type_id: "",
|
|
103
|
-
weight: "",
|
|
104
|
-
width: ""
|
|
105
|
-
};
|
|
106
|
-
export {
|
|
107
|
-
EditProductMediaSchema,
|
|
108
|
-
MediaSchema,
|
|
109
|
-
PRODUCT_CREATE_FORM_DEFAULTS,
|
|
110
|
-
ProductCreateSchema,
|
|
111
|
-
SC_STACKED_MODAL_ID
|
|
112
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createColumnHelper } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@tanstack/react-table/build/lib/index.mjs";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
|
-
import { ProductCell, ProductHeader } from "../../../../components/product/product-cell/product-cell.js";
|
|
5
|
-
import { ProductStatusCell, ProductStatusHeader } from "../../../../components/product/product-status-cell/product-status-cell.js";
|
|
6
|
-
import { SalesChannelsCell, SalesChannelHeader } from "../../../../components/product/sales-channels-cell/sales-channels-cell.js";
|
|
7
|
-
import { VariantCell, VariantHeader } from "../../../../components/product/variant-cell/variant-cell.js";
|
|
8
|
-
const columnHelper = createColumnHelper();
|
|
9
|
-
const useGiftCardProductsTableColumns = () => {
|
|
10
|
-
return useMemo(
|
|
11
|
-
() => [
|
|
12
|
-
columnHelper.display({
|
|
13
|
-
id: "product",
|
|
14
|
-
header: () => /* @__PURE__ */ jsx(ProductHeader, {}),
|
|
15
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(ProductCell, { product: row.original })
|
|
16
|
-
}),
|
|
17
|
-
columnHelper.accessor("sales_channels", {
|
|
18
|
-
header: () => /* @__PURE__ */ jsx(SalesChannelHeader, {}),
|
|
19
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(SalesChannelsCell, { salesChannels: row.original.sales_channels })
|
|
20
|
-
}),
|
|
21
|
-
columnHelper.accessor("variants", {
|
|
22
|
-
header: () => /* @__PURE__ */ jsx(VariantHeader, {}),
|
|
23
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(VariantCell, { variants: row.original.variants })
|
|
24
|
-
}),
|
|
25
|
-
columnHelper.accessor("status", {
|
|
26
|
-
header: () => /* @__PURE__ */ jsx(ProductStatusHeader, {}),
|
|
27
|
-
cell: ({ row }) => /* @__PURE__ */ jsx(ProductStatusCell, { status: row.original.status })
|
|
28
|
-
})
|
|
29
|
-
],
|
|
30
|
-
[]
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
useGiftCardProductsTableColumns
|
|
35
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
import { useDataTableDateFilters } from "../../../../hooks/common/use-data-table-date-filters.js";
|
|
3
|
-
const useGiftCardProductsFilters = () => {
|
|
4
|
-
const dateFilterOptions = useDataTableDateFilters();
|
|
5
|
-
return useMemo(() => {
|
|
6
|
-
return [...dateFilterOptions];
|
|
7
|
-
}, [dateFilterOptions]);
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
useGiftCardProductsFilters
|
|
11
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Container } from "@medusajs/ui";
|
|
3
|
-
import { Fragment } from "react";
|
|
4
|
-
import { Outlet } from "react-router-dom";
|
|
5
|
-
import { DataTable } from "../../../../components/data-table.js";
|
|
6
|
-
import { useProducts } from "../../../../hooks/api/products.js";
|
|
7
|
-
import { useGiftCardProductsTableColumns } from "./columns.js";
|
|
8
|
-
import { useGiftCardProductsFilters } from "./filters.js";
|
|
9
|
-
import { useGiftCardProductsTableQuery } from "./query.js";
|
|
10
|
-
const PAGE_SIZE = 10;
|
|
11
|
-
function GiftCardProductsTable() {
|
|
12
|
-
const queryParams = useGiftCardProductsTableQuery({
|
|
13
|
-
pageSize: PAGE_SIZE
|
|
14
|
-
});
|
|
15
|
-
const {
|
|
16
|
-
products: giftCardProducts,
|
|
17
|
-
isPending,
|
|
18
|
-
count
|
|
19
|
-
} = useProducts({
|
|
20
|
-
...queryParams,
|
|
21
|
-
is_giftcard: true,
|
|
22
|
-
order: queryParams.order ?? "-created_at"
|
|
23
|
-
});
|
|
24
|
-
const columns = useGiftCardProductsTableColumns();
|
|
25
|
-
const filters = useGiftCardProductsFilters();
|
|
26
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
-
/* @__PURE__ */ jsx(Container, { className: "p-0", children: /* @__PURE__ */ jsx(
|
|
28
|
-
DataTable,
|
|
29
|
-
{
|
|
30
|
-
data: giftCardProducts,
|
|
31
|
-
getRowId: (row) => row.id,
|
|
32
|
-
columns,
|
|
33
|
-
filters,
|
|
34
|
-
isLoading: isPending,
|
|
35
|
-
pageSize: PAGE_SIZE,
|
|
36
|
-
rowCount: count,
|
|
37
|
-
enableSearch: false,
|
|
38
|
-
heading: "Gift Card Products",
|
|
39
|
-
action: {
|
|
40
|
-
label: "Create gift card product",
|
|
41
|
-
to: "create"
|
|
42
|
-
},
|
|
43
|
-
rowHref: (row) => `${row.id}`,
|
|
44
|
-
emptyState: {
|
|
45
|
-
empty: {
|
|
46
|
-
heading: "No gift card products found",
|
|
47
|
-
description: "Create a new gift card product to get started."
|
|
48
|
-
},
|
|
49
|
-
filtered: {
|
|
50
|
-
heading: "No results found",
|
|
51
|
-
description: "No gift card products match your filter criteria."
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
) }),
|
|
56
|
-
/* @__PURE__ */ jsx(Outlet, {})
|
|
57
|
-
] });
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
GiftCardProductsTable
|
|
61
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useQueryParams } from "../../../../hooks/common/use-query-params.js";
|
|
2
|
-
const useGiftCardProductsTableQuery = ({
|
|
3
|
-
prefix,
|
|
4
|
-
pageSize = 20
|
|
5
|
-
}) => {
|
|
6
|
-
const queryObject = useQueryParams(
|
|
7
|
-
["offset", "customer_id", "created_at", "updated_at"],
|
|
8
|
-
prefix
|
|
9
|
-
);
|
|
10
|
-
const { offset, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
11
|
-
const searchParams = {
|
|
12
|
-
limit: pageSize,
|
|
13
|
-
offset: offset ? Number(offset) : 0,
|
|
14
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
15
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
16
|
-
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
17
|
-
...rest
|
|
18
|
-
};
|
|
19
|
-
return searchParams;
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
useGiftCardProductsTableQuery
|
|
23
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
|
-
import { Toaster } from "@medusajs/ui";
|
|
4
|
-
import { GiftCardProductsTable } from "./components/gift-card-products-table/gift-card-products-table.js";
|
|
5
|
-
const GiftCardProductsPage = () => {
|
|
6
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7
|
-
/* @__PURE__ */ jsx(GiftCardProductsTable, {}),
|
|
8
|
-
/* @__PURE__ */ jsx(Toaster, {})
|
|
9
|
-
] });
|
|
10
|
-
};
|
|
11
|
-
const config = defineRouteConfig({
|
|
12
|
-
label: "Gift Cards",
|
|
13
|
-
nested: "/products"
|
|
14
|
-
});
|
|
15
|
-
export {
|
|
16
|
-
config,
|
|
17
|
-
GiftCardProductsPage as default
|
|
18
|
-
};
|