@medusajs/loyalty-plugin 0.0.1 → 0.0.2
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 +30214 -0
- package/.medusa/server/src/admin/index.mjs +30193 -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/types/loyalty/module.js +0 -8
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useParams } from "react-router-dom";
|
|
3
|
-
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
4
|
-
import { RouteFocusModal } from "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
5
|
-
import "react";
|
|
6
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
7
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
8
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
9
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
10
|
-
import { useProduct } from "../../../../hooks/api/products.js";
|
|
11
|
-
import { ProductMediaView } from "./components/product-media-view/product-media-view.js";
|
|
12
|
-
const ProductMedia = () => {
|
|
13
|
-
const { id } = useParams();
|
|
14
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
15
|
-
const ready = !isLoading && product;
|
|
16
|
-
if (isError) {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
return /* @__PURE__ */ jsxs(RouteFocusModal, { children: [
|
|
20
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Product media" }) }),
|
|
21
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit product media" }) }),
|
|
22
|
-
ready && /* @__PURE__ */ jsx(ProductMediaView, { product })
|
|
23
|
-
] });
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
ProductMedia,
|
|
27
|
-
ProductMedia as default
|
|
28
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useParams, Outlet } from "react-router-dom";
|
|
3
|
-
import { JsonViewSection } from "../../../components/json-view-section.js";
|
|
4
|
-
import { TwoColumnLayout } from "../../../components/layouts/two-column.js";
|
|
5
|
-
import { useProduct } from "../../../hooks/api/products.js";
|
|
6
|
-
import { ProductGeneralSection } from "./components/product-general-section.js";
|
|
7
|
-
import { ProductMediaSection } from "./components/product-media-section.js";
|
|
8
|
-
import { ProductSalesChannelSection } from "./components/product-sales-channel-section.js";
|
|
9
|
-
import { ProductVariantSection } from "./components/product-variant-section.js";
|
|
10
|
-
const ProductDetail = () => {
|
|
11
|
-
const { id } = useParams();
|
|
12
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
13
|
-
if (isLoading || !product) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (isError) {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
20
|
-
/* @__PURE__ */ jsx(
|
|
21
|
-
TwoColumnLayout,
|
|
22
|
-
{
|
|
23
|
-
firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
-
/* @__PURE__ */ jsx(ProductGeneralSection, { product }),
|
|
25
|
-
/* @__PURE__ */ jsx(ProductVariantSection, { product }),
|
|
26
|
-
/* @__PURE__ */ jsx(JsonViewSection, { data: product })
|
|
27
|
-
] }),
|
|
28
|
-
secondCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
-
/* @__PURE__ */ jsx(ProductSalesChannelSection, { product }),
|
|
30
|
-
/* @__PURE__ */ jsx(ProductMediaSection, { product })
|
|
31
|
-
] })
|
|
32
|
-
}
|
|
33
|
-
),
|
|
34
|
-
/* @__PURE__ */ jsx(Outlet, {})
|
|
35
|
-
] });
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
ProductDetail,
|
|
39
|
-
ProductDetail as default
|
|
40
|
-
};
|
package/.medusa/server/src/admin/routes/gift-card-products/_id_/prices/components/prices-edit.js
DELETED
|
@@ -1,121 +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 { Button } from "@medusajs/ui";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
6
|
-
import * as zod from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
7
|
-
import { KeyboundForm } from "../../../../../components/keybound-form.js";
|
|
8
|
-
import "../../../../../components/modals/route-drawer/route-drawer.js";
|
|
9
|
-
import { RouteFocusModal } from "../../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
10
|
-
import "react-router-dom";
|
|
11
|
-
import "../../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
12
|
-
import { useRouteModal } from "../../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
13
|
-
import "../../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
14
|
-
import "../../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
15
|
-
import "../../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
16
|
-
import { useUpdateProductVariantsBatch } from "../../../../../hooks/api/products.js";
|
|
17
|
-
import { useRegions } from "../../../../../hooks/api/regions.js";
|
|
18
|
-
import { castNumber } from "../../../../../utils/validations.js";
|
|
19
|
-
import { VariantPricingForm } from "./variant-pricing-form.js";
|
|
20
|
-
const UpdateDenominationPricesSchema = zod.object({
|
|
21
|
-
variants: zod.array(
|
|
22
|
-
zod.object({
|
|
23
|
-
prices: zod.record(zod.string(), zod.string().or(zod.number()).optional()).optional()
|
|
24
|
-
})
|
|
25
|
-
)
|
|
26
|
-
});
|
|
27
|
-
const PricingEdit = ({
|
|
28
|
-
product,
|
|
29
|
-
variantId
|
|
30
|
-
}) => {
|
|
31
|
-
var _a;
|
|
32
|
-
const { handleSuccess } = useRouteModal();
|
|
33
|
-
const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
|
|
34
|
-
const { regions } = useRegions({ limit: 9999 });
|
|
35
|
-
const regionsCurrencyMap = useMemo(() => {
|
|
36
|
-
if (!(regions == null ? void 0 : regions.length)) {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
return regions.reduce((acc, reg) => {
|
|
40
|
-
acc[reg.id] = reg.currency_code;
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
}, [regions]);
|
|
44
|
-
const variants = variantId ? (_a = product.variants) == null ? void 0 : _a.filter((v) => v.id === variantId) : product.variants;
|
|
45
|
-
const form = useForm({
|
|
46
|
-
defaultValues: {
|
|
47
|
-
variants: variants == null ? void 0 : variants.map((variant) => ({
|
|
48
|
-
title: variant.title,
|
|
49
|
-
prices: variant.prices.reduce((acc, price) => {
|
|
50
|
-
var _a2;
|
|
51
|
-
if ((_a2 = price.rules) == null ? void 0 : _a2.region_id) {
|
|
52
|
-
acc[price.rules.region_id] = price.amount;
|
|
53
|
-
} else {
|
|
54
|
-
acc[price.currency_code] = price.amount;
|
|
55
|
-
}
|
|
56
|
-
return acc;
|
|
57
|
-
}, {})
|
|
58
|
-
}))
|
|
59
|
-
},
|
|
60
|
-
resolver: zodResolver(UpdateDenominationPricesSchema, {})
|
|
61
|
-
});
|
|
62
|
-
const handleSubmit = form.handleSubmit(async (values) => {
|
|
63
|
-
const reqData = values.variants.map((variant, ind) => {
|
|
64
|
-
var _a2;
|
|
65
|
-
return {
|
|
66
|
-
id: (_a2 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a2.id,
|
|
67
|
-
prices: Object.entries(variant.prices || {}).filter(
|
|
68
|
-
([_, value]) => value !== "" && typeof value !== "undefined"
|
|
69
|
-
// deleted cells
|
|
70
|
-
).map(([currencyCodeOrRegionId, value]) => {
|
|
71
|
-
var _a3, _b, _c, _d, _e, _f;
|
|
72
|
-
const regionId = currencyCodeOrRegionId.startsWith("reg_") ? currencyCodeOrRegionId : void 0;
|
|
73
|
-
const currencyCode = currencyCodeOrRegionId.startsWith("reg_") ? regionsCurrencyMap[regionId] : currencyCodeOrRegionId;
|
|
74
|
-
let existingId = void 0;
|
|
75
|
-
if (regionId) {
|
|
76
|
-
existingId = (_c = (_b = (_a3 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a3.prices) == null ? void 0 : _b.find(
|
|
77
|
-
(p) => p.rules["region_id"] === regionId
|
|
78
|
-
)) == null ? void 0 : _c.id;
|
|
79
|
-
} else {
|
|
80
|
-
existingId = (_f = (_e = (_d = variants == null ? void 0 : variants[ind]) == null ? void 0 : _d.prices) == null ? void 0 : _e.find(
|
|
81
|
-
(p) => p.currency_code === currencyCode && Object.keys(p.rules ?? {}).length === 0
|
|
82
|
-
)) == null ? void 0 : _f.id;
|
|
83
|
-
}
|
|
84
|
-
const amount = castNumber(value);
|
|
85
|
-
return {
|
|
86
|
-
id: existingId,
|
|
87
|
-
currency_code: currencyCode,
|
|
88
|
-
amount,
|
|
89
|
-
...regionId ? { rules: { region_id: regionId } } : {}
|
|
90
|
-
};
|
|
91
|
-
})
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
await mutateAsync(reqData, {
|
|
95
|
-
onSuccess: () => {
|
|
96
|
-
handleSuccess("..");
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex size-full flex-col", children: [
|
|
101
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
102
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-col overflow-hidden", children: /* @__PURE__ */ jsx(VariantPricingForm, { form }) }),
|
|
103
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-end gap-x-2", children: [
|
|
104
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
105
|
-
/* @__PURE__ */ jsx(
|
|
106
|
-
Button,
|
|
107
|
-
{
|
|
108
|
-
type: "submit",
|
|
109
|
-
variant: "primary",
|
|
110
|
-
size: "small",
|
|
111
|
-
isLoading: isPending,
|
|
112
|
-
children: "Save"
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
] }) })
|
|
116
|
-
] }) });
|
|
117
|
-
};
|
|
118
|
-
export {
|
|
119
|
-
PricingEdit,
|
|
120
|
-
UpdateDenominationPricesSchema
|
|
121
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useWatch } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
4
|
-
import { DataGrid } from "../../../../../components/data-grid/data-grid.js";
|
|
5
|
-
import { createDataGridHelper } from "../../../../../components/data-grid/helpers/create-data-grid-column-helper.js";
|
|
6
|
-
import { createDataGridPriceColumns } from "../../../../../components/data-grid/helpers/create-data-grid-price-columns.js";
|
|
7
|
-
import "../../../../../components/modals/route-drawer/route-drawer.js";
|
|
8
|
-
import "../../../../../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 { usePricePreferences } from "../../../../../hooks/api/price-preferences.js";
|
|
16
|
-
import { useRegions } from "../../../../../hooks/api/regions.js";
|
|
17
|
-
import { useStore } from "../../../../../hooks/api/store.js";
|
|
18
|
-
const VariantPricingForm = ({ form }) => {
|
|
19
|
-
const { store } = useStore();
|
|
20
|
-
const { regions } = useRegions({ limit: 9999 });
|
|
21
|
-
const { price_preferences: pricePreferences } = usePricePreferences({});
|
|
22
|
-
const { setCloseOnEscape } = useRouteModal();
|
|
23
|
-
const columns = useVariantPriceGridColumns({
|
|
24
|
-
currencies: store == null ? void 0 : store.supported_currencies,
|
|
25
|
-
regions,
|
|
26
|
-
pricePreferences
|
|
27
|
-
});
|
|
28
|
-
const variants = useWatch({
|
|
29
|
-
control: form.control,
|
|
30
|
-
name: "variants"
|
|
31
|
-
});
|
|
32
|
-
return /* @__PURE__ */ jsx(
|
|
33
|
-
DataGrid,
|
|
34
|
-
{
|
|
35
|
-
columns,
|
|
36
|
-
data: variants,
|
|
37
|
-
state: form,
|
|
38
|
-
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
const columnHelper = createDataGridHelper();
|
|
43
|
-
const useVariantPriceGridColumns = ({
|
|
44
|
-
currencies = [],
|
|
45
|
-
regions = [],
|
|
46
|
-
pricePreferences = []
|
|
47
|
-
}) => {
|
|
48
|
-
return useMemo(() => {
|
|
49
|
-
return [
|
|
50
|
-
columnHelper.column({
|
|
51
|
-
id: "Title",
|
|
52
|
-
header: "Title",
|
|
53
|
-
cell: (context) => {
|
|
54
|
-
const entity = context.row.original;
|
|
55
|
-
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: entity.title }) }) });
|
|
56
|
-
},
|
|
57
|
-
disableHiding: true
|
|
58
|
-
}),
|
|
59
|
-
...createDataGridPriceColumns({
|
|
60
|
-
currencies: currencies.map((c) => c.currency_code),
|
|
61
|
-
regions,
|
|
62
|
-
pricePreferences,
|
|
63
|
-
getFieldName: (context, value) => {
|
|
64
|
-
return `variants.${context.row.index}.prices.${value}`;
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
];
|
|
68
|
-
}, [currencies, regions, pricePreferences]);
|
|
69
|
-
};
|
|
70
|
-
export {
|
|
71
|
-
VariantPricingForm
|
|
72
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useParams } from "react-router-dom";
|
|
3
|
-
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
4
|
-
import { RouteFocusModal } from "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
5
|
-
import "react";
|
|
6
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
7
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
8
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
9
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
10
|
-
import { useProduct } from "../../../../hooks/api/products.js";
|
|
11
|
-
import { PricingEdit } from "./components/prices-edit.js";
|
|
12
|
-
const ProductPrices = () => {
|
|
13
|
-
const { id, variant_id } = useParams();
|
|
14
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
15
|
-
if (isError) {
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
ProductPrices,
|
|
22
|
-
ProductPrices as default
|
|
23
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createDataTableColumnHelper, Button } from "@medusajs/ui";
|
|
3
|
-
import { useState, useEffect, useMemo } from "react";
|
|
4
|
-
import * as zod from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
5
|
-
import { zodResolver } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/@hookform/resolvers/zod/dist/zod.mjs";
|
|
6
|
-
import { keepPreviousData } from "@tanstack/react-query";
|
|
7
|
-
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
8
|
-
import { DataTable } from "../../../../../components/data-table.js";
|
|
9
|
-
import { useSalesChannelTableColumns } from "../../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-columns.js";
|
|
10
|
-
import { useSalesChannelTableEmptyState } from "../../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-empty-state.js";
|
|
11
|
-
import { useSalesChannelTableFilters } from "../../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-filters.js";
|
|
12
|
-
import { useSalesChannelTableQuery } from "../../../../../components/data-table/helpers/sales-channels/use-sales-channel-table-query.js";
|
|
13
|
-
import "../../../../../components/modals/route-drawer/route-drawer.js";
|
|
14
|
-
import { RouteFocusModal } from "../../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
15
|
-
import "react-router-dom";
|
|
16
|
-
import "../../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
17
|
-
import { useRouteModal } from "../../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
18
|
-
import "../../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
19
|
-
import "../../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
20
|
-
import "../../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
21
|
-
import { useUpdateProduct } from "../../../../../hooks/api/products.js";
|
|
22
|
-
import { useSalesChannels } from "../../../../../hooks/api/sales-channels.js";
|
|
23
|
-
const EditSalesChannelsSchema = zod.object({
|
|
24
|
-
sales_channels: zod.array(zod.string()).optional()
|
|
25
|
-
});
|
|
26
|
-
const PAGE_SIZE = 50;
|
|
27
|
-
const PREFIX = "sc";
|
|
28
|
-
const EditSalesChannelsForm = ({
|
|
29
|
-
product
|
|
30
|
-
}) => {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
const { handleSuccess } = useRouteModal();
|
|
33
|
-
const form = useForm({
|
|
34
|
-
defaultValues: {
|
|
35
|
-
sales_channels: ((_a = product.sales_channels) == null ? void 0 : _a.map((sc) => sc.id)) ?? []
|
|
36
|
-
},
|
|
37
|
-
resolver: zodResolver(EditSalesChannelsSchema)
|
|
38
|
-
});
|
|
39
|
-
const { setValue } = form;
|
|
40
|
-
const initialState = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41
|
-
acc[curr.id] = true;
|
|
42
|
-
return acc;
|
|
43
|
-
}, {})) ?? {};
|
|
44
|
-
const [rowSelection, setRowSelection] = useState(initialState);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const ids = Object.keys(rowSelection);
|
|
47
|
-
setValue("sales_channels", ids, {
|
|
48
|
-
shouldDirty: true,
|
|
49
|
-
shouldTouch: true
|
|
50
|
-
});
|
|
51
|
-
}, [rowSelection, setValue]);
|
|
52
|
-
const searchParams = useSalesChannelTableQuery({
|
|
53
|
-
pageSize: PAGE_SIZE,
|
|
54
|
-
prefix: PREFIX
|
|
55
|
-
});
|
|
56
|
-
const { sales_channels, count, isLoading, isError, error } = useSalesChannels(
|
|
57
|
-
{
|
|
58
|
-
...searchParams
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
placeholderData: keepPreviousData
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
const filters = useSalesChannelTableFilters();
|
|
65
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
66
|
-
const columns = useColumns();
|
|
67
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
68
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
69
|
-
const arr = data.sales_channels ?? [];
|
|
70
|
-
const sales_channels2 = arr.map((id) => {
|
|
71
|
-
return {
|
|
72
|
-
id
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
await mutateAsync(
|
|
76
|
-
{
|
|
77
|
-
sales_channels: sales_channels2
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
onSuccess: () => {
|
|
81
|
-
handleSuccess();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
if (isError) {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
90
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
91
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
92
|
-
DataTable,
|
|
93
|
-
{
|
|
94
|
-
data: sales_channels,
|
|
95
|
-
columns,
|
|
96
|
-
getRowId: (row) => row.id,
|
|
97
|
-
rowCount: count,
|
|
98
|
-
isLoading,
|
|
99
|
-
filters,
|
|
100
|
-
rowSelection: {
|
|
101
|
-
state: rowSelection,
|
|
102
|
-
onRowSelectionChange: setRowSelection
|
|
103
|
-
},
|
|
104
|
-
autoFocusSearch: true,
|
|
105
|
-
layout: "fill",
|
|
106
|
-
emptyState,
|
|
107
|
-
prefix: PREFIX
|
|
108
|
-
}
|
|
109
|
-
) }),
|
|
110
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
111
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
112
|
-
/* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
113
|
-
] }) })
|
|
114
|
-
] }) });
|
|
115
|
-
};
|
|
116
|
-
const columnHelper = createDataTableColumnHelper();
|
|
117
|
-
const useColumns = () => {
|
|
118
|
-
const columns = useSalesChannelTableColumns();
|
|
119
|
-
return useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
120
|
-
};
|
|
121
|
-
export {
|
|
122
|
-
EditSalesChannelsForm
|
|
123
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useParams } from "react-router-dom";
|
|
3
|
-
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
4
|
-
import { RouteFocusModal } from "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
5
|
-
import "react";
|
|
6
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
7
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
8
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
9
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
10
|
-
import { useProduct } from "../../../../hooks/api/products.js";
|
|
11
|
-
import { EditSalesChannelsForm } from "./components/edit-sales-channel-form.js";
|
|
12
|
-
const ProductSalesChannels = () => {
|
|
13
|
-
const { id } = useParams();
|
|
14
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
15
|
-
if (isError) {
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
ProductSalesChannels,
|
|
22
|
-
ProductSalesChannels as default
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { useWatch } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
4
|
-
import { DataGrid } from "../../../../components/data-grid/data-grid.js";
|
|
5
|
-
import { createDataGridHelper } from "../../../../components/data-grid/helpers/create-data-grid-column-helper.js";
|
|
6
|
-
import { createDataGridPriceColumns } from "../../../../components/data-grid/helpers/create-data-grid-price-columns.js";
|
|
7
|
-
import "../../../../components/modals/route-drawer/route-drawer.js";
|
|
8
|
-
import "../../../../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
|
-
const GiftCardProductCreateDenominationsForm = ({
|
|
16
|
-
form,
|
|
17
|
-
regions,
|
|
18
|
-
store,
|
|
19
|
-
pricePreferences
|
|
20
|
-
}) => {
|
|
21
|
-
const { setCloseOnEscape } = useRouteModal();
|
|
22
|
-
const currencyCodes = useMemo(
|
|
23
|
-
() => {
|
|
24
|
-
var _a;
|
|
25
|
-
return ((_a = store == null ? void 0 : store.supported_currencies) == null ? void 0 : _a.map((c) => c.currency_code)) || [];
|
|
26
|
-
},
|
|
27
|
-
[store]
|
|
28
|
-
);
|
|
29
|
-
const denominations = useWatch({
|
|
30
|
-
control: form.control,
|
|
31
|
-
name: "denominations",
|
|
32
|
-
defaultValue: []
|
|
33
|
-
});
|
|
34
|
-
const columns = useColumns({
|
|
35
|
-
denominations,
|
|
36
|
-
currencies: currencyCodes,
|
|
37
|
-
regions,
|
|
38
|
-
pricePreferences
|
|
39
|
-
});
|
|
40
|
-
const variantData = useMemo(() => {
|
|
41
|
-
const ret = [];
|
|
42
|
-
denominations.forEach((v, i) => {
|
|
43
|
-
ret.push({ ...v, originalIndex: i });
|
|
44
|
-
});
|
|
45
|
-
return ret;
|
|
46
|
-
}, [denominations]);
|
|
47
|
-
return /* @__PURE__ */ jsx("div", { className: "flex size-full flex-col divide-y overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
48
|
-
DataGrid,
|
|
49
|
-
{
|
|
50
|
-
columns,
|
|
51
|
-
data: variantData,
|
|
52
|
-
state: form,
|
|
53
|
-
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
54
|
-
}
|
|
55
|
-
) });
|
|
56
|
-
};
|
|
57
|
-
const columnHelper = createDataGridHelper();
|
|
58
|
-
const useColumns = ({
|
|
59
|
-
denominations = [],
|
|
60
|
-
currencies = [],
|
|
61
|
-
regions = [],
|
|
62
|
-
pricePreferences = []
|
|
63
|
-
}) => {
|
|
64
|
-
return useMemo(
|
|
65
|
-
() => [
|
|
66
|
-
columnHelper.column({
|
|
67
|
-
id: "denominations",
|
|
68
|
-
header: () => /* @__PURE__ */ jsx("div", { className: "flex size-full items-center overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: "Denomination" }) }),
|
|
69
|
-
cell: (context) => {
|
|
70
|
-
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, children: context.row.original.value });
|
|
71
|
-
},
|
|
72
|
-
disableHiding: true
|
|
73
|
-
}),
|
|
74
|
-
columnHelper.column({
|
|
75
|
-
id: "sku",
|
|
76
|
-
name: "SKU",
|
|
77
|
-
header: "SKU",
|
|
78
|
-
field: (context) => `denominations.${context.row.original.originalIndex}.sku`,
|
|
79
|
-
type: "text",
|
|
80
|
-
cell: (context) => {
|
|
81
|
-
return /* @__PURE__ */ jsx(DataGrid.TextCell, { context });
|
|
82
|
-
}
|
|
83
|
-
}),
|
|
84
|
-
...createDataGridPriceColumns({
|
|
85
|
-
currencies,
|
|
86
|
-
regions,
|
|
87
|
-
pricePreferences,
|
|
88
|
-
getFieldName: (context, value) => {
|
|
89
|
-
return `denominations.${context.row.original.originalIndex}.prices.${value}`;
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
],
|
|
93
|
-
[currencies, regions, denominations, pricePreferences]
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
export {
|
|
97
|
-
GiftCardProductCreateDenominationsForm
|
|
98
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Divider, Heading } from "@medusajs/ui";
|
|
3
|
-
import { GiftCardProductCreateFormDenominations } from "./gift-card-product-create-form-denominations.js";
|
|
4
|
-
import { GiftCardProductCreateFormGeneral } from "./gift-card-product-create-form-general.js";
|
|
5
|
-
import { GiftCardProductCreateFormMedia } from "./gift-card-product-create-form-media.js";
|
|
6
|
-
import { GiftCardProductCreateOrganizeForm } from "./gift-card-product-create-form-organize.js";
|
|
7
|
-
const GiftCardProductCreateDetailsForm = ({
|
|
8
|
-
form
|
|
9
|
-
}) => {
|
|
10
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
11
|
-
/* @__PURE__ */ jsx(Header, {}),
|
|
12
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
13
|
-
/* @__PURE__ */ jsx(GiftCardProductCreateFormGeneral, { form }),
|
|
14
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
15
|
-
/* @__PURE__ */ jsx(GiftCardProductCreateFormMedia, { form }),
|
|
16
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
17
|
-
/* @__PURE__ */ jsx(GiftCardProductCreateOrganizeForm, { form }),
|
|
18
|
-
/* @__PURE__ */ jsx(Divider, {}),
|
|
19
|
-
/* @__PURE__ */ jsx(GiftCardProductCreateFormDenominations, { form })
|
|
20
|
-
] })
|
|
21
|
-
] }) });
|
|
22
|
-
};
|
|
23
|
-
const Header = () => {
|
|
24
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx(Heading, { children: "Create Gift Card Product" }) });
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
GiftCardProductCreateDetailsForm
|
|
28
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { MinusMini } from "@medusajs/icons";
|
|
3
|
-
import { Text, Input, Button, Alert } from "@medusajs/ui";
|
|
4
|
-
import { useFieldArray } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
5
|
-
import { Form } from "../../../../components/form.js";
|
|
6
|
-
const GiftCardProductCreateFormDenominations = ({
|
|
7
|
-
form
|
|
8
|
-
}) => {
|
|
9
|
-
const {
|
|
10
|
-
fields: denominationsFields,
|
|
11
|
-
append: addDenomination,
|
|
12
|
-
remove: removeDenomination
|
|
13
|
-
} = useFieldArray({
|
|
14
|
-
name: "denominations",
|
|
15
|
-
control: form.control
|
|
16
|
-
});
|
|
17
|
-
return /* @__PURE__ */ jsxs("div", { id: "variants", className: "grid grid-cols-1 gap-y-6 md:grid-cols-2", children: [
|
|
18
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
19
|
-
/* @__PURE__ */ jsx(
|
|
20
|
-
Text,
|
|
21
|
-
{
|
|
22
|
-
className: "txt-compact-small-plus text-ui-fg-base",
|
|
23
|
-
weight: "regular",
|
|
24
|
-
children: "Denominations"
|
|
25
|
-
}
|
|
26
|
-
),
|
|
27
|
-
/* @__PURE__ */ jsx(Text, { className: "txt-small text-ui-fg-muted", children: "Denominations are the different values that can be selected for the gift card product." })
|
|
28
|
-
] }),
|
|
29
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
30
|
-
denominationsFields.map((denominationField, index) => {
|
|
31
|
-
return /* @__PURE__ */ jsxs(
|
|
32
|
-
"div",
|
|
33
|
-
{
|
|
34
|
-
className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
|
|
35
|
-
children: [
|
|
36
|
-
/* @__PURE__ */ jsx(
|
|
37
|
-
Form.Field,
|
|
38
|
-
{
|
|
39
|
-
control: form.control,
|
|
40
|
-
name: `denominations.${index}.value`,
|
|
41
|
-
render: ({ field }) => {
|
|
42
|
-
return /* @__PURE__ */ jsxs(Form.Item, { className: "w-full", children: [
|
|
43
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
44
|
-
Input,
|
|
45
|
-
{
|
|
46
|
-
...field,
|
|
47
|
-
placeholder: "100",
|
|
48
|
-
required: true,
|
|
49
|
-
type: "number",
|
|
50
|
-
min: 0
|
|
51
|
-
}
|
|
52
|
-
) }),
|
|
53
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
54
|
-
] });
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
denominationField.id
|
|
58
|
-
),
|
|
59
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
60
|
-
Button,
|
|
61
|
-
{
|
|
62
|
-
size: "small",
|
|
63
|
-
variant: "secondary",
|
|
64
|
-
type: "button",
|
|
65
|
-
className: "rounded-full bg-red-500 text-white p-0 ml-4 hover:bg-red-600",
|
|
66
|
-
onClick: () => {
|
|
67
|
-
removeDenomination(index);
|
|
68
|
-
},
|
|
69
|
-
children: /* @__PURE__ */ jsx(MinusMini, { className: "rounded-full" })
|
|
70
|
-
}
|
|
71
|
-
) })
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
denominationField.id
|
|
75
|
-
);
|
|
76
|
-
}),
|
|
77
|
-
/* @__PURE__ */ jsx(
|
|
78
|
-
Button,
|
|
79
|
-
{
|
|
80
|
-
size: "small",
|
|
81
|
-
variant: "secondary",
|
|
82
|
-
type: "button",
|
|
83
|
-
className: "w-full",
|
|
84
|
-
onClick: () => {
|
|
85
|
-
addDenomination({ value: "", sku: "", prices: {} });
|
|
86
|
-
},
|
|
87
|
-
children: "Add denomination"
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
91
|
-
] }) }) })
|
|
92
|
-
] });
|
|
93
|
-
};
|
|
94
|
-
export {
|
|
95
|
-
GiftCardProductCreateFormDenominations
|
|
96
|
-
};
|