@medusajs/loyalty-plugin 2.15.5 → 2.15.6-preview-20260601104039
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 +112 -112
- package/.medusa/server/src/admin/index.mjs +112 -112
- package/package.json +15 -15
|
@@ -41172,6 +41172,112 @@ const ProductMedia = () => {
|
|
|
41172
41172
|
ready && /* @__PURE__ */ jsxRuntime.jsx(ProductMediaView, { product })
|
|
41173
41173
|
] });
|
|
41174
41174
|
};
|
|
41175
|
+
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41176
|
+
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41177
|
+
});
|
|
41178
|
+
const PAGE_SIZE = 50;
|
|
41179
|
+
const PREFIX = "sc";
|
|
41180
|
+
const EditSalesChannelsForm = ({
|
|
41181
|
+
product
|
|
41182
|
+
}) => {
|
|
41183
|
+
var _a2, _b;
|
|
41184
|
+
const { handleSuccess } = useRouteModal();
|
|
41185
|
+
const form = useForm({
|
|
41186
|
+
defaultValues: {
|
|
41187
|
+
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41188
|
+
},
|
|
41189
|
+
resolver: t(EditSalesChannelsSchema)
|
|
41190
|
+
});
|
|
41191
|
+
const { setValue: setValue2 } = form;
|
|
41192
|
+
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41193
|
+
acc[curr.id] = true;
|
|
41194
|
+
return acc;
|
|
41195
|
+
}, {})) ?? {};
|
|
41196
|
+
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41197
|
+
React.useEffect(() => {
|
|
41198
|
+
const ids2 = Object.keys(rowSelection);
|
|
41199
|
+
setValue2("sales_channels", ids2, {
|
|
41200
|
+
shouldDirty: true,
|
|
41201
|
+
shouldTouch: true
|
|
41202
|
+
});
|
|
41203
|
+
}, [rowSelection, setValue2]);
|
|
41204
|
+
const searchParams = useSalesChannelTableQuery({
|
|
41205
|
+
pageSize: PAGE_SIZE,
|
|
41206
|
+
prefix: PREFIX
|
|
41207
|
+
});
|
|
41208
|
+
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41209
|
+
{
|
|
41210
|
+
...searchParams
|
|
41211
|
+
},
|
|
41212
|
+
{
|
|
41213
|
+
placeholderData: reactQuery.keepPreviousData
|
|
41214
|
+
}
|
|
41215
|
+
);
|
|
41216
|
+
const filters = useSalesChannelTableFilters();
|
|
41217
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
41218
|
+
const columns = useColumns();
|
|
41219
|
+
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41220
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41221
|
+
const arr = data.sales_channels ?? [];
|
|
41222
|
+
const sales_channels2 = arr.map((id) => {
|
|
41223
|
+
return {
|
|
41224
|
+
id
|
|
41225
|
+
};
|
|
41226
|
+
});
|
|
41227
|
+
await mutateAsync(
|
|
41228
|
+
{
|
|
41229
|
+
sales_channels: sales_channels2
|
|
41230
|
+
},
|
|
41231
|
+
{
|
|
41232
|
+
onSuccess: () => {
|
|
41233
|
+
handleSuccess();
|
|
41234
|
+
}
|
|
41235
|
+
}
|
|
41236
|
+
);
|
|
41237
|
+
});
|
|
41238
|
+
if (isError) {
|
|
41239
|
+
throw error;
|
|
41240
|
+
}
|
|
41241
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41242
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41243
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41244
|
+
DataTable,
|
|
41245
|
+
{
|
|
41246
|
+
data: sales_channels,
|
|
41247
|
+
columns,
|
|
41248
|
+
getRowId: (row) => row.id,
|
|
41249
|
+
rowCount: count2,
|
|
41250
|
+
isLoading,
|
|
41251
|
+
filters,
|
|
41252
|
+
rowSelection: {
|
|
41253
|
+
state: rowSelection,
|
|
41254
|
+
onRowSelectionChange: setRowSelection
|
|
41255
|
+
},
|
|
41256
|
+
autoFocusSearch: true,
|
|
41257
|
+
layout: "fill",
|
|
41258
|
+
emptyState,
|
|
41259
|
+
prefix: PREFIX
|
|
41260
|
+
}
|
|
41261
|
+
) }),
|
|
41262
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41263
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41264
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41265
|
+
] }) })
|
|
41266
|
+
] }) });
|
|
41267
|
+
};
|
|
41268
|
+
const columnHelper$1 = ui.createDataTableColumnHelper();
|
|
41269
|
+
const useColumns = () => {
|
|
41270
|
+
const columns = useSalesChannelTableColumns();
|
|
41271
|
+
return React.useMemo(() => [columnHelper$1.select(), ...columns], [columns]);
|
|
41272
|
+
};
|
|
41273
|
+
const ProductSalesChannels = () => {
|
|
41274
|
+
const { id } = reactRouterDom.useParams();
|
|
41275
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
41276
|
+
if (isError) {
|
|
41277
|
+
throw error;
|
|
41278
|
+
}
|
|
41279
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41280
|
+
};
|
|
41175
41281
|
const VariantPricingForm = ({ form }) => {
|
|
41176
41282
|
const { store } = useStore$2();
|
|
41177
41283
|
const { regions } = useRegions({ limit: 9999 });
|
|
@@ -41196,7 +41302,7 @@ const VariantPricingForm = ({ form }) => {
|
|
|
41196
41302
|
}
|
|
41197
41303
|
);
|
|
41198
41304
|
};
|
|
41199
|
-
const columnHelper
|
|
41305
|
+
const columnHelper = createDataGridHelper();
|
|
41200
41306
|
const useVariantPriceGridColumns = ({
|
|
41201
41307
|
currencies: currencies2 = [],
|
|
41202
41308
|
regions = [],
|
|
@@ -41204,7 +41310,7 @@ const useVariantPriceGridColumns = ({
|
|
|
41204
41310
|
}) => {
|
|
41205
41311
|
return React.useMemo(() => {
|
|
41206
41312
|
return [
|
|
41207
|
-
columnHelper
|
|
41313
|
+
columnHelper.column({
|
|
41208
41314
|
id: "Title",
|
|
41209
41315
|
header: "Title",
|
|
41210
41316
|
cell: (context) => {
|
|
@@ -41330,112 +41436,6 @@ const ProductPrices = () => {
|
|
|
41330
41436
|
}
|
|
41331
41437
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41332
41438
|
};
|
|
41333
|
-
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41334
|
-
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41335
|
-
});
|
|
41336
|
-
const PAGE_SIZE = 50;
|
|
41337
|
-
const PREFIX = "sc";
|
|
41338
|
-
const EditSalesChannelsForm = ({
|
|
41339
|
-
product
|
|
41340
|
-
}) => {
|
|
41341
|
-
var _a2, _b;
|
|
41342
|
-
const { handleSuccess } = useRouteModal();
|
|
41343
|
-
const form = useForm({
|
|
41344
|
-
defaultValues: {
|
|
41345
|
-
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41346
|
-
},
|
|
41347
|
-
resolver: t(EditSalesChannelsSchema)
|
|
41348
|
-
});
|
|
41349
|
-
const { setValue: setValue2 } = form;
|
|
41350
|
-
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41351
|
-
acc[curr.id] = true;
|
|
41352
|
-
return acc;
|
|
41353
|
-
}, {})) ?? {};
|
|
41354
|
-
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41355
|
-
React.useEffect(() => {
|
|
41356
|
-
const ids2 = Object.keys(rowSelection);
|
|
41357
|
-
setValue2("sales_channels", ids2, {
|
|
41358
|
-
shouldDirty: true,
|
|
41359
|
-
shouldTouch: true
|
|
41360
|
-
});
|
|
41361
|
-
}, [rowSelection, setValue2]);
|
|
41362
|
-
const searchParams = useSalesChannelTableQuery({
|
|
41363
|
-
pageSize: PAGE_SIZE,
|
|
41364
|
-
prefix: PREFIX
|
|
41365
|
-
});
|
|
41366
|
-
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41367
|
-
{
|
|
41368
|
-
...searchParams
|
|
41369
|
-
},
|
|
41370
|
-
{
|
|
41371
|
-
placeholderData: reactQuery.keepPreviousData
|
|
41372
|
-
}
|
|
41373
|
-
);
|
|
41374
|
-
const filters = useSalesChannelTableFilters();
|
|
41375
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
41376
|
-
const columns = useColumns();
|
|
41377
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41378
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41379
|
-
const arr = data.sales_channels ?? [];
|
|
41380
|
-
const sales_channels2 = arr.map((id) => {
|
|
41381
|
-
return {
|
|
41382
|
-
id
|
|
41383
|
-
};
|
|
41384
|
-
});
|
|
41385
|
-
await mutateAsync(
|
|
41386
|
-
{
|
|
41387
|
-
sales_channels: sales_channels2
|
|
41388
|
-
},
|
|
41389
|
-
{
|
|
41390
|
-
onSuccess: () => {
|
|
41391
|
-
handleSuccess();
|
|
41392
|
-
}
|
|
41393
|
-
}
|
|
41394
|
-
);
|
|
41395
|
-
});
|
|
41396
|
-
if (isError) {
|
|
41397
|
-
throw error;
|
|
41398
|
-
}
|
|
41399
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41400
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41401
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41402
|
-
DataTable,
|
|
41403
|
-
{
|
|
41404
|
-
data: sales_channels,
|
|
41405
|
-
columns,
|
|
41406
|
-
getRowId: (row) => row.id,
|
|
41407
|
-
rowCount: count2,
|
|
41408
|
-
isLoading,
|
|
41409
|
-
filters,
|
|
41410
|
-
rowSelection: {
|
|
41411
|
-
state: rowSelection,
|
|
41412
|
-
onRowSelectionChange: setRowSelection
|
|
41413
|
-
},
|
|
41414
|
-
autoFocusSearch: true,
|
|
41415
|
-
layout: "fill",
|
|
41416
|
-
emptyState,
|
|
41417
|
-
prefix: PREFIX
|
|
41418
|
-
}
|
|
41419
|
-
) }),
|
|
41420
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41421
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41422
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41423
|
-
] }) })
|
|
41424
|
-
] }) });
|
|
41425
|
-
};
|
|
41426
|
-
const columnHelper = ui.createDataTableColumnHelper();
|
|
41427
|
-
const useColumns = () => {
|
|
41428
|
-
const columns = useSalesChannelTableColumns();
|
|
41429
|
-
return React.useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
41430
|
-
};
|
|
41431
|
-
const ProductSalesChannels = () => {
|
|
41432
|
-
const { id } = reactRouterDom.useParams();
|
|
41433
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41434
|
-
if (isError) {
|
|
41435
|
-
throw error;
|
|
41436
|
-
}
|
|
41437
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41438
|
-
};
|
|
41439
41439
|
const widgetModule = { widgets: [
|
|
41440
41440
|
{
|
|
41441
41441
|
Component: CustomerStoreCreditWidget,
|
|
@@ -41524,13 +41524,13 @@ const routeModule = {
|
|
|
41524
41524
|
Component: ProductMedia,
|
|
41525
41525
|
path: "/gift-cards/gift-card-products/:id/media"
|
|
41526
41526
|
},
|
|
41527
|
-
{
|
|
41528
|
-
Component: ProductPrices,
|
|
41529
|
-
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41530
|
-
},
|
|
41531
41527
|
{
|
|
41532
41528
|
Component: ProductSalesChannels,
|
|
41533
41529
|
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41530
|
+
},
|
|
41531
|
+
{
|
|
41532
|
+
Component: ProductPrices,
|
|
41533
|
+
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41534
41534
|
}
|
|
41535
41535
|
]
|
|
41536
41536
|
};
|
|
@@ -41152,6 +41152,112 @@ const ProductMedia = () => {
|
|
|
41152
41152
|
ready && /* @__PURE__ */ jsx(ProductMediaView, { product })
|
|
41153
41153
|
] });
|
|
41154
41154
|
};
|
|
41155
|
+
const EditSalesChannelsSchema = zod.object({
|
|
41156
|
+
sales_channels: zod.array(zod.string()).optional()
|
|
41157
|
+
});
|
|
41158
|
+
const PAGE_SIZE = 50;
|
|
41159
|
+
const PREFIX = "sc";
|
|
41160
|
+
const EditSalesChannelsForm = ({
|
|
41161
|
+
product
|
|
41162
|
+
}) => {
|
|
41163
|
+
var _a2, _b;
|
|
41164
|
+
const { handleSuccess } = useRouteModal();
|
|
41165
|
+
const form = useForm({
|
|
41166
|
+
defaultValues: {
|
|
41167
|
+
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41168
|
+
},
|
|
41169
|
+
resolver: t(EditSalesChannelsSchema)
|
|
41170
|
+
});
|
|
41171
|
+
const { setValue: setValue2 } = form;
|
|
41172
|
+
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41173
|
+
acc[curr.id] = true;
|
|
41174
|
+
return acc;
|
|
41175
|
+
}, {})) ?? {};
|
|
41176
|
+
const [rowSelection, setRowSelection] = useState(initialState2);
|
|
41177
|
+
useEffect(() => {
|
|
41178
|
+
const ids2 = Object.keys(rowSelection);
|
|
41179
|
+
setValue2("sales_channels", ids2, {
|
|
41180
|
+
shouldDirty: true,
|
|
41181
|
+
shouldTouch: true
|
|
41182
|
+
});
|
|
41183
|
+
}, [rowSelection, setValue2]);
|
|
41184
|
+
const searchParams = useSalesChannelTableQuery({
|
|
41185
|
+
pageSize: PAGE_SIZE,
|
|
41186
|
+
prefix: PREFIX
|
|
41187
|
+
});
|
|
41188
|
+
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41189
|
+
{
|
|
41190
|
+
...searchParams
|
|
41191
|
+
},
|
|
41192
|
+
{
|
|
41193
|
+
placeholderData: keepPreviousData
|
|
41194
|
+
}
|
|
41195
|
+
);
|
|
41196
|
+
const filters = useSalesChannelTableFilters();
|
|
41197
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
41198
|
+
const columns = useColumns();
|
|
41199
|
+
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41200
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41201
|
+
const arr = data.sales_channels ?? [];
|
|
41202
|
+
const sales_channels2 = arr.map((id) => {
|
|
41203
|
+
return {
|
|
41204
|
+
id
|
|
41205
|
+
};
|
|
41206
|
+
});
|
|
41207
|
+
await mutateAsync(
|
|
41208
|
+
{
|
|
41209
|
+
sales_channels: sales_channels2
|
|
41210
|
+
},
|
|
41211
|
+
{
|
|
41212
|
+
onSuccess: () => {
|
|
41213
|
+
handleSuccess();
|
|
41214
|
+
}
|
|
41215
|
+
}
|
|
41216
|
+
);
|
|
41217
|
+
});
|
|
41218
|
+
if (isError) {
|
|
41219
|
+
throw error;
|
|
41220
|
+
}
|
|
41221
|
+
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41222
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
41223
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
41224
|
+
DataTable,
|
|
41225
|
+
{
|
|
41226
|
+
data: sales_channels,
|
|
41227
|
+
columns,
|
|
41228
|
+
getRowId: (row) => row.id,
|
|
41229
|
+
rowCount: count2,
|
|
41230
|
+
isLoading,
|
|
41231
|
+
filters,
|
|
41232
|
+
rowSelection: {
|
|
41233
|
+
state: rowSelection,
|
|
41234
|
+
onRowSelectionChange: setRowSelection
|
|
41235
|
+
},
|
|
41236
|
+
autoFocusSearch: true,
|
|
41237
|
+
layout: "fill",
|
|
41238
|
+
emptyState,
|
|
41239
|
+
prefix: PREFIX
|
|
41240
|
+
}
|
|
41241
|
+
) }),
|
|
41242
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41243
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41244
|
+
/* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41245
|
+
] }) })
|
|
41246
|
+
] }) });
|
|
41247
|
+
};
|
|
41248
|
+
const columnHelper$1 = createDataTableColumnHelper();
|
|
41249
|
+
const useColumns = () => {
|
|
41250
|
+
const columns = useSalesChannelTableColumns();
|
|
41251
|
+
return useMemo(() => [columnHelper$1.select(), ...columns], [columns]);
|
|
41252
|
+
};
|
|
41253
|
+
const ProductSalesChannels = () => {
|
|
41254
|
+
const { id } = useParams();
|
|
41255
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
41256
|
+
if (isError) {
|
|
41257
|
+
throw error;
|
|
41258
|
+
}
|
|
41259
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
|
|
41260
|
+
};
|
|
41155
41261
|
const VariantPricingForm = ({ form }) => {
|
|
41156
41262
|
const { store } = useStore$2();
|
|
41157
41263
|
const { regions } = useRegions({ limit: 9999 });
|
|
@@ -41176,7 +41282,7 @@ const VariantPricingForm = ({ form }) => {
|
|
|
41176
41282
|
}
|
|
41177
41283
|
);
|
|
41178
41284
|
};
|
|
41179
|
-
const columnHelper
|
|
41285
|
+
const columnHelper = createDataGridHelper();
|
|
41180
41286
|
const useVariantPriceGridColumns = ({
|
|
41181
41287
|
currencies: currencies2 = [],
|
|
41182
41288
|
regions = [],
|
|
@@ -41184,7 +41290,7 @@ const useVariantPriceGridColumns = ({
|
|
|
41184
41290
|
}) => {
|
|
41185
41291
|
return useMemo(() => {
|
|
41186
41292
|
return [
|
|
41187
|
-
columnHelper
|
|
41293
|
+
columnHelper.column({
|
|
41188
41294
|
id: "Title",
|
|
41189
41295
|
header: "Title",
|
|
41190
41296
|
cell: (context) => {
|
|
@@ -41310,112 +41416,6 @@ const ProductPrices = () => {
|
|
|
41310
41416
|
}
|
|
41311
41417
|
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41312
41418
|
};
|
|
41313
|
-
const EditSalesChannelsSchema = zod.object({
|
|
41314
|
-
sales_channels: zod.array(zod.string()).optional()
|
|
41315
|
-
});
|
|
41316
|
-
const PAGE_SIZE = 50;
|
|
41317
|
-
const PREFIX = "sc";
|
|
41318
|
-
const EditSalesChannelsForm = ({
|
|
41319
|
-
product
|
|
41320
|
-
}) => {
|
|
41321
|
-
var _a2, _b;
|
|
41322
|
-
const { handleSuccess } = useRouteModal();
|
|
41323
|
-
const form = useForm({
|
|
41324
|
-
defaultValues: {
|
|
41325
|
-
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41326
|
-
},
|
|
41327
|
-
resolver: t(EditSalesChannelsSchema)
|
|
41328
|
-
});
|
|
41329
|
-
const { setValue: setValue2 } = form;
|
|
41330
|
-
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41331
|
-
acc[curr.id] = true;
|
|
41332
|
-
return acc;
|
|
41333
|
-
}, {})) ?? {};
|
|
41334
|
-
const [rowSelection, setRowSelection] = useState(initialState2);
|
|
41335
|
-
useEffect(() => {
|
|
41336
|
-
const ids2 = Object.keys(rowSelection);
|
|
41337
|
-
setValue2("sales_channels", ids2, {
|
|
41338
|
-
shouldDirty: true,
|
|
41339
|
-
shouldTouch: true
|
|
41340
|
-
});
|
|
41341
|
-
}, [rowSelection, setValue2]);
|
|
41342
|
-
const searchParams = useSalesChannelTableQuery({
|
|
41343
|
-
pageSize: PAGE_SIZE,
|
|
41344
|
-
prefix: PREFIX
|
|
41345
|
-
});
|
|
41346
|
-
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41347
|
-
{
|
|
41348
|
-
...searchParams
|
|
41349
|
-
},
|
|
41350
|
-
{
|
|
41351
|
-
placeholderData: keepPreviousData
|
|
41352
|
-
}
|
|
41353
|
-
);
|
|
41354
|
-
const filters = useSalesChannelTableFilters();
|
|
41355
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
41356
|
-
const columns = useColumns();
|
|
41357
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41358
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41359
|
-
const arr = data.sales_channels ?? [];
|
|
41360
|
-
const sales_channels2 = arr.map((id) => {
|
|
41361
|
-
return {
|
|
41362
|
-
id
|
|
41363
|
-
};
|
|
41364
|
-
});
|
|
41365
|
-
await mutateAsync(
|
|
41366
|
-
{
|
|
41367
|
-
sales_channels: sales_channels2
|
|
41368
|
-
},
|
|
41369
|
-
{
|
|
41370
|
-
onSuccess: () => {
|
|
41371
|
-
handleSuccess();
|
|
41372
|
-
}
|
|
41373
|
-
}
|
|
41374
|
-
);
|
|
41375
|
-
});
|
|
41376
|
-
if (isError) {
|
|
41377
|
-
throw error;
|
|
41378
|
-
}
|
|
41379
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41380
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
41381
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
41382
|
-
DataTable,
|
|
41383
|
-
{
|
|
41384
|
-
data: sales_channels,
|
|
41385
|
-
columns,
|
|
41386
|
-
getRowId: (row) => row.id,
|
|
41387
|
-
rowCount: count2,
|
|
41388
|
-
isLoading,
|
|
41389
|
-
filters,
|
|
41390
|
-
rowSelection: {
|
|
41391
|
-
state: rowSelection,
|
|
41392
|
-
onRowSelectionChange: setRowSelection
|
|
41393
|
-
},
|
|
41394
|
-
autoFocusSearch: true,
|
|
41395
|
-
layout: "fill",
|
|
41396
|
-
emptyState,
|
|
41397
|
-
prefix: PREFIX
|
|
41398
|
-
}
|
|
41399
|
-
) }),
|
|
41400
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41401
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41402
|
-
/* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41403
|
-
] }) })
|
|
41404
|
-
] }) });
|
|
41405
|
-
};
|
|
41406
|
-
const columnHelper = createDataTableColumnHelper();
|
|
41407
|
-
const useColumns = () => {
|
|
41408
|
-
const columns = useSalesChannelTableColumns();
|
|
41409
|
-
return useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
41410
|
-
};
|
|
41411
|
-
const ProductSalesChannels = () => {
|
|
41412
|
-
const { id } = useParams();
|
|
41413
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41414
|
-
if (isError) {
|
|
41415
|
-
throw error;
|
|
41416
|
-
}
|
|
41417
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
|
|
41418
|
-
};
|
|
41419
41419
|
const widgetModule = { widgets: [
|
|
41420
41420
|
{
|
|
41421
41421
|
Component: CustomerStoreCreditWidget,
|
|
@@ -41504,13 +41504,13 @@ const routeModule = {
|
|
|
41504
41504
|
Component: ProductMedia,
|
|
41505
41505
|
path: "/gift-cards/gift-card-products/:id/media"
|
|
41506
41506
|
},
|
|
41507
|
-
{
|
|
41508
|
-
Component: ProductPrices,
|
|
41509
|
-
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41510
|
-
},
|
|
41511
41507
|
{
|
|
41512
41508
|
Component: ProductSalesChannels,
|
|
41513
41509
|
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41510
|
+
},
|
|
41511
|
+
{
|
|
41512
|
+
Component: ProductPrices,
|
|
41513
|
+
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41514
41514
|
}
|
|
41515
41515
|
]
|
|
41516
41516
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/loyalty-plugin",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.6-preview-20260601104039",
|
|
4
4
|
"description": "Medusa Plugin: Loyalty - Gift Cards",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"prepare": "cross-env NODE_ENV=production yarn run build"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@medusajs/admin-sdk": "2.15.
|
|
53
|
-
"@medusajs/cli": "2.15.
|
|
54
|
-
"@medusajs/framework": "2.15.
|
|
55
|
-
"@medusajs/icons": "2.15.
|
|
56
|
-
"@medusajs/test-utils": "2.15.
|
|
57
|
-
"@medusajs/types": "2.15.
|
|
58
|
-
"@medusajs/ui": "4.1.
|
|
59
|
-
"@medusajs/ui-preset": "2.15.
|
|
52
|
+
"@medusajs/admin-sdk": "2.15.6-preview-20260601104039",
|
|
53
|
+
"@medusajs/cli": "2.15.6-preview-20260601104039",
|
|
54
|
+
"@medusajs/framework": "2.15.6-preview-20260601104039",
|
|
55
|
+
"@medusajs/icons": "2.15.6-preview-20260601104039",
|
|
56
|
+
"@medusajs/test-utils": "2.15.6-preview-20260601104039",
|
|
57
|
+
"@medusajs/types": "2.15.6-preview-20260601104039",
|
|
58
|
+
"@medusajs/ui": "4.1.16-preview-20260601104039",
|
|
59
|
+
"@medusajs/ui-preset": "2.15.6-preview-20260601104039",
|
|
60
60
|
"@swc/core": "1.5.7",
|
|
61
61
|
"@types/node": "^20.0.0",
|
|
62
62
|
"cross-env": "^7.0.3",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"typescript": "^5.7.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@medusajs/admin-sdk": "2.15.
|
|
68
|
-
"@medusajs/cli": "2.15.
|
|
69
|
-
"@medusajs/framework": "2.15.
|
|
70
|
-
"@medusajs/icons": "2.15.
|
|
71
|
-
"@medusajs/test-utils": "2.15.
|
|
72
|
-
"@medusajs/ui": "4.1.
|
|
67
|
+
"@medusajs/admin-sdk": "2.15.6-preview-20260601104039",
|
|
68
|
+
"@medusajs/cli": "2.15.6-preview-20260601104039",
|
|
69
|
+
"@medusajs/framework": "2.15.6-preview-20260601104039",
|
|
70
|
+
"@medusajs/icons": "2.15.6-preview-20260601104039",
|
|
71
|
+
"@medusajs/test-utils": "2.15.6-preview-20260601104039",
|
|
72
|
+
"@medusajs/ui": "4.1.16-preview-20260601104039",
|
|
73
73
|
"react": "^18.3.1",
|
|
74
74
|
"react-dom": "^18.3.1",
|
|
75
75
|
"react-router-dom": "6.30.3"
|