@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,17 +0,0 @@
|
|
|
1
|
-
const queryKeysFactory = (globalKey) => {
|
|
2
|
-
const queryKeyFactory = {
|
|
3
|
-
all: [globalKey],
|
|
4
|
-
lists: () => [...queryKeyFactory.all, "list"],
|
|
5
|
-
list: (query) => [...queryKeyFactory.lists(), { query }],
|
|
6
|
-
details: () => [...queryKeyFactory.all, "detail"],
|
|
7
|
-
detail: (id, query) => [
|
|
8
|
-
...queryKeyFactory.details(),
|
|
9
|
-
id,
|
|
10
|
-
{ query }
|
|
11
|
-
]
|
|
12
|
-
};
|
|
13
|
-
return queryKeyFactory;
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
queryKeysFactory
|
|
17
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import "../../../components/modals/route-drawer/route-drawer.js";
|
|
3
|
-
import { RouteFocusModal } from "../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
4
|
-
import "react";
|
|
5
|
-
import "react-router-dom";
|
|
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 { usePricePreferences } from "../../../hooks/api/price-preferences.js";
|
|
11
|
-
import { useRegions } from "../../../hooks/api/regions.js";
|
|
12
|
-
import { useSalesChannel } from "../../../hooks/api/sales-channels.js";
|
|
13
|
-
import { useStore } from "../../../hooks/api/store.js";
|
|
14
|
-
import { GiftCardProductCreateForm } from "../components/gift-card-product-create-form/gift-card-product-create-form.js";
|
|
15
|
-
const GiftCardProductCreate = () => {
|
|
16
|
-
const {
|
|
17
|
-
store,
|
|
18
|
-
isPending: isStorePending,
|
|
19
|
-
isError: isStoreError,
|
|
20
|
-
error: storeError
|
|
21
|
-
} = useStore({
|
|
22
|
-
fields: "+default_sales_channel"
|
|
23
|
-
});
|
|
24
|
-
const {
|
|
25
|
-
sales_channel,
|
|
26
|
-
isPending: isSalesChannelPending,
|
|
27
|
-
isError: isSalesChannelError,
|
|
28
|
-
error: salesChannelError
|
|
29
|
-
} = useSalesChannel(store == null ? void 0 : store.default_sales_channel_id, {
|
|
30
|
-
enabled: !!(store == null ? void 0 : store.default_sales_channel_id)
|
|
31
|
-
});
|
|
32
|
-
const {
|
|
33
|
-
regions,
|
|
34
|
-
isPending: isRegionsPending,
|
|
35
|
-
isError: isRegionsError,
|
|
36
|
-
error: regionsError
|
|
37
|
-
} = useRegions({ limit: 9999 });
|
|
38
|
-
const {
|
|
39
|
-
price_preferences,
|
|
40
|
-
isPending: isPricePreferencesPending,
|
|
41
|
-
isError: isPricePreferencesError,
|
|
42
|
-
error: pricePreferencesError
|
|
43
|
-
} = usePricePreferences({
|
|
44
|
-
limit: 9999
|
|
45
|
-
});
|
|
46
|
-
const ready = !!store && !isStorePending && !!regions && !isRegionsPending && !!sales_channel && !isSalesChannelPending && !!price_preferences && !isPricePreferencesPending;
|
|
47
|
-
if (isStoreError) {
|
|
48
|
-
throw storeError;
|
|
49
|
-
}
|
|
50
|
-
if (isRegionsError) {
|
|
51
|
-
throw regionsError;
|
|
52
|
-
}
|
|
53
|
-
if (isSalesChannelError) {
|
|
54
|
-
throw salesChannelError;
|
|
55
|
-
}
|
|
56
|
-
if (isPricePreferencesError) {
|
|
57
|
-
throw pricePreferencesError;
|
|
58
|
-
}
|
|
59
|
-
return /* @__PURE__ */ jsxs(RouteFocusModal, { children: [
|
|
60
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Create Gift Card Product" }) }),
|
|
61
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Create a new gift card product" }) }),
|
|
62
|
-
ready && /* @__PURE__ */ jsx(
|
|
63
|
-
GiftCardProductCreateForm,
|
|
64
|
-
{
|
|
65
|
-
defaultChannel: sales_channel,
|
|
66
|
-
store,
|
|
67
|
-
pricePreferences: price_preferences,
|
|
68
|
-
regions
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
] });
|
|
72
|
-
};
|
|
73
|
-
export {
|
|
74
|
-
GiftCardProductCreate as default
|
|
75
|
-
};
|
|
@@ -1,172 +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 { MinusMini } from "@medusajs/icons";
|
|
4
|
-
import { toast, Input, Button, Alert } from "@medusajs/ui";
|
|
5
|
-
import { useForm, useFieldArray } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
6
|
-
import { z } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
7
|
-
import { Form } from "../../../../../components/form.js";
|
|
8
|
-
import { KeyboundForm } from "../../../../../components/keybound-form.js";
|
|
9
|
-
import { RouteDrawer } from "../../../../../components/modals/route-drawer/route-drawer.js";
|
|
10
|
-
import "../../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
11
|
-
import "react";
|
|
12
|
-
import "react-router-dom";
|
|
13
|
-
import "../../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
14
|
-
import { useRouteModal } from "../../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
15
|
-
import "../../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
16
|
-
import "../../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
17
|
-
import "../../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
18
|
-
import { useUpdateProduct } from "../../../../../hooks/api/products.js";
|
|
19
|
-
import { optionalFloat } from "../../../../../utils/validations.js";
|
|
20
|
-
const EditProductSchema = z.object({
|
|
21
|
-
denominations: z.array(
|
|
22
|
-
z.object({
|
|
23
|
-
id: z.string().optional(),
|
|
24
|
-
value: z.string().min(1),
|
|
25
|
-
sku: z.string().optional(),
|
|
26
|
-
prices: z.record(z.string(), optionalFloat).optional()
|
|
27
|
-
})
|
|
28
|
-
).min(1)
|
|
29
|
-
});
|
|
30
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
31
|
-
product
|
|
32
|
-
}) => {
|
|
33
|
-
var _a;
|
|
34
|
-
const { handleSuccess } = useRouteModal();
|
|
35
|
-
const form = useForm({
|
|
36
|
-
defaultValues: {
|
|
37
|
-
denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => {
|
|
38
|
-
var _a2;
|
|
39
|
-
return {
|
|
40
|
-
id: variant.id,
|
|
41
|
-
value: variant.title,
|
|
42
|
-
sku: ((_a2 = variant.sku) == null ? void 0 : _a2.length) ? variant.sku : void 0
|
|
43
|
-
};
|
|
44
|
-
})
|
|
45
|
-
},
|
|
46
|
-
resolver: zodResolver(EditProductSchema)
|
|
47
|
-
});
|
|
48
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
49
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
50
|
-
const optionValues = data.denominations.map(
|
|
51
|
-
(denomination) => denomination.value
|
|
52
|
-
);
|
|
53
|
-
const options = [
|
|
54
|
-
{
|
|
55
|
-
title: "denomination",
|
|
56
|
-
values: optionValues
|
|
57
|
-
}
|
|
58
|
-
];
|
|
59
|
-
await mutateAsync(
|
|
60
|
-
{
|
|
61
|
-
options,
|
|
62
|
-
variants: data.denominations.map((denomination) => {
|
|
63
|
-
var _a2;
|
|
64
|
-
return {
|
|
65
|
-
id: denomination.id,
|
|
66
|
-
title: denomination.value,
|
|
67
|
-
sku: ((_a2 = denomination.sku) == null ? void 0 : _a2.length) ? denomination.sku : void 0,
|
|
68
|
-
options: {
|
|
69
|
-
denomination: denomination.value
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
})
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
onSuccess: () => {
|
|
76
|
-
toast.success(`Denominations updated successfully`);
|
|
77
|
-
handleSuccess();
|
|
78
|
-
},
|
|
79
|
-
onError: (e) => {
|
|
80
|
-
toast.error(e.message);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
const {
|
|
86
|
-
fields: denominationsFields,
|
|
87
|
-
append: addDenomination,
|
|
88
|
-
remove: removeDenomination
|
|
89
|
-
} = useFieldArray({
|
|
90
|
-
name: "denominations",
|
|
91
|
-
control: form.control
|
|
92
|
-
});
|
|
93
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
94
|
-
KeyboundForm,
|
|
95
|
-
{
|
|
96
|
-
onSubmit: handleSubmit,
|
|
97
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
98
|
-
children: [
|
|
99
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__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: [
|
|
100
|
-
denominationsFields.map((denominationField, index) => {
|
|
101
|
-
return /* @__PURE__ */ jsxs(
|
|
102
|
-
"div",
|
|
103
|
-
{
|
|
104
|
-
className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
|
|
105
|
-
children: [
|
|
106
|
-
/* @__PURE__ */ jsx(
|
|
107
|
-
Form.Field,
|
|
108
|
-
{
|
|
109
|
-
control: form.control,
|
|
110
|
-
name: `denominations.${index}.value`,
|
|
111
|
-
render: ({ field }) => {
|
|
112
|
-
return /* @__PURE__ */ jsxs(Form.Item, { className: "w-full", children: [
|
|
113
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
|
|
114
|
-
Input,
|
|
115
|
-
{
|
|
116
|
-
...field,
|
|
117
|
-
placeholder: "100",
|
|
118
|
-
required: true,
|
|
119
|
-
type: "number",
|
|
120
|
-
min: 0
|
|
121
|
-
}
|
|
122
|
-
) }),
|
|
123
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
124
|
-
] });
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
denominationField.id
|
|
128
|
-
),
|
|
129
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
130
|
-
Button,
|
|
131
|
-
{
|
|
132
|
-
size: "small",
|
|
133
|
-
variant: "secondary",
|
|
134
|
-
type: "button",
|
|
135
|
-
className: "rounded-full bg-red-500 text-white p-0 ml-4 hover:bg-red-600",
|
|
136
|
-
onClick: () => {
|
|
137
|
-
removeDenomination(index);
|
|
138
|
-
},
|
|
139
|
-
children: /* @__PURE__ */ jsx(MinusMini, { className: "rounded-full" })
|
|
140
|
-
}
|
|
141
|
-
) })
|
|
142
|
-
]
|
|
143
|
-
},
|
|
144
|
-
denominationField.id
|
|
145
|
-
);
|
|
146
|
-
}),
|
|
147
|
-
/* @__PURE__ */ jsx(
|
|
148
|
-
Button,
|
|
149
|
-
{
|
|
150
|
-
size: "small",
|
|
151
|
-
variant: "secondary",
|
|
152
|
-
type: "button",
|
|
153
|
-
className: "w-full",
|
|
154
|
-
onClick: () => {
|
|
155
|
-
addDenomination({ value: "", sku: "", prices: {} });
|
|
156
|
-
},
|
|
157
|
-
children: "Add denomination"
|
|
158
|
-
}
|
|
159
|
-
),
|
|
160
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
161
|
-
] }) }) }) }),
|
|
162
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
163
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
164
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
165
|
-
] }) })
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
) });
|
|
169
|
-
};
|
|
170
|
-
export {
|
|
171
|
-
GiftCardProductEditDenominationsForm
|
|
172
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Heading } from "@medusajs/ui";
|
|
3
|
-
import { useParams } from "react-router-dom";
|
|
4
|
-
import { RouteDrawer } from "../../../../components/modals/route-drawer/route-drawer.js";
|
|
5
|
-
import "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
6
|
-
import "react";
|
|
7
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
8
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
9
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
10
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
11
|
-
import { useProduct } from "../../../../hooks/api/products.js";
|
|
12
|
-
import { GiftCardProductEditDenominationsForm } from "./components/gift-card-product-edit-denominations-form.js";
|
|
13
|
-
const GiftCardProductEdit = () => {
|
|
14
|
-
const { id } = useParams();
|
|
15
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
16
|
-
if (isError) {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
20
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
21
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
|
|
22
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
|
|
23
|
-
] }),
|
|
24
|
-
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
25
|
-
] });
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
GiftCardProductEdit,
|
|
29
|
-
GiftCardProductEdit as default
|
|
30
|
-
};
|
|
@@ -1,180 +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, Select, Input, Text, Textarea, Button } from "@medusajs/ui";
|
|
4
|
-
import { useForm } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-hook-form/dist/index.esm.mjs";
|
|
5
|
-
import { z } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/zod/lib/index.mjs";
|
|
6
|
-
import { Form } from "../../../../../components/form.js";
|
|
7
|
-
import { KeyboundForm } from "../../../../../components/keybound-form.js";
|
|
8
|
-
import { RouteDrawer } from "../../../../../components/modals/route-drawer/route-drawer.js";
|
|
9
|
-
import "../../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
10
|
-
import "react";
|
|
11
|
-
import "react-router-dom";
|
|
12
|
-
import "../../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
13
|
-
import { useRouteModal } from "../../../../../components/modals/route-modal-provider/use-route-modal.js";
|
|
14
|
-
import "../../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
15
|
-
import "../../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
16
|
-
import "../../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
17
|
-
import { useUpdateProduct } from "../../../../../hooks/api/products.js";
|
|
18
|
-
const EditProductSchema = z.object({
|
|
19
|
-
status: z.enum(["draft", "published", "proposed", "rejected"]),
|
|
20
|
-
title: z.string().min(1),
|
|
21
|
-
subtitle: z.string().optional(),
|
|
22
|
-
handle: z.string().min(1),
|
|
23
|
-
description: z.string().optional()
|
|
24
|
-
});
|
|
25
|
-
const GiftCardProductEditForm = ({
|
|
26
|
-
product
|
|
27
|
-
}) => {
|
|
28
|
-
const { handleSuccess } = useRouteModal();
|
|
29
|
-
const form = useForm({
|
|
30
|
-
defaultValues: {
|
|
31
|
-
status: product.status,
|
|
32
|
-
title: product.title,
|
|
33
|
-
subtitle: product.subtitle || "",
|
|
34
|
-
handle: product.handle || "",
|
|
35
|
-
description: product.description || ""
|
|
36
|
-
},
|
|
37
|
-
resolver: zodResolver(EditProductSchema)
|
|
38
|
-
});
|
|
39
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41
|
-
const { title, handle, status, ...optional } = data;
|
|
42
|
-
await mutateAsync(
|
|
43
|
-
{
|
|
44
|
-
...optional,
|
|
45
|
-
title,
|
|
46
|
-
handle,
|
|
47
|
-
status
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
onSuccess: ({ product: product2 }) => {
|
|
51
|
-
toast.success(
|
|
52
|
-
`Gift card product ${product2.title} updated successfully`
|
|
53
|
-
);
|
|
54
|
-
handleSuccess();
|
|
55
|
-
},
|
|
56
|
-
onError: (e) => {
|
|
57
|
-
toast.error(e.message);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
63
|
-
KeyboundForm,
|
|
64
|
-
{
|
|
65
|
-
onSubmit: handleSubmit,
|
|
66
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
69
|
-
/* @__PURE__ */ jsx(
|
|
70
|
-
Form.Field,
|
|
71
|
-
{
|
|
72
|
-
control: form.control,
|
|
73
|
-
name: "status",
|
|
74
|
-
render: ({ field: { onChange, ref, ...field } }) => {
|
|
75
|
-
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
76
|
-
/* @__PURE__ */ jsx(Form.Label, { children: "Status" }),
|
|
77
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
|
|
78
|
-
/* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
79
|
-
/* @__PURE__ */ jsx(Select.Content, { children: [
|
|
80
|
-
"draft",
|
|
81
|
-
"published",
|
|
82
|
-
"proposed",
|
|
83
|
-
"rejected"
|
|
84
|
-
].map((status) => {
|
|
85
|
-
return /* @__PURE__ */ jsx(
|
|
86
|
-
Select.Item,
|
|
87
|
-
{
|
|
88
|
-
value: status,
|
|
89
|
-
className: "capitalize",
|
|
90
|
-
children: status
|
|
91
|
-
},
|
|
92
|
-
status
|
|
93
|
-
);
|
|
94
|
-
}) })
|
|
95
|
-
] }) }),
|
|
96
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
97
|
-
] });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
),
|
|
101
|
-
/* @__PURE__ */ jsx(
|
|
102
|
-
Form.Field,
|
|
103
|
-
{
|
|
104
|
-
control: form.control,
|
|
105
|
-
name: "title",
|
|
106
|
-
render: ({ field }) => {
|
|
107
|
-
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
108
|
-
/* @__PURE__ */ jsx(Form.Label, { children: "Title" }),
|
|
109
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
110
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
111
|
-
] });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
),
|
|
115
|
-
/* @__PURE__ */ jsx(
|
|
116
|
-
Form.Field,
|
|
117
|
-
{
|
|
118
|
-
control: form.control,
|
|
119
|
-
name: "subtitle",
|
|
120
|
-
render: ({ field }) => {
|
|
121
|
-
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
122
|
-
/* @__PURE__ */ jsx(Form.Label, { optional: true, children: "Subtitle" }),
|
|
123
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
124
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
125
|
-
] });
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
),
|
|
129
|
-
/* @__PURE__ */ jsx(
|
|
130
|
-
Form.Field,
|
|
131
|
-
{
|
|
132
|
-
control: form.control,
|
|
133
|
-
name: "handle",
|
|
134
|
-
render: ({ field }) => {
|
|
135
|
-
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
136
|
-
/* @__PURE__ */ jsx(Form.Label, { children: "Handle" }),
|
|
137
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
138
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
|
|
139
|
-
Text,
|
|
140
|
-
{
|
|
141
|
-
className: "text-ui-fg-muted",
|
|
142
|
-
size: "small",
|
|
143
|
-
leading: "compact",
|
|
144
|
-
weight: "plus",
|
|
145
|
-
children: "/"
|
|
146
|
-
}
|
|
147
|
-
) }),
|
|
148
|
-
/* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
|
|
149
|
-
] }) }),
|
|
150
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
151
|
-
] });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
),
|
|
155
|
-
/* @__PURE__ */ jsx(
|
|
156
|
-
Form.Field,
|
|
157
|
-
{
|
|
158
|
-
control: form.control,
|
|
159
|
-
name: "description",
|
|
160
|
-
render: ({ field }) => {
|
|
161
|
-
return /* @__PURE__ */ jsxs(Form.Item, { children: [
|
|
162
|
-
/* @__PURE__ */ jsx(Form.Label, { optional: true, children: "Description" }),
|
|
163
|
-
/* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
164
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, {})
|
|
165
|
-
] });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
)
|
|
169
|
-
] }) }) }),
|
|
170
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
171
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
172
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
173
|
-
] }) })
|
|
174
|
-
]
|
|
175
|
-
}
|
|
176
|
-
) });
|
|
177
|
-
};
|
|
178
|
-
export {
|
|
179
|
-
GiftCardProductEditForm
|
|
180
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Heading } from "@medusajs/ui";
|
|
3
|
-
import { useParams } from "react-router-dom";
|
|
4
|
-
import { RouteDrawer } from "../../../../components/modals/route-drawer/route-drawer.js";
|
|
5
|
-
import "../../../../components/modals/route-focus-modal/route-focus-modal.js";
|
|
6
|
-
import "react";
|
|
7
|
-
import "../../../../components/modals/route-modal-provider/route-modal-context.js";
|
|
8
|
-
import "../../../../components/modals/stacked-drawer/stacked-drawer.js";
|
|
9
|
-
import "../../../../components/modals/stacked-focus-modal/stacked-focus-modal.js";
|
|
10
|
-
import "../../../../components/modals/stacked-modal-provider/stacked-modal-context.js";
|
|
11
|
-
import { useProduct } from "../../../../hooks/api/products.js";
|
|
12
|
-
import { GiftCardProductEditForm } from "./components/gift-card-product-edit-form.js";
|
|
13
|
-
const GiftCardProductEdit = () => {
|
|
14
|
-
const { id } = useParams();
|
|
15
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
16
|
-
if (isError) {
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
20
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
21
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
|
|
22
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
|
|
23
|
-
] }),
|
|
24
|
-
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
|
|
25
|
-
] });
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
GiftCardProductEdit,
|
|
29
|
-
GiftCardProductEdit as default
|
|
30
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PencilSquare, Trash } from "@medusajs/icons";
|
|
3
|
-
import { usePrompt, Container, Heading, StatusBadge } from "@medusajs/ui";
|
|
4
|
-
import { useNavigate } from "react-router-dom";
|
|
5
|
-
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
6
|
-
import { SectionRow } from "../../../../components/section-row.js";
|
|
7
|
-
import { useDeleteProduct } from "../../../../hooks/api/products.js";
|
|
8
|
-
const productStatusColor = (status) => {
|
|
9
|
-
switch (status) {
|
|
10
|
-
case "draft":
|
|
11
|
-
return "grey";
|
|
12
|
-
case "proposed":
|
|
13
|
-
return "orange";
|
|
14
|
-
case "published":
|
|
15
|
-
return "green";
|
|
16
|
-
case "rejected":
|
|
17
|
-
return "red";
|
|
18
|
-
default:
|
|
19
|
-
return "grey";
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const ProductGeneralSection = ({
|
|
23
|
-
product
|
|
24
|
-
}) => {
|
|
25
|
-
const prompt = usePrompt();
|
|
26
|
-
const navigate = useNavigate();
|
|
27
|
-
const { mutateAsync } = useDeleteProduct(product.id);
|
|
28
|
-
const handleDelete = async () => {
|
|
29
|
-
const res = await prompt({
|
|
30
|
-
title: "Are you sure?",
|
|
31
|
-
description: `Are you sure you want to delete gift card product ${product.title}?`,
|
|
32
|
-
confirmText: "Delete",
|
|
33
|
-
cancelText: "Cancel"
|
|
34
|
-
});
|
|
35
|
-
if (!res) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
await mutateAsync(void 0, {
|
|
39
|
-
onSuccess: () => {
|
|
40
|
-
navigate("..");
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
45
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
46
|
-
/* @__PURE__ */ jsx(Heading, { children: product.title }),
|
|
47
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
|
|
48
|
-
/* @__PURE__ */ jsx(
|
|
49
|
-
StatusBadge,
|
|
50
|
-
{
|
|
51
|
-
color: productStatusColor(product.status),
|
|
52
|
-
className: "capitalize",
|
|
53
|
-
children: product.status
|
|
54
|
-
}
|
|
55
|
-
),
|
|
56
|
-
/* @__PURE__ */ jsx(
|
|
57
|
-
ActionMenu,
|
|
58
|
-
{
|
|
59
|
-
groups: [
|
|
60
|
-
{
|
|
61
|
-
actions: [
|
|
62
|
-
{
|
|
63
|
-
label: "Edit",
|
|
64
|
-
to: "edit",
|
|
65
|
-
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
actions: [
|
|
71
|
-
{
|
|
72
|
-
label: "Delete",
|
|
73
|
-
onClick: handleDelete,
|
|
74
|
-
icon: /* @__PURE__ */ jsx(Trash, {})
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
)
|
|
81
|
-
] })
|
|
82
|
-
] }),
|
|
83
|
-
/* @__PURE__ */ jsx(SectionRow, { title: "Description", value: product.description }),
|
|
84
|
-
/* @__PURE__ */ jsx(SectionRow, { title: "Subtitle", value: product.subtitle }),
|
|
85
|
-
/* @__PURE__ */ jsx(SectionRow, { title: "Handle", value: `/${product.handle}` }),
|
|
86
|
-
/* @__PURE__ */ jsx(
|
|
87
|
-
SectionRow,
|
|
88
|
-
{
|
|
89
|
-
title: "Discountable",
|
|
90
|
-
value: product.discountable.toString()
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
] });
|
|
94
|
-
};
|
|
95
|
-
export {
|
|
96
|
-
ProductGeneralSection
|
|
97
|
-
};
|