@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
package/.medusa/server/src/admin/routes/gift-card-products/_id_/components/product-media-section.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PencilSquare, ThumbnailBadge } from "@medusajs/icons";
|
|
3
|
-
import { usePrompt, Container, Heading, clx, Checkbox, Tooltip, Text, Button, CommandBar } from "@medusajs/ui";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { Link } from "react-router-dom";
|
|
6
|
-
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
7
|
-
import { useUpdateProduct } from "../../../../hooks/api/products.js";
|
|
8
|
-
const ProductMediaSection = ({ product }) => {
|
|
9
|
-
const prompt = usePrompt();
|
|
10
|
-
const [selection, setSelection] = useState({});
|
|
11
|
-
const media = getMedia(product);
|
|
12
|
-
const handleCheckedChange = (id) => {
|
|
13
|
-
setSelection((prev) => {
|
|
14
|
-
if (prev[id]) {
|
|
15
|
-
const { [id]: _, ...rest } = prev;
|
|
16
|
-
return rest;
|
|
17
|
-
} else {
|
|
18
|
-
return { ...prev, [id]: true };
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const { mutateAsync } = useUpdateProduct(product.id);
|
|
23
|
-
const handleDelete = async () => {
|
|
24
|
-
const ids = Object.keys(selection);
|
|
25
|
-
const includingThumbnail = ids.some(
|
|
26
|
-
(id) => {
|
|
27
|
-
var _a;
|
|
28
|
-
return (_a = media.find((m) => m.id === id)) == null ? void 0 : _a.isThumbnail;
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
const res = await prompt({
|
|
32
|
-
title: "Are you sure?",
|
|
33
|
-
description: includingThumbnail ? `Deleting ${ids.length} image(s) including the thumbnail. This will remove the thumbnail from the product.` : `Deleting ${ids.length} image(s).`,
|
|
34
|
-
confirmText: "Delete",
|
|
35
|
-
cancelText: "Cancel"
|
|
36
|
-
});
|
|
37
|
-
if (!res) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const mediaToKeep = ((product == null ? void 0 : product.images) || []).filter((i) => !ids.includes(i.id)).map((i) => ({ url: i.url }));
|
|
41
|
-
await mutateAsync(
|
|
42
|
-
{
|
|
43
|
-
images: mediaToKeep,
|
|
44
|
-
thumbnail: includingThumbnail ? "" : void 0
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
onSuccess: () => {
|
|
48
|
-
setSelection({});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
54
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
55
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Media" }),
|
|
56
|
-
/* @__PURE__ */ jsx(
|
|
57
|
-
ActionMenu,
|
|
58
|
-
{
|
|
59
|
-
groups: [
|
|
60
|
-
{
|
|
61
|
-
actions: [
|
|
62
|
-
{
|
|
63
|
-
label: "Edit",
|
|
64
|
-
to: "media?view=edit",
|
|
65
|
-
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
] }),
|
|
73
|
-
media.length > 0 ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-4 px-6 py-4", children: media.map((i, index) => {
|
|
74
|
-
const isSelected = selection[i.id];
|
|
75
|
-
return /* @__PURE__ */ jsxs(
|
|
76
|
-
"div",
|
|
77
|
-
{
|
|
78
|
-
className: "shadow-elevation-card-rest hover:shadow-elevation-card-hover transition-fg group relative aspect-square size-full cursor-pointer overflow-hidden rounded-[8px]",
|
|
79
|
-
children: [
|
|
80
|
-
/* @__PURE__ */ jsx(
|
|
81
|
-
"div",
|
|
82
|
-
{
|
|
83
|
-
className: clx(
|
|
84
|
-
"transition-fg invisible absolute right-2 top-2 opacity-0 group-hover:visible group-hover:opacity-100",
|
|
85
|
-
{
|
|
86
|
-
"visible opacity-100": isSelected
|
|
87
|
-
}
|
|
88
|
-
),
|
|
89
|
-
children: /* @__PURE__ */ jsx(
|
|
90
|
-
Checkbox,
|
|
91
|
-
{
|
|
92
|
-
checked: selection[i.id] || false,
|
|
93
|
-
onCheckedChange: () => handleCheckedChange(i.id)
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
),
|
|
98
|
-
i.isThumbnail && /* @__PURE__ */ jsx("div", { className: "absolute left-2 top-2", children: /* @__PURE__ */ jsx(Tooltip, { content: "Thumbnail", children: /* @__PURE__ */ jsx(ThumbnailBadge, {}) }) }),
|
|
99
|
-
/* @__PURE__ */ jsx(Link, { to: `media`, state: { curr: index }, children: /* @__PURE__ */ jsx(
|
|
100
|
-
"img",
|
|
101
|
-
{
|
|
102
|
-
src: i.url,
|
|
103
|
-
alt: `${product.title} image`,
|
|
104
|
-
className: "size-full object-cover"
|
|
105
|
-
}
|
|
106
|
-
) })
|
|
107
|
-
]
|
|
108
|
-
},
|
|
109
|
-
i.id
|
|
110
|
-
);
|
|
111
|
-
}) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-y-4 pb-8 pt-6", children: [
|
|
112
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
113
|
-
/* @__PURE__ */ jsx(
|
|
114
|
-
Text,
|
|
115
|
-
{
|
|
116
|
-
size: "small",
|
|
117
|
-
leading: "compact",
|
|
118
|
-
weight: "plus",
|
|
119
|
-
className: "text-ui-fg-subtle",
|
|
120
|
-
children: "No media yet"
|
|
121
|
-
}
|
|
122
|
-
),
|
|
123
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-muted", children: "Add images to your product" })
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "media?view=edit", children: "Add images" }) })
|
|
126
|
-
] }),
|
|
127
|
-
/* @__PURE__ */ jsx(CommandBar, { open: !!Object.keys(selection).length, children: /* @__PURE__ */ jsxs(CommandBar.Bar, { children: [
|
|
128
|
-
/* @__PURE__ */ jsxs(CommandBar.Value, { children: [
|
|
129
|
-
Object.keys(selection).length,
|
|
130
|
-
" selected"
|
|
131
|
-
] }),
|
|
132
|
-
/* @__PURE__ */ jsx(CommandBar.Seperator, {}),
|
|
133
|
-
/* @__PURE__ */ jsx(
|
|
134
|
-
CommandBar.Command,
|
|
135
|
-
{
|
|
136
|
-
action: handleDelete,
|
|
137
|
-
label: "Delete",
|
|
138
|
-
shortcut: "d"
|
|
139
|
-
}
|
|
140
|
-
)
|
|
141
|
-
] }) })
|
|
142
|
-
] });
|
|
143
|
-
};
|
|
144
|
-
const getMedia = (product) => {
|
|
145
|
-
const { images = [], thumbnail } = product;
|
|
146
|
-
const media = (images || []).map((image) => ({
|
|
147
|
-
id: image.id,
|
|
148
|
-
url: image.url,
|
|
149
|
-
isThumbnail: image.url === thumbnail
|
|
150
|
-
}));
|
|
151
|
-
if (thumbnail && !media.some((mediaItem) => mediaItem.url === thumbnail)) {
|
|
152
|
-
media.unshift({
|
|
153
|
-
id: "img_thumbnail",
|
|
154
|
-
url: thumbnail,
|
|
155
|
-
isThumbnail: true
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
return media;
|
|
159
|
-
};
|
|
160
|
-
export {
|
|
161
|
-
ProductMediaSection
|
|
162
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PencilSquare, Channels } from "@medusajs/icons";
|
|
3
|
-
import { Container, Heading, Text, Tooltip } from "@medusajs/ui";
|
|
4
|
-
import { Trans } from "/Users/oliverjuhl/Desktop/medusa/loyalty-plugin/node_modules/react-i18next/dist/es/index.js";
|
|
5
|
-
import { ActionMenu } from "../../../../components/action-menu.js";
|
|
6
|
-
import { useSalesChannels } from "../../../../hooks/api/sales-channels.js";
|
|
7
|
-
const ProductSalesChannelSection = ({
|
|
8
|
-
product
|
|
9
|
-
}) => {
|
|
10
|
-
var _a;
|
|
11
|
-
const { count } = useSalesChannels();
|
|
12
|
-
const availableInSalesChannels = ((_a = product.sales_channels) == null ? void 0 : _a.map((sc) => ({
|
|
13
|
-
id: sc.id,
|
|
14
|
-
name: sc.name
|
|
15
|
-
}))) ?? [];
|
|
16
|
-
const firstChannels = availableInSalesChannels.slice(0, 3);
|
|
17
|
-
const restChannels = availableInSalesChannels.slice(3);
|
|
18
|
-
return /* @__PURE__ */ jsxs(Container, { className: "flex flex-col gap-y-4 px-6 py-4", children: [
|
|
19
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
20
|
-
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Sales Channels" }),
|
|
21
|
-
/* @__PURE__ */ jsx(
|
|
22
|
-
ActionMenu,
|
|
23
|
-
{
|
|
24
|
-
groups: [
|
|
25
|
-
{
|
|
26
|
-
actions: [
|
|
27
|
-
{
|
|
28
|
-
label: "Edit",
|
|
29
|
-
to: "sales-channels",
|
|
30
|
-
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
)
|
|
37
|
-
] }),
|
|
38
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[28px_1fr] items-center gap-x-3", children: [
|
|
39
|
-
/* @__PURE__ */ jsx("div", { className: "bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md", children: /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]", children: /* @__PURE__ */ jsx(Channels, { className: "text-ui-fg-subtle" }) }) }),
|
|
40
|
-
availableInSalesChannels.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
41
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: firstChannels.map((sc) => sc.name).join(", ") }),
|
|
42
|
-
restChannels.length > 0 && /* @__PURE__ */ jsx(
|
|
43
|
-
Tooltip,
|
|
44
|
-
{
|
|
45
|
-
content: /* @__PURE__ */ jsx("ul", { children: restChannels.map((sc) => /* @__PURE__ */ jsx("li", { children: sc.name }, sc.id)) }),
|
|
46
|
-
children: /* @__PURE__ */ jsx(
|
|
47
|
-
Text,
|
|
48
|
-
{
|
|
49
|
-
size: "small",
|
|
50
|
-
leading: "compact",
|
|
51
|
-
className: "text-ui-fg-subtle",
|
|
52
|
-
children: `+${restChannels.length}`
|
|
53
|
-
}
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: "No sales channels" })
|
|
58
|
-
] }),
|
|
59
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", size: "small", leading: "compact", children: /* @__PURE__ */ jsx(
|
|
60
|
-
Trans,
|
|
61
|
-
{
|
|
62
|
-
i18nKey: "sales_channels.availableIn",
|
|
63
|
-
values: {
|
|
64
|
-
x: availableInSalesChannels.length,
|
|
65
|
-
y: count ?? 0
|
|
66
|
-
},
|
|
67
|
-
components: [
|
|
68
|
-
/* @__PURE__ */ jsx(
|
|
69
|
-
"span",
|
|
70
|
-
{
|
|
71
|
-
className: "text-ui-fg-base txt-compact-medium-plus"
|
|
72
|
-
},
|
|
73
|
-
"x"
|
|
74
|
-
),
|
|
75
|
-
/* @__PURE__ */ jsx(
|
|
76
|
-
"span",
|
|
77
|
-
{
|
|
78
|
-
className: "text-ui-fg-base txt-compact-medium-plus"
|
|
79
|
-
},
|
|
80
|
-
"y"
|
|
81
|
-
)
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
) }) })
|
|
85
|
-
] });
|
|
86
|
-
};
|
|
87
|
-
export {
|
|
88
|
-
ProductSalesChannelSection
|
|
89
|
-
};
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { PencilSquare, Trash } from "@medusajs/icons";
|
|
3
|
-
import { createDataTableColumnHelper, Container, usePrompt, Tooltip, Badge } from "@medusajs/ui";
|
|
4
|
-
import { keepPreviousData } from "@tanstack/react-query";
|
|
5
|
-
import { useMemo, useCallback } from "react";
|
|
6
|
-
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
7
|
-
import { DataTable } from "../../../../components/data-table.js";
|
|
8
|
-
import { useDataTableDateColumns } from "../../../../components/data-table/helpers/general/use-data-table-date-columns.js";
|
|
9
|
-
import { useProductVariants, useDeleteVariantLazy } from "../../../../hooks/api/products.js";
|
|
10
|
-
import { useDataTableDateFilters } from "../../../../hooks/common/use-data-table-date-filters.js";
|
|
11
|
-
import { useQueryParams } from "../../../../hooks/common/use-query-params.js";
|
|
12
|
-
const PAGE_SIZE = 10;
|
|
13
|
-
const PREFIX = "pv";
|
|
14
|
-
const ProductVariantSection = ({
|
|
15
|
-
product
|
|
16
|
-
}) => {
|
|
17
|
-
const {
|
|
18
|
-
q,
|
|
19
|
-
order,
|
|
20
|
-
offset,
|
|
21
|
-
allow_backorder,
|
|
22
|
-
manage_inventory,
|
|
23
|
-
created_at,
|
|
24
|
-
updated_at
|
|
25
|
-
} = useQueryParams(
|
|
26
|
-
[
|
|
27
|
-
"q",
|
|
28
|
-
"order",
|
|
29
|
-
"offset",
|
|
30
|
-
"manage_inventory",
|
|
31
|
-
"allow_backorder",
|
|
32
|
-
"created_at",
|
|
33
|
-
"updated_at"
|
|
34
|
-
],
|
|
35
|
-
PREFIX
|
|
36
|
-
);
|
|
37
|
-
const columns = useColumns(product);
|
|
38
|
-
const filters = useFilters();
|
|
39
|
-
const { variants, count, isPending, isError, error } = useProductVariants(
|
|
40
|
-
product.id,
|
|
41
|
-
{
|
|
42
|
-
q,
|
|
43
|
-
order: order ? order : "variant_rank",
|
|
44
|
-
offset: offset ? parseInt(offset) : void 0,
|
|
45
|
-
limit: PAGE_SIZE,
|
|
46
|
-
allow_backorder: allow_backorder ? JSON.parse(allow_backorder) : void 0,
|
|
47
|
-
manage_inventory: manage_inventory ? JSON.parse(manage_inventory) : void 0,
|
|
48
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
49
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
50
|
-
fields: "title,sku,*options,created_at,updated_at"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
placeholderData: keepPreviousData
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
if (isError) {
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
return /* @__PURE__ */ jsx(Container, { className: "divide-y p-0", children: /* @__PURE__ */ jsx(
|
|
60
|
-
DataTable,
|
|
61
|
-
{
|
|
62
|
-
data: variants,
|
|
63
|
-
columns,
|
|
64
|
-
filters,
|
|
65
|
-
rowCount: count,
|
|
66
|
-
getRowId: (row) => row.id,
|
|
67
|
-
pageSize: PAGE_SIZE,
|
|
68
|
-
isLoading: isPending,
|
|
69
|
-
heading: "Denominations",
|
|
70
|
-
emptyState: {
|
|
71
|
-
empty: {
|
|
72
|
-
heading: "No denominations",
|
|
73
|
-
description: "Add a denomination to get started"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
action: {
|
|
77
|
-
label: "Edit denomination",
|
|
78
|
-
to: `denominations`
|
|
79
|
-
},
|
|
80
|
-
actionMenu: {
|
|
81
|
-
groups: [
|
|
82
|
-
{
|
|
83
|
-
actions: [
|
|
84
|
-
{
|
|
85
|
-
label: "Edit prices",
|
|
86
|
-
to: `prices`,
|
|
87
|
-
icon: /* @__PURE__ */ jsx(PencilSquare, {})
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
},
|
|
93
|
-
prefix: PREFIX
|
|
94
|
-
}
|
|
95
|
-
) });
|
|
96
|
-
};
|
|
97
|
-
const columnHelper = createDataTableColumnHelper();
|
|
98
|
-
const useColumns = (product) => {
|
|
99
|
-
const navigate = useNavigate();
|
|
100
|
-
const { mutateAsync } = useDeleteVariantLazy(product.id);
|
|
101
|
-
const prompt = usePrompt();
|
|
102
|
-
const [searchParams] = useSearchParams();
|
|
103
|
-
const tableSearchParams = useMemo(() => {
|
|
104
|
-
const filtered = new URLSearchParams();
|
|
105
|
-
for (const [key, value] of searchParams.entries()) {
|
|
106
|
-
if (key.startsWith(`${PREFIX}_`)) {
|
|
107
|
-
filtered.append(key, value);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return filtered;
|
|
111
|
-
}, [searchParams]);
|
|
112
|
-
const dateColumns = useDataTableDateColumns();
|
|
113
|
-
const handleDelete = useCallback(
|
|
114
|
-
async (id, title) => {
|
|
115
|
-
const res = await prompt({
|
|
116
|
-
title: "Are you sure?",
|
|
117
|
-
description: `Are you sure you want to delete denomination ${title}?`,
|
|
118
|
-
confirmText: "Delete",
|
|
119
|
-
cancelText: "Cancel"
|
|
120
|
-
});
|
|
121
|
-
if (!res) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
await mutateAsync({ variantId: id });
|
|
125
|
-
},
|
|
126
|
-
[mutateAsync, prompt]
|
|
127
|
-
);
|
|
128
|
-
const optionColumns = useMemo(() => {
|
|
129
|
-
if (!(product == null ? void 0 : product.options)) {
|
|
130
|
-
return [];
|
|
131
|
-
}
|
|
132
|
-
return product.options.map((option) => {
|
|
133
|
-
return columnHelper.display({
|
|
134
|
-
id: option.id,
|
|
135
|
-
header: option.title,
|
|
136
|
-
cell: ({ row }) => {
|
|
137
|
-
var _a;
|
|
138
|
-
const variantOpt = (_a = row.original.options) == null ? void 0 : _a.find(
|
|
139
|
-
(opt) => opt.option_id === option.id
|
|
140
|
-
);
|
|
141
|
-
if (!variantOpt) {
|
|
142
|
-
return /* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted", children: "-" });
|
|
143
|
-
}
|
|
144
|
-
return /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(Tooltip, { content: variantOpt.value, children: /* @__PURE__ */ jsx(
|
|
145
|
-
Badge,
|
|
146
|
-
{
|
|
147
|
-
size: "2xsmall",
|
|
148
|
-
title: variantOpt.value,
|
|
149
|
-
className: "inline-flex min-w-[20px] max-w-[140px] items-center justify-center overflow-hidden truncate",
|
|
150
|
-
children: variantOpt.value
|
|
151
|
-
}
|
|
152
|
-
) }) });
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
}, [product]);
|
|
157
|
-
const getActions = useCallback(
|
|
158
|
-
(ctx) => {
|
|
159
|
-
const variant = ctx.row.original;
|
|
160
|
-
const mainActions = [
|
|
161
|
-
{
|
|
162
|
-
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
163
|
-
label: "Delete",
|
|
164
|
-
onClick: () => handleDelete(variant.id, variant.title)
|
|
165
|
-
}
|
|
166
|
-
];
|
|
167
|
-
return [mainActions];
|
|
168
|
-
},
|
|
169
|
-
[handleDelete, navigate, tableSearchParams]
|
|
170
|
-
);
|
|
171
|
-
return useMemo(() => {
|
|
172
|
-
return [
|
|
173
|
-
columnHelper.accessor("title", {
|
|
174
|
-
header: "Title",
|
|
175
|
-
enableSorting: true,
|
|
176
|
-
sortAscLabel: "Asc",
|
|
177
|
-
sortDescLabel: "Desc"
|
|
178
|
-
}),
|
|
179
|
-
columnHelper.accessor("sku", {
|
|
180
|
-
header: "SKU",
|
|
181
|
-
enableSorting: true,
|
|
182
|
-
sortAscLabel: "Asc",
|
|
183
|
-
sortDescLabel: "Desc"
|
|
184
|
-
}),
|
|
185
|
-
columnHelper.action({
|
|
186
|
-
actions: getActions
|
|
187
|
-
})
|
|
188
|
-
];
|
|
189
|
-
}, [optionColumns, dateColumns, getActions]);
|
|
190
|
-
};
|
|
191
|
-
const useFilters = () => {
|
|
192
|
-
const dateFilters = useDataTableDateFilters();
|
|
193
|
-
return useMemo(() => {
|
|
194
|
-
return [...dateFilters];
|
|
195
|
-
}, [dateFilters]);
|
|
196
|
-
};
|
|
197
|
-
export {
|
|
198
|
-
ProductVariantSection
|
|
199
|
-
};
|