@medusajs/loyalty-plugin 2.23.0 → 2.23.1-snapshot-20261124145306

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.
@@ -35870,256 +35870,6 @@ var GiftCardProductEdit = () => {
35870
35870
  })] }), !isLoading && product && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GiftCardProductEditForm, { product })] });
35871
35871
  };
35872
35872
  var handle$3 = { permissions: ["product:read", "product:update"] };
35873
- // src/admin/routes/gift-cards/gift-card-products/[id]/prices/components/variant-pricing-form.tsx
35874
- var VariantPricingForm = ({ form }) => {
35875
- const { hasPermission } = (0, _medusajs_dashboard_hooks.usePermissions)();
35876
- const { store } = useStore$2();
35877
- const { regions } = useRegions({ limit: 9999 }, { enabled: hasPermission("region:read") });
35878
- const { price_preferences: pricePreferences } = usePricePreferences({}, { enabled: hasPermission("price_preference:read") });
35879
- const { setCloseOnEscape } = useRouteModal();
35880
- const columns = useVariantPriceGridColumns({
35881
- currencies: store?.supported_currencies,
35882
- regions,
35883
- pricePreferences
35884
- });
35885
- const variants = useWatch({
35886
- control: form.control,
35887
- name: "variants"
35888
- });
35889
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataGrid, {
35890
- columns,
35891
- data: variants,
35892
- state: form,
35893
- onEditingChange: (editing) => setCloseOnEscape(!editing)
35894
- });
35895
- };
35896
- var columnHelper$1 = createDataGridHelper();
35897
- var useVariantPriceGridColumns = ({ currencies = [], regions = [], pricePreferences = [] }) => {
35898
- return (0, react.useMemo)(() => {
35899
- return [columnHelper$1.column({
35900
- id: "Title",
35901
- header: "Title",
35902
- cell: (context) => {
35903
- const entity = context.row.original;
35904
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataGrid.ReadonlyCell, {
35905
- context,
35906
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
35907
- className: "flex h-full w-full items-center gap-x-2 overflow-hidden",
35908
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
35909
- className: "truncate",
35910
- children: entity.title
35911
- })
35912
- })
35913
- });
35914
- },
35915
- disableHiding: true
35916
- }), ...createDataGridPriceColumns({
35917
- currencies: currencies.map((c) => c.currency_code),
35918
- regions,
35919
- pricePreferences,
35920
- getFieldName: (context, value) => {
35921
- return `variants.${context.row.index}.prices.${value}`;
35922
- }
35923
- })];
35924
- }, [
35925
- currencies,
35926
- regions,
35927
- pricePreferences
35928
- ]);
35929
- };
35930
- // src/admin/routes/gift-cards/gift-card-products/[id]/prices/components/prices-edit.tsx
35931
- var UpdateDenominationPricesSchema = _medusajs_framework_zod.object({ variants: _medusajs_framework_zod.array(_medusajs_framework_zod.object({ prices: _medusajs_framework_zod.record(_medusajs_framework_zod.string(), _medusajs_framework_zod.string().or(_medusajs_framework_zod.number()).optional()).optional() })) });
35932
- var PricingEdit = ({ product, variantId }) => {
35933
- const { handleSuccess } = useRouteModal();
35934
- const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
35935
- const { hasPermission } = (0, _medusajs_dashboard_hooks.usePermissions)();
35936
- const { regions } = useRegions({ limit: 9999 }, { enabled: hasPermission("region:read") });
35937
- const regionsCurrencyMap = (0, react.useMemo)(() => {
35938
- if (!regions?.length) return {};
35939
- return regions.reduce((acc, reg) => {
35940
- acc[reg.id] = reg.currency_code;
35941
- return acc;
35942
- }, {});
35943
- }, [regions]);
35944
- const variants = variantId ? product.variants?.filter((v) => v.id === variantId) : product.variants;
35945
- const form = useForm({
35946
- defaultValues: { variants: variants?.map((variant) => ({
35947
- title: variant.title,
35948
- prices: variant.prices.reduce((acc, price) => {
35949
- if (price.rules?.region_id) acc[price.rules.region_id] = price.amount;
35950
- else acc[price.currency_code] = price.amount;
35951
- return acc;
35952
- }, {})
35953
- })) },
35954
- resolver: u(UpdateDenominationPricesSchema, {})
35955
- });
35956
- const handleSubmit = form.handleSubmit(async (values) => {
35957
- const reqData = values.variants.map((variant, ind) => ({
35958
- id: variants?.[ind]?.id,
35959
- prices: Object.entries(variant.prices || {}).filter(([_, value]) => value !== "" && typeof value !== "undefined").map(([currencyCodeOrRegionId, value]) => {
35960
- const regionId = currencyCodeOrRegionId.startsWith("reg_") ? currencyCodeOrRegionId : void 0;
35961
- const currencyCode = currencyCodeOrRegionId.startsWith("reg_") ? regionsCurrencyMap[regionId] : currencyCodeOrRegionId;
35962
- let existingId = void 0;
35963
- if (regionId) existingId = variants?.[ind]?.prices?.find((p) => p.rules["region_id"] === regionId)?.id;
35964
- else existingId = variants?.[ind]?.prices?.find((p) => p.currency_code === currencyCode && Object.keys(p.rules ?? {}).length === 0)?.id;
35965
- const amount = castNumber(value);
35966
- return {
35967
- id: existingId,
35968
- currency_code: currencyCode,
35969
- amount,
35970
- ...regionId ? { rules: { region_id: regionId } } : {}
35971
- };
35972
- })
35973
- }));
35974
- await mutateAsync(reqData, { onSuccess: () => {
35975
- handleSuccess("..");
35976
- } });
35977
- });
35978
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Form, {
35979
- form,
35980
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
35981
- onSubmit: handleSubmit,
35982
- className: "flex size-full flex-col",
35983
- children: [
35984
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Header, {}),
35985
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Body, {
35986
- className: "flex flex-col overflow-hidden",
35987
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VariantPricingForm, { form })
35988
- }),
35989
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
35990
- className: "flex w-full items-center justify-end gap-x-2",
35991
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Close, {
35992
- asChild: true,
35993
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
35994
- variant: "secondary",
35995
- size: "small",
35996
- children: "Cancel"
35997
- })
35998
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
35999
- type: "submit",
36000
- variant: "primary",
36001
- size: "small",
36002
- isLoading: isPending,
36003
- children: "Save"
36004
- })]
36005
- }) })
36006
- ]
36007
- })
36008
- });
36009
- };
36010
- // src/admin/routes/gift-cards/gift-card-products/[id]/prices/page.tsx
36011
- var ProductPrices = () => {
36012
- const { id, variant_id } = (0, react_router_dom.useParams)();
36013
- const { product, isLoading, isError, error } = useProduct(id);
36014
- if (isError) throw error;
36015
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingEdit, {
36016
- product,
36017
- variantId: variant_id
36018
- }) });
36019
- };
36020
- var handle$2 = { permissions: EDIT_GIFT_CARD_PRICES_PERMISSIONS };
36021
- // src/admin/routes/gift-cards/gift-card-products/[id]/sales-channels/components/edit-sales-channel-form.tsx
36022
- var EditSalesChannelsSchema = _medusajs_framework_zod.object({ sales_channels: _medusajs_framework_zod.array(_medusajs_framework_zod.string()).optional() });
36023
- var PAGE_SIZE = 50;
36024
- var PREFIX = "sc";
36025
- var EditSalesChannelsForm = ({ product }) => {
36026
- const { handleSuccess } = useRouteModal();
36027
- const form = useForm({
36028
- defaultValues: { sales_channels: product.sales_channels?.map((sc) => sc.id) ?? [] },
36029
- resolver: u(EditSalesChannelsSchema)
36030
- });
36031
- const { setValue } = form;
36032
- const initialState = product.sales_channels?.reduce((acc, curr) => {
36033
- acc[curr.id] = true;
36034
- return acc;
36035
- }, {}) ?? {};
36036
- const [rowSelection, setRowSelection] = (0, react.useState)(initialState);
36037
- (0, react.useEffect)(() => {
36038
- const ids = Object.keys(rowSelection);
36039
- setValue("sales_channels", ids, {
36040
- shouldDirty: true,
36041
- shouldTouch: true
36042
- });
36043
- }, [rowSelection, setValue]);
36044
- const { sales_channels, count, isLoading, isError, error } = useSalesChannels({ ...useSalesChannelTableQuery({
36045
- pageSize: PAGE_SIZE,
36046
- prefix: PREFIX
36047
- }) }, { placeholderData: _tanstack_react_query.keepPreviousData });
36048
- const filters = useSalesChannelTableFilters();
36049
- const emptyState = useSalesChannelTableEmptyState();
36050
- const columns = useColumns();
36051
- const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
36052
- const handleSubmit = form.handleSubmit(async (data) => {
36053
- const sales_channels = (data.sales_channels ?? []).map((id) => {
36054
- return { id };
36055
- });
36056
- await mutateAsync({ sales_channels }, { onSuccess: () => {
36057
- handleSuccess();
36058
- } });
36059
- });
36060
- if (isError) throw error;
36061
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Form, {
36062
- form,
36063
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36064
- className: "flex h-full flex-col overflow-hidden",
36065
- children: [
36066
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Header, {}),
36067
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Body, {
36068
- className: "flex-1 overflow-hidden",
36069
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTable, {
36070
- data: sales_channels,
36071
- columns,
36072
- getRowId: (row) => row.id,
36073
- rowCount: count,
36074
- isLoading,
36075
- filters,
36076
- rowSelection: {
36077
- state: rowSelection,
36078
- onRowSelectionChange: setRowSelection
36079
- },
36080
- autoFocusSearch: true,
36081
- layout: "fill",
36082
- emptyState,
36083
- prefix: PREFIX
36084
- })
36085
- }),
36086
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36087
- className: "flex items-center justify-end gap-x-2",
36088
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Close, {
36089
- asChild: true,
36090
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
36091
- size: "small",
36092
- variant: "secondary",
36093
- children: "Cancel"
36094
- })
36095
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
36096
- size: "small",
36097
- isLoading: isMutating,
36098
- onClick: handleSubmit,
36099
- children: "Save"
36100
- })]
36101
- }) })
36102
- ]
36103
- })
36104
- });
36105
- };
36106
- var columnHelper = (0, _medusajs_ui.createDataTableColumnHelper)();
36107
- var useColumns = () => {
36108
- const columns = useSalesChannelTableColumns();
36109
- return (0, react.useMemo)(() => [columnHelper.select(), ...columns], [columns]);
36110
- };
36111
- // src/admin/routes/gift-cards/gift-card-products/[id]/sales-channels/page.tsx
36112
- var ProductSalesChannels = () => {
36113
- const { id } = (0, react_router_dom.useParams)();
36114
- const { product, isLoading, isError, error } = useProduct(id);
36115
- if (isError) throw error;
36116
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditSalesChannelsForm, { product }) });
36117
- };
36118
- var handle$1 = { permissions: [
36119
- "product:read",
36120
- "sales_channel:read",
36121
- "product:update"
36122
- ] };
36123
35873
  // src/admin/routes/gift-cards/gift-card-products/[id]/media/components/edit-product-media-form/edit-product-media-form.tsx
36124
35874
  var EditProductMediaForm = ({ product }) => {
36125
35875
  const [selection, setSelection] = (0, react.useState)({});
@@ -36691,7 +36441,257 @@ var ProductMedia = () => {
36691
36441
  ready && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ProductMediaView, { product })
36692
36442
  ] });
36693
36443
  };
36694
- var handle = { permissions: ["product:read"] };
36444
+ var handle$2 = { permissions: ["product:read"] };
36445
+ // src/admin/routes/gift-cards/gift-card-products/[id]/prices/components/variant-pricing-form.tsx
36446
+ var VariantPricingForm = ({ form }) => {
36447
+ const { hasPermission } = (0, _medusajs_dashboard_hooks.usePermissions)();
36448
+ const { store } = useStore$2();
36449
+ const { regions } = useRegions({ limit: 9999 }, { enabled: hasPermission("region:read") });
36450
+ const { price_preferences: pricePreferences } = usePricePreferences({}, { enabled: hasPermission("price_preference:read") });
36451
+ const { setCloseOnEscape } = useRouteModal();
36452
+ const columns = useVariantPriceGridColumns({
36453
+ currencies: store?.supported_currencies,
36454
+ regions,
36455
+ pricePreferences
36456
+ });
36457
+ const variants = useWatch({
36458
+ control: form.control,
36459
+ name: "variants"
36460
+ });
36461
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataGrid, {
36462
+ columns,
36463
+ data: variants,
36464
+ state: form,
36465
+ onEditingChange: (editing) => setCloseOnEscape(!editing)
36466
+ });
36467
+ };
36468
+ var columnHelper$1 = createDataGridHelper();
36469
+ var useVariantPriceGridColumns = ({ currencies = [], regions = [], pricePreferences = [] }) => {
36470
+ return (0, react.useMemo)(() => {
36471
+ return [columnHelper$1.column({
36472
+ id: "Title",
36473
+ header: "Title",
36474
+ cell: (context) => {
36475
+ const entity = context.row.original;
36476
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataGrid.ReadonlyCell, {
36477
+ context,
36478
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
36479
+ className: "flex h-full w-full items-center gap-x-2 overflow-hidden",
36480
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
36481
+ className: "truncate",
36482
+ children: entity.title
36483
+ })
36484
+ })
36485
+ });
36486
+ },
36487
+ disableHiding: true
36488
+ }), ...createDataGridPriceColumns({
36489
+ currencies: currencies.map((c) => c.currency_code),
36490
+ regions,
36491
+ pricePreferences,
36492
+ getFieldName: (context, value) => {
36493
+ return `variants.${context.row.index}.prices.${value}`;
36494
+ }
36495
+ })];
36496
+ }, [
36497
+ currencies,
36498
+ regions,
36499
+ pricePreferences
36500
+ ]);
36501
+ };
36502
+ // src/admin/routes/gift-cards/gift-card-products/[id]/prices/components/prices-edit.tsx
36503
+ var UpdateDenominationPricesSchema = _medusajs_framework_zod.object({ variants: _medusajs_framework_zod.array(_medusajs_framework_zod.object({ prices: _medusajs_framework_zod.record(_medusajs_framework_zod.string(), _medusajs_framework_zod.string().or(_medusajs_framework_zod.number()).optional()).optional() })) });
36504
+ var PricingEdit = ({ product, variantId }) => {
36505
+ const { handleSuccess } = useRouteModal();
36506
+ const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
36507
+ const { hasPermission } = (0, _medusajs_dashboard_hooks.usePermissions)();
36508
+ const { regions } = useRegions({ limit: 9999 }, { enabled: hasPermission("region:read") });
36509
+ const regionsCurrencyMap = (0, react.useMemo)(() => {
36510
+ if (!regions?.length) return {};
36511
+ return regions.reduce((acc, reg) => {
36512
+ acc[reg.id] = reg.currency_code;
36513
+ return acc;
36514
+ }, {});
36515
+ }, [regions]);
36516
+ const variants = variantId ? product.variants?.filter((v) => v.id === variantId) : product.variants;
36517
+ const form = useForm({
36518
+ defaultValues: { variants: variants?.map((variant) => ({
36519
+ title: variant.title,
36520
+ prices: variant.prices.reduce((acc, price) => {
36521
+ if (price.rules?.region_id) acc[price.rules.region_id] = price.amount;
36522
+ else acc[price.currency_code] = price.amount;
36523
+ return acc;
36524
+ }, {})
36525
+ })) },
36526
+ resolver: u(UpdateDenominationPricesSchema, {})
36527
+ });
36528
+ const handleSubmit = form.handleSubmit(async (values) => {
36529
+ const reqData = values.variants.map((variant, ind) => ({
36530
+ id: variants?.[ind]?.id,
36531
+ prices: Object.entries(variant.prices || {}).filter(([_, value]) => value !== "" && typeof value !== "undefined").map(([currencyCodeOrRegionId, value]) => {
36532
+ const regionId = currencyCodeOrRegionId.startsWith("reg_") ? currencyCodeOrRegionId : void 0;
36533
+ const currencyCode = currencyCodeOrRegionId.startsWith("reg_") ? regionsCurrencyMap[regionId] : currencyCodeOrRegionId;
36534
+ let existingId = void 0;
36535
+ if (regionId) existingId = variants?.[ind]?.prices?.find((p) => p.rules["region_id"] === regionId)?.id;
36536
+ else existingId = variants?.[ind]?.prices?.find((p) => p.currency_code === currencyCode && Object.keys(p.rules ?? {}).length === 0)?.id;
36537
+ const amount = castNumber(value);
36538
+ return {
36539
+ id: existingId,
36540
+ currency_code: currencyCode,
36541
+ amount,
36542
+ ...regionId ? { rules: { region_id: regionId } } : {}
36543
+ };
36544
+ })
36545
+ }));
36546
+ await mutateAsync(reqData, { onSuccess: () => {
36547
+ handleSuccess("..");
36548
+ } });
36549
+ });
36550
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Form, {
36551
+ form,
36552
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(KeyboundForm, {
36553
+ onSubmit: handleSubmit,
36554
+ className: "flex size-full flex-col",
36555
+ children: [
36556
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Header, {}),
36557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Body, {
36558
+ className: "flex flex-col overflow-hidden",
36559
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(VariantPricingForm, { form })
36560
+ }),
36561
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36562
+ className: "flex w-full items-center justify-end gap-x-2",
36563
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Close, {
36564
+ asChild: true,
36565
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
36566
+ variant: "secondary",
36567
+ size: "small",
36568
+ children: "Cancel"
36569
+ })
36570
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
36571
+ type: "submit",
36572
+ variant: "primary",
36573
+ size: "small",
36574
+ isLoading: isPending,
36575
+ children: "Save"
36576
+ })]
36577
+ }) })
36578
+ ]
36579
+ })
36580
+ });
36581
+ };
36582
+ // src/admin/routes/gift-cards/gift-card-products/[id]/prices/page.tsx
36583
+ var ProductPrices = () => {
36584
+ const { id, variant_id } = (0, react_router_dom.useParams)();
36585
+ const { product, isLoading, isError, error } = useProduct(id);
36586
+ if (isError) throw error;
36587
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PricingEdit, {
36588
+ product,
36589
+ variantId: variant_id
36590
+ }) });
36591
+ };
36592
+ var handle$1 = { permissions: EDIT_GIFT_CARD_PRICES_PERMISSIONS };
36593
+ // src/admin/routes/gift-cards/gift-card-products/[id]/sales-channels/components/edit-sales-channel-form.tsx
36594
+ var EditSalesChannelsSchema = _medusajs_framework_zod.object({ sales_channels: _medusajs_framework_zod.array(_medusajs_framework_zod.string()).optional() });
36595
+ var PAGE_SIZE = 50;
36596
+ var PREFIX = "sc";
36597
+ var EditSalesChannelsForm = ({ product }) => {
36598
+ const { handleSuccess } = useRouteModal();
36599
+ const form = useForm({
36600
+ defaultValues: { sales_channels: product.sales_channels?.map((sc) => sc.id) ?? [] },
36601
+ resolver: u(EditSalesChannelsSchema)
36602
+ });
36603
+ const { setValue } = form;
36604
+ const initialState = product.sales_channels?.reduce((acc, curr) => {
36605
+ acc[curr.id] = true;
36606
+ return acc;
36607
+ }, {}) ?? {};
36608
+ const [rowSelection, setRowSelection] = (0, react.useState)(initialState);
36609
+ (0, react.useEffect)(() => {
36610
+ const ids = Object.keys(rowSelection);
36611
+ setValue("sales_channels", ids, {
36612
+ shouldDirty: true,
36613
+ shouldTouch: true
36614
+ });
36615
+ }, [rowSelection, setValue]);
36616
+ const { sales_channels, count, isLoading, isError, error } = useSalesChannels({ ...useSalesChannelTableQuery({
36617
+ pageSize: PAGE_SIZE,
36618
+ prefix: PREFIX
36619
+ }) }, { placeholderData: _tanstack_react_query.keepPreviousData });
36620
+ const filters = useSalesChannelTableFilters();
36621
+ const emptyState = useSalesChannelTableEmptyState();
36622
+ const columns = useColumns();
36623
+ const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
36624
+ const handleSubmit = form.handleSubmit(async (data) => {
36625
+ const sales_channels = (data.sales_channels ?? []).map((id) => {
36626
+ return { id };
36627
+ });
36628
+ await mutateAsync({ sales_channels }, { onSuccess: () => {
36629
+ handleSuccess();
36630
+ } });
36631
+ });
36632
+ if (isError) throw error;
36633
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Form, {
36634
+ form,
36635
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36636
+ className: "flex h-full flex-col overflow-hidden",
36637
+ children: [
36638
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Header, {}),
36639
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Body, {
36640
+ className: "flex-1 overflow-hidden",
36641
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DataTable, {
36642
+ data: sales_channels,
36643
+ columns,
36644
+ getRowId: (row) => row.id,
36645
+ rowCount: count,
36646
+ isLoading,
36647
+ filters,
36648
+ rowSelection: {
36649
+ state: rowSelection,
36650
+ onRowSelectionChange: setRowSelection
36651
+ },
36652
+ autoFocusSearch: true,
36653
+ layout: "fill",
36654
+ emptyState,
36655
+ prefix: PREFIX
36656
+ })
36657
+ }),
36658
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Footer, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
36659
+ className: "flex items-center justify-end gap-x-2",
36660
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal.Close, {
36661
+ asChild: true,
36662
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
36663
+ size: "small",
36664
+ variant: "secondary",
36665
+ children: "Cancel"
36666
+ })
36667
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_medusajs_ui.Button, {
36668
+ size: "small",
36669
+ isLoading: isMutating,
36670
+ onClick: handleSubmit,
36671
+ children: "Save"
36672
+ })]
36673
+ }) })
36674
+ ]
36675
+ })
36676
+ });
36677
+ };
36678
+ var columnHelper = (0, _medusajs_ui.createDataTableColumnHelper)();
36679
+ var useColumns = () => {
36680
+ const columns = useSalesChannelTableColumns();
36681
+ return (0, react.useMemo)(() => [columnHelper.select(), ...columns], [columns]);
36682
+ };
36683
+ // src/admin/routes/gift-cards/gift-card-products/[id]/sales-channels/page.tsx
36684
+ var ProductSalesChannels = () => {
36685
+ const { id } = (0, react_router_dom.useParams)();
36686
+ const { product, isLoading, isError, error } = useProduct(id);
36687
+ if (isError) throw error;
36688
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditSalesChannelsForm, { product }) });
36689
+ };
36690
+ var handle = { permissions: [
36691
+ "product:read",
36692
+ "sales_channel:read",
36693
+ "product:update"
36694
+ ] };
36695
36695
  // ../../admin/admin-shared/dist/index.mjs
36696
36696
  var PRODUCT_CUSTOM_FIELD_MODEL = "product";
36697
36697
  var PRODUCT_CUSTOM_FIELD_FORM_ZONES = [
@@ -37220,18 +37220,18 @@ var plugin = {
37220
37220
  }]
37221
37221
  },
37222
37222
  {
37223
- Component: ProductPrices,
37224
- path: "/gift-cards/gift-card-products/:id/prices",
37223
+ Component: ProductMedia,
37224
+ path: "/gift-cards/gift-card-products/:id/media",
37225
37225
  handle: handle$2
37226
37226
  },
37227
37227
  {
37228
- Component: ProductSalesChannels,
37229
- path: "/gift-cards/gift-card-products/:id/sales-channels",
37228
+ Component: ProductPrices,
37229
+ path: "/gift-cards/gift-card-products/:id/prices",
37230
37230
  handle: handle$1
37231
37231
  },
37232
37232
  {
37233
- Component: ProductMedia,
37234
- path: "/gift-cards/gift-card-products/:id/media",
37233
+ Component: ProductSalesChannels,
37234
+ path: "/gift-cards/gift-card-products/:id/sales-channels",
37235
37235
  handle
37236
37236
  }
37237
37237
  ] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/loyalty-plugin",
3
- "version": "2.23.0",
3
+ "version": "2.23.1-snapshot-20261124145306",
4
4
  "description": "Medusa Plugin: Loyalty - Gift Cards",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -59,16 +59,16 @@
59
59
  "watch": "medusa plugin:develop"
60
60
  },
61
61
  "devDependencies": {
62
- "@medusajs/admin-sdk": "2.23.0",
63
- "@medusajs/cli": "2.23.0",
64
- "@medusajs/dashboard": "2.23.0",
65
- "@medusajs/framework": "2.23.0",
66
- "@medusajs/icons": "2.23.0",
67
- "@medusajs/medusa": "2.23.0",
68
- "@medusajs/test-utils": "2.23.0",
69
- "@medusajs/types": "2.23.0",
70
- "@medusajs/ui": "4.3.0",
71
- "@medusajs/ui-preset": "2.23.0",
62
+ "@medusajs/admin-sdk": "2.23.1-snapshot-20261124145306",
63
+ "@medusajs/cli": "2.23.1-snapshot-20261124145306",
64
+ "@medusajs/dashboard": "2.23.1-snapshot-20261124145306",
65
+ "@medusajs/framework": "2.23.1-snapshot-20261124145306",
66
+ "@medusajs/icons": "2.23.1-snapshot-20261124145306",
67
+ "@medusajs/medusa": "2.23.1-snapshot-20261124145306",
68
+ "@medusajs/test-utils": "2.23.1-snapshot-20261124145306",
69
+ "@medusajs/types": "2.23.1-snapshot-20261124145306",
70
+ "@medusajs/ui": "4.3.1-snapshot-20261124145306",
71
+ "@medusajs/ui-preset": "2.23.1-snapshot-20261124145306",
72
72
  "@swc/core": "^1.16.20",
73
73
  "@tanstack/react-table": "9.3.1",
74
74
  "@types/node": "^22.20.5",
@@ -77,14 +77,14 @@
77
77
  "typescript": "npm:@typescript/typescript6@^6.0.2"
78
78
  },
79
79
  "peerDependencies": {
80
- "@medusajs/admin-sdk": "2.23.0",
81
- "@medusajs/cli": "2.23.0",
82
- "@medusajs/dashboard": "2.23.0",
83
- "@medusajs/framework": "2.23.0",
84
- "@medusajs/icons": "2.23.0",
85
- "@medusajs/medusa": "2.23.0",
86
- "@medusajs/test-utils": "2.23.0",
87
- "@medusajs/ui": "4.3.0",
80
+ "@medusajs/admin-sdk": "2.23.1-snapshot-20261124145306",
81
+ "@medusajs/cli": "2.23.1-snapshot-20261124145306",
82
+ "@medusajs/dashboard": "2.23.1-snapshot-20261124145306",
83
+ "@medusajs/framework": "2.23.1-snapshot-20261124145306",
84
+ "@medusajs/icons": "2.23.1-snapshot-20261124145306",
85
+ "@medusajs/medusa": "2.23.1-snapshot-20261124145306",
86
+ "@medusajs/test-utils": "2.23.1-snapshot-20261124145306",
87
+ "@medusajs/ui": "4.3.1-snapshot-20261124145306",
88
88
  "@tanstack/react-table": "^9.3.1",
89
89
  "react": "^19.3.1",
90
90
  "react-dom": "^19.3.1",