@medusajs/loyalty-plugin 2.15.3 → 2.15.4-preview-20260521212902
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 +283 -283
- package/.medusa/server/src/admin/index.mjs +283 -283
- package/package.json +15 -15
|
@@ -40239,6 +40239,153 @@ const ProductDetail = () => {
|
|
|
40239
40239
|
] });
|
|
40240
40240
|
};
|
|
40241
40241
|
const EditProductSchema$1 = zod.z.object({
|
|
40242
|
+
denominations: zod.z.array(
|
|
40243
|
+
zod.z.object({
|
|
40244
|
+
id: zod.z.string().optional(),
|
|
40245
|
+
value: zod.z.string().min(1),
|
|
40246
|
+
prices: zod.z.record(zod.z.string(), optionalFloat).optional()
|
|
40247
|
+
})
|
|
40248
|
+
).min(1)
|
|
40249
|
+
});
|
|
40250
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
40251
|
+
product
|
|
40252
|
+
}) => {
|
|
40253
|
+
var _a2;
|
|
40254
|
+
const { handleSuccess } = useRouteModal();
|
|
40255
|
+
const form = useForm({
|
|
40256
|
+
defaultValues: {
|
|
40257
|
+
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40258
|
+
id: variant.id,
|
|
40259
|
+
value: variant.title
|
|
40260
|
+
}))
|
|
40261
|
+
},
|
|
40262
|
+
resolver: t(EditProductSchema$1)
|
|
40263
|
+
});
|
|
40264
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40265
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40266
|
+
const optionValues = data.denominations.map(
|
|
40267
|
+
(denomination) => denomination.value
|
|
40268
|
+
);
|
|
40269
|
+
const options = [
|
|
40270
|
+
{
|
|
40271
|
+
title: "denomination",
|
|
40272
|
+
values: optionValues
|
|
40273
|
+
}
|
|
40274
|
+
];
|
|
40275
|
+
await mutateAsync(
|
|
40276
|
+
{
|
|
40277
|
+
options,
|
|
40278
|
+
variants: data.denominations.map((denomination) => ({
|
|
40279
|
+
id: denomination.id,
|
|
40280
|
+
title: denomination.value,
|
|
40281
|
+
manage_inventory: false,
|
|
40282
|
+
options: {
|
|
40283
|
+
denomination: denomination.value
|
|
40284
|
+
}
|
|
40285
|
+
}))
|
|
40286
|
+
},
|
|
40287
|
+
{
|
|
40288
|
+
onSuccess: () => {
|
|
40289
|
+
ui.toast.success(`Denominations updated successfully`);
|
|
40290
|
+
handleSuccess();
|
|
40291
|
+
},
|
|
40292
|
+
onError: (e2) => {
|
|
40293
|
+
ui.toast.error(e2.message);
|
|
40294
|
+
}
|
|
40295
|
+
}
|
|
40296
|
+
);
|
|
40297
|
+
});
|
|
40298
|
+
const {
|
|
40299
|
+
fields: denominationsFields,
|
|
40300
|
+
append: addDenomination,
|
|
40301
|
+
remove: removeDenomination
|
|
40302
|
+
} = useFieldArray({
|
|
40303
|
+
name: "denominations",
|
|
40304
|
+
control: form.control
|
|
40305
|
+
});
|
|
40306
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40307
|
+
KeyboundForm,
|
|
40308
|
+
{
|
|
40309
|
+
onSubmit: handleSubmit,
|
|
40310
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
40311
|
+
children: [
|
|
40312
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
40313
|
+
denominationsFields.map((denominationField, index) => {
|
|
40314
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40315
|
+
"div",
|
|
40316
|
+
{
|
|
40317
|
+
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40318
|
+
children: [
|
|
40319
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40320
|
+
Form$2.Field,
|
|
40321
|
+
{
|
|
40322
|
+
control: form.control,
|
|
40323
|
+
name: `denominations.${index}.value`,
|
|
40324
|
+
render: ({ field }) => {
|
|
40325
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40326
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
40327
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40328
|
+
] });
|
|
40329
|
+
}
|
|
40330
|
+
},
|
|
40331
|
+
denominationField.id
|
|
40332
|
+
),
|
|
40333
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40334
|
+
ui.Button,
|
|
40335
|
+
{
|
|
40336
|
+
size: "small",
|
|
40337
|
+
variant: "secondary",
|
|
40338
|
+
type: "button",
|
|
40339
|
+
className: "ml-4 rounded-full p-0",
|
|
40340
|
+
onClick: () => {
|
|
40341
|
+
removeDenomination(index);
|
|
40342
|
+
},
|
|
40343
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
40344
|
+
}
|
|
40345
|
+
) })
|
|
40346
|
+
]
|
|
40347
|
+
},
|
|
40348
|
+
denominationField.id
|
|
40349
|
+
);
|
|
40350
|
+
}),
|
|
40351
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40352
|
+
ui.Button,
|
|
40353
|
+
{
|
|
40354
|
+
size: "small",
|
|
40355
|
+
variant: "secondary",
|
|
40356
|
+
type: "button",
|
|
40357
|
+
className: "w-full",
|
|
40358
|
+
onClick: () => {
|
|
40359
|
+
addDenomination({ value: "", prices: {} });
|
|
40360
|
+
},
|
|
40361
|
+
children: "Add denomination"
|
|
40362
|
+
}
|
|
40363
|
+
),
|
|
40364
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40365
|
+
] }) }) }) }),
|
|
40366
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40367
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40368
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40369
|
+
] }) })
|
|
40370
|
+
]
|
|
40371
|
+
}
|
|
40372
|
+
) });
|
|
40373
|
+
};
|
|
40374
|
+
const GiftCardProductEdit$1 = () => {
|
|
40375
|
+
const { id } = reactRouterDom.useParams();
|
|
40376
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40377
|
+
if (isError) {
|
|
40378
|
+
throw error;
|
|
40379
|
+
}
|
|
40380
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40381
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40382
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
40383
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40384
|
+
] }),
|
|
40385
|
+
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40386
|
+
] });
|
|
40387
|
+
};
|
|
40388
|
+
const EditProductSchema = zod.z.object({
|
|
40242
40389
|
status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40243
40390
|
title: zod.z.string().min(1),
|
|
40244
40391
|
subtitle: zod.z.string().optional(),
|
|
@@ -40257,7 +40404,7 @@ const GiftCardProductEditForm = ({
|
|
|
40257
40404
|
handle: product.handle || "",
|
|
40258
40405
|
description: product.description || ""
|
|
40259
40406
|
},
|
|
40260
|
-
resolver: t(EditProductSchema
|
|
40407
|
+
resolver: t(EditProductSchema)
|
|
40261
40408
|
});
|
|
40262
40409
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40263
40410
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -40369,174 +40516,27 @@ const GiftCardProductEditForm = ({
|
|
|
40369
40516
|
}
|
|
40370
40517
|
) }),
|
|
40371
40518
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, className: "pl-10" })
|
|
40372
|
-
] }) }),
|
|
40373
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40374
|
-
] });
|
|
40375
|
-
}
|
|
40376
|
-
}
|
|
40377
|
-
),
|
|
40378
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40379
|
-
Form$2.Field,
|
|
40380
|
-
{
|
|
40381
|
-
control: form.control,
|
|
40382
|
-
name: "description",
|
|
40383
|
-
render: ({ field }) => {
|
|
40384
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
40385
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Description" }),
|
|
40386
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
40387
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40388
|
-
] });
|
|
40389
|
-
}
|
|
40390
|
-
}
|
|
40391
|
-
)
|
|
40392
|
-
] }) }) }),
|
|
40393
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40394
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40395
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40396
|
-
] }) })
|
|
40397
|
-
]
|
|
40398
|
-
}
|
|
40399
|
-
) });
|
|
40400
|
-
};
|
|
40401
|
-
const GiftCardProductEdit$1 = () => {
|
|
40402
|
-
const { id } = reactRouterDom.useParams();
|
|
40403
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40404
|
-
if (isError) {
|
|
40405
|
-
throw error;
|
|
40406
|
-
}
|
|
40407
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40408
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40409
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift card product" }) }),
|
|
40410
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
|
|
40411
|
-
] }),
|
|
40412
|
-
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40413
|
-
] });
|
|
40414
|
-
};
|
|
40415
|
-
const EditProductSchema = zod.z.object({
|
|
40416
|
-
denominations: zod.z.array(
|
|
40417
|
-
zod.z.object({
|
|
40418
|
-
id: zod.z.string().optional(),
|
|
40419
|
-
value: zod.z.string().min(1),
|
|
40420
|
-
prices: zod.z.record(zod.z.string(), optionalFloat).optional()
|
|
40421
|
-
})
|
|
40422
|
-
).min(1)
|
|
40423
|
-
});
|
|
40424
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
40425
|
-
product
|
|
40426
|
-
}) => {
|
|
40427
|
-
var _a2;
|
|
40428
|
-
const { handleSuccess } = useRouteModal();
|
|
40429
|
-
const form = useForm({
|
|
40430
|
-
defaultValues: {
|
|
40431
|
-
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40432
|
-
id: variant.id,
|
|
40433
|
-
value: variant.title
|
|
40434
|
-
}))
|
|
40435
|
-
},
|
|
40436
|
-
resolver: t(EditProductSchema)
|
|
40437
|
-
});
|
|
40438
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40439
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40440
|
-
const optionValues = data.denominations.map(
|
|
40441
|
-
(denomination) => denomination.value
|
|
40442
|
-
);
|
|
40443
|
-
const options = [
|
|
40444
|
-
{
|
|
40445
|
-
title: "denomination",
|
|
40446
|
-
values: optionValues
|
|
40447
|
-
}
|
|
40448
|
-
];
|
|
40449
|
-
await mutateAsync(
|
|
40450
|
-
{
|
|
40451
|
-
options,
|
|
40452
|
-
variants: data.denominations.map((denomination) => ({
|
|
40453
|
-
id: denomination.id,
|
|
40454
|
-
title: denomination.value,
|
|
40455
|
-
manage_inventory: false,
|
|
40456
|
-
options: {
|
|
40457
|
-
denomination: denomination.value
|
|
40458
|
-
}
|
|
40459
|
-
}))
|
|
40460
|
-
},
|
|
40461
|
-
{
|
|
40462
|
-
onSuccess: () => {
|
|
40463
|
-
ui.toast.success(`Denominations updated successfully`);
|
|
40464
|
-
handleSuccess();
|
|
40465
|
-
},
|
|
40466
|
-
onError: (e2) => {
|
|
40467
|
-
ui.toast.error(e2.message);
|
|
40468
|
-
}
|
|
40469
|
-
}
|
|
40470
|
-
);
|
|
40471
|
-
});
|
|
40472
|
-
const {
|
|
40473
|
-
fields: denominationsFields,
|
|
40474
|
-
append: addDenomination,
|
|
40475
|
-
remove: removeDenomination
|
|
40476
|
-
} = useFieldArray({
|
|
40477
|
-
name: "denominations",
|
|
40478
|
-
control: form.control
|
|
40479
|
-
});
|
|
40480
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40481
|
-
KeyboundForm,
|
|
40482
|
-
{
|
|
40483
|
-
onSubmit: handleSubmit,
|
|
40484
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
40485
|
-
children: [
|
|
40486
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
40487
|
-
denominationsFields.map((denominationField, index) => {
|
|
40488
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40489
|
-
"div",
|
|
40490
|
-
{
|
|
40491
|
-
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40492
|
-
children: [
|
|
40493
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40494
|
-
Form$2.Field,
|
|
40495
|
-
{
|
|
40496
|
-
control: form.control,
|
|
40497
|
-
name: `denominations.${index}.value`,
|
|
40498
|
-
render: ({ field }) => {
|
|
40499
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40500
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
40501
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40502
|
-
] });
|
|
40503
|
-
}
|
|
40504
|
-
},
|
|
40505
|
-
denominationField.id
|
|
40506
|
-
),
|
|
40507
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40508
|
-
ui.Button,
|
|
40509
|
-
{
|
|
40510
|
-
size: "small",
|
|
40511
|
-
variant: "secondary",
|
|
40512
|
-
type: "button",
|
|
40513
|
-
className: "ml-4 rounded-full p-0",
|
|
40514
|
-
onClick: () => {
|
|
40515
|
-
removeDenomination(index);
|
|
40516
|
-
},
|
|
40517
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
40518
|
-
}
|
|
40519
|
-
) })
|
|
40520
|
-
]
|
|
40521
|
-
},
|
|
40522
|
-
denominationField.id
|
|
40523
|
-
);
|
|
40524
|
-
}),
|
|
40519
|
+
] }) }),
|
|
40520
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40521
|
+
] });
|
|
40522
|
+
}
|
|
40523
|
+
}
|
|
40524
|
+
),
|
|
40525
40525
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40526
|
-
|
|
40526
|
+
Form$2.Field,
|
|
40527
40527
|
{
|
|
40528
|
-
|
|
40529
|
-
|
|
40530
|
-
|
|
40531
|
-
|
|
40532
|
-
|
|
40533
|
-
|
|
40534
|
-
|
|
40535
|
-
|
|
40528
|
+
control: form.control,
|
|
40529
|
+
name: "description",
|
|
40530
|
+
render: ({ field }) => {
|
|
40531
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
40532
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Description" }),
|
|
40533
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
40534
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40535
|
+
] });
|
|
40536
|
+
}
|
|
40536
40537
|
}
|
|
40537
|
-
)
|
|
40538
|
-
|
|
40539
|
-
] }) }) }) }),
|
|
40538
|
+
)
|
|
40539
|
+
] }) }) }),
|
|
40540
40540
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40541
40541
|
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40542
40542
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -40553,10 +40553,10 @@ const GiftCardProductEdit = () => {
|
|
|
40553
40553
|
}
|
|
40554
40554
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40555
40555
|
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40556
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift
|
|
40557
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card
|
|
40556
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift card product" }) }),
|
|
40557
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
|
|
40558
40558
|
] }),
|
|
40559
|
-
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(
|
|
40559
|
+
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40560
40560
|
] });
|
|
40561
40561
|
};
|
|
40562
40562
|
const EditProductMediaForm = ({ product }) => {
|
|
@@ -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,
|
|
@@ -41512,11 +41512,11 @@ const routeModule = {
|
|
|
41512
41512
|
children: [
|
|
41513
41513
|
{
|
|
41514
41514
|
Component: GiftCardProductEdit$1,
|
|
41515
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41515
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41516
41516
|
},
|
|
41517
41517
|
{
|
|
41518
41518
|
Component: GiftCardProductEdit,
|
|
41519
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41519
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
41520
41520
|
}
|
|
41521
41521
|
]
|
|
41522
41522
|
},
|
|
@@ -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
|
};
|
|
@@ -40219,6 +40219,153 @@ const ProductDetail = () => {
|
|
|
40219
40219
|
] });
|
|
40220
40220
|
};
|
|
40221
40221
|
const EditProductSchema$1 = z.object({
|
|
40222
|
+
denominations: z.array(
|
|
40223
|
+
z.object({
|
|
40224
|
+
id: z.string().optional(),
|
|
40225
|
+
value: z.string().min(1),
|
|
40226
|
+
prices: z.record(z.string(), optionalFloat).optional()
|
|
40227
|
+
})
|
|
40228
|
+
).min(1)
|
|
40229
|
+
});
|
|
40230
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
40231
|
+
product
|
|
40232
|
+
}) => {
|
|
40233
|
+
var _a2;
|
|
40234
|
+
const { handleSuccess } = useRouteModal();
|
|
40235
|
+
const form = useForm({
|
|
40236
|
+
defaultValues: {
|
|
40237
|
+
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40238
|
+
id: variant.id,
|
|
40239
|
+
value: variant.title
|
|
40240
|
+
}))
|
|
40241
|
+
},
|
|
40242
|
+
resolver: t(EditProductSchema$1)
|
|
40243
|
+
});
|
|
40244
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40245
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40246
|
+
const optionValues = data.denominations.map(
|
|
40247
|
+
(denomination) => denomination.value
|
|
40248
|
+
);
|
|
40249
|
+
const options = [
|
|
40250
|
+
{
|
|
40251
|
+
title: "denomination",
|
|
40252
|
+
values: optionValues
|
|
40253
|
+
}
|
|
40254
|
+
];
|
|
40255
|
+
await mutateAsync(
|
|
40256
|
+
{
|
|
40257
|
+
options,
|
|
40258
|
+
variants: data.denominations.map((denomination) => ({
|
|
40259
|
+
id: denomination.id,
|
|
40260
|
+
title: denomination.value,
|
|
40261
|
+
manage_inventory: false,
|
|
40262
|
+
options: {
|
|
40263
|
+
denomination: denomination.value
|
|
40264
|
+
}
|
|
40265
|
+
}))
|
|
40266
|
+
},
|
|
40267
|
+
{
|
|
40268
|
+
onSuccess: () => {
|
|
40269
|
+
toast.success(`Denominations updated successfully`);
|
|
40270
|
+
handleSuccess();
|
|
40271
|
+
},
|
|
40272
|
+
onError: (e2) => {
|
|
40273
|
+
toast.error(e2.message);
|
|
40274
|
+
}
|
|
40275
|
+
}
|
|
40276
|
+
);
|
|
40277
|
+
});
|
|
40278
|
+
const {
|
|
40279
|
+
fields: denominationsFields,
|
|
40280
|
+
append: addDenomination,
|
|
40281
|
+
remove: removeDenomination
|
|
40282
|
+
} = useFieldArray({
|
|
40283
|
+
name: "denominations",
|
|
40284
|
+
control: form.control
|
|
40285
|
+
});
|
|
40286
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
40287
|
+
KeyboundForm,
|
|
40288
|
+
{
|
|
40289
|
+
onSubmit: handleSubmit,
|
|
40290
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
40291
|
+
children: [
|
|
40292
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
40293
|
+
denominationsFields.map((denominationField, index) => {
|
|
40294
|
+
return /* @__PURE__ */ jsxs(
|
|
40295
|
+
"div",
|
|
40296
|
+
{
|
|
40297
|
+
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40298
|
+
children: [
|
|
40299
|
+
/* @__PURE__ */ jsx(
|
|
40300
|
+
Form$2.Field,
|
|
40301
|
+
{
|
|
40302
|
+
control: form.control,
|
|
40303
|
+
name: `denominations.${index}.value`,
|
|
40304
|
+
render: ({ field }) => {
|
|
40305
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40306
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
|
|
40307
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40308
|
+
] });
|
|
40309
|
+
}
|
|
40310
|
+
},
|
|
40311
|
+
denominationField.id
|
|
40312
|
+
),
|
|
40313
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
40314
|
+
Button,
|
|
40315
|
+
{
|
|
40316
|
+
size: "small",
|
|
40317
|
+
variant: "secondary",
|
|
40318
|
+
type: "button",
|
|
40319
|
+
className: "ml-4 rounded-full p-0",
|
|
40320
|
+
onClick: () => {
|
|
40321
|
+
removeDenomination(index);
|
|
40322
|
+
},
|
|
40323
|
+
children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
|
|
40324
|
+
}
|
|
40325
|
+
) })
|
|
40326
|
+
]
|
|
40327
|
+
},
|
|
40328
|
+
denominationField.id
|
|
40329
|
+
);
|
|
40330
|
+
}),
|
|
40331
|
+
/* @__PURE__ */ jsx(
|
|
40332
|
+
Button,
|
|
40333
|
+
{
|
|
40334
|
+
size: "small",
|
|
40335
|
+
variant: "secondary",
|
|
40336
|
+
type: "button",
|
|
40337
|
+
className: "w-full",
|
|
40338
|
+
onClick: () => {
|
|
40339
|
+
addDenomination({ value: "", prices: {} });
|
|
40340
|
+
},
|
|
40341
|
+
children: "Add denomination"
|
|
40342
|
+
}
|
|
40343
|
+
),
|
|
40344
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40345
|
+
] }) }) }) }),
|
|
40346
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40347
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40348
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40349
|
+
] }) })
|
|
40350
|
+
]
|
|
40351
|
+
}
|
|
40352
|
+
) });
|
|
40353
|
+
};
|
|
40354
|
+
const GiftCardProductEdit$1 = () => {
|
|
40355
|
+
const { id } = useParams();
|
|
40356
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40357
|
+
if (isError) {
|
|
40358
|
+
throw error;
|
|
40359
|
+
}
|
|
40360
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
40361
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
40362
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
|
|
40363
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40364
|
+
] }),
|
|
40365
|
+
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40366
|
+
] });
|
|
40367
|
+
};
|
|
40368
|
+
const EditProductSchema = z.object({
|
|
40222
40369
|
status: z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40223
40370
|
title: z.string().min(1),
|
|
40224
40371
|
subtitle: z.string().optional(),
|
|
@@ -40237,7 +40384,7 @@ const GiftCardProductEditForm = ({
|
|
|
40237
40384
|
handle: product.handle || "",
|
|
40238
40385
|
description: product.description || ""
|
|
40239
40386
|
},
|
|
40240
|
-
resolver: t(EditProductSchema
|
|
40387
|
+
resolver: t(EditProductSchema)
|
|
40241
40388
|
});
|
|
40242
40389
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40243
40390
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -40349,174 +40496,27 @@ const GiftCardProductEditForm = ({
|
|
|
40349
40496
|
}
|
|
40350
40497
|
) }),
|
|
40351
40498
|
/* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
|
|
40352
|
-
] }) }),
|
|
40353
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40354
|
-
] });
|
|
40355
|
-
}
|
|
40356
|
-
}
|
|
40357
|
-
),
|
|
40358
|
-
/* @__PURE__ */ jsx(
|
|
40359
|
-
Form$2.Field,
|
|
40360
|
-
{
|
|
40361
|
-
control: form.control,
|
|
40362
|
-
name: "description",
|
|
40363
|
-
render: ({ field }) => {
|
|
40364
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
40365
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
|
|
40366
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
40367
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40368
|
-
] });
|
|
40369
|
-
}
|
|
40370
|
-
}
|
|
40371
|
-
)
|
|
40372
|
-
] }) }) }),
|
|
40373
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40374
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40375
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40376
|
-
] }) })
|
|
40377
|
-
]
|
|
40378
|
-
}
|
|
40379
|
-
) });
|
|
40380
|
-
};
|
|
40381
|
-
const GiftCardProductEdit$1 = () => {
|
|
40382
|
-
const { id } = useParams();
|
|
40383
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40384
|
-
if (isError) {
|
|
40385
|
-
throw error;
|
|
40386
|
-
}
|
|
40387
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
40388
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
40389
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
|
|
40390
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
|
|
40391
|
-
] }),
|
|
40392
|
-
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
|
|
40393
|
-
] });
|
|
40394
|
-
};
|
|
40395
|
-
const EditProductSchema = z.object({
|
|
40396
|
-
denominations: z.array(
|
|
40397
|
-
z.object({
|
|
40398
|
-
id: z.string().optional(),
|
|
40399
|
-
value: z.string().min(1),
|
|
40400
|
-
prices: z.record(z.string(), optionalFloat).optional()
|
|
40401
|
-
})
|
|
40402
|
-
).min(1)
|
|
40403
|
-
});
|
|
40404
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
40405
|
-
product
|
|
40406
|
-
}) => {
|
|
40407
|
-
var _a2;
|
|
40408
|
-
const { handleSuccess } = useRouteModal();
|
|
40409
|
-
const form = useForm({
|
|
40410
|
-
defaultValues: {
|
|
40411
|
-
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40412
|
-
id: variant.id,
|
|
40413
|
-
value: variant.title
|
|
40414
|
-
}))
|
|
40415
|
-
},
|
|
40416
|
-
resolver: t(EditProductSchema)
|
|
40417
|
-
});
|
|
40418
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40419
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40420
|
-
const optionValues = data.denominations.map(
|
|
40421
|
-
(denomination) => denomination.value
|
|
40422
|
-
);
|
|
40423
|
-
const options = [
|
|
40424
|
-
{
|
|
40425
|
-
title: "denomination",
|
|
40426
|
-
values: optionValues
|
|
40427
|
-
}
|
|
40428
|
-
];
|
|
40429
|
-
await mutateAsync(
|
|
40430
|
-
{
|
|
40431
|
-
options,
|
|
40432
|
-
variants: data.denominations.map((denomination) => ({
|
|
40433
|
-
id: denomination.id,
|
|
40434
|
-
title: denomination.value,
|
|
40435
|
-
manage_inventory: false,
|
|
40436
|
-
options: {
|
|
40437
|
-
denomination: denomination.value
|
|
40438
|
-
}
|
|
40439
|
-
}))
|
|
40440
|
-
},
|
|
40441
|
-
{
|
|
40442
|
-
onSuccess: () => {
|
|
40443
|
-
toast.success(`Denominations updated successfully`);
|
|
40444
|
-
handleSuccess();
|
|
40445
|
-
},
|
|
40446
|
-
onError: (e2) => {
|
|
40447
|
-
toast.error(e2.message);
|
|
40448
|
-
}
|
|
40449
|
-
}
|
|
40450
|
-
);
|
|
40451
|
-
});
|
|
40452
|
-
const {
|
|
40453
|
-
fields: denominationsFields,
|
|
40454
|
-
append: addDenomination,
|
|
40455
|
-
remove: removeDenomination
|
|
40456
|
-
} = useFieldArray({
|
|
40457
|
-
name: "denominations",
|
|
40458
|
-
control: form.control
|
|
40459
|
-
});
|
|
40460
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
40461
|
-
KeyboundForm,
|
|
40462
|
-
{
|
|
40463
|
-
onSubmit: handleSubmit,
|
|
40464
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
40465
|
-
children: [
|
|
40466
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
40467
|
-
denominationsFields.map((denominationField, index) => {
|
|
40468
|
-
return /* @__PURE__ */ jsxs(
|
|
40469
|
-
"div",
|
|
40470
|
-
{
|
|
40471
|
-
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40472
|
-
children: [
|
|
40473
|
-
/* @__PURE__ */ jsx(
|
|
40474
|
-
Form$2.Field,
|
|
40475
|
-
{
|
|
40476
|
-
control: form.control,
|
|
40477
|
-
name: `denominations.${index}.value`,
|
|
40478
|
-
render: ({ field }) => {
|
|
40479
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40480
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
|
|
40481
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40482
|
-
] });
|
|
40483
|
-
}
|
|
40484
|
-
},
|
|
40485
|
-
denominationField.id
|
|
40486
|
-
),
|
|
40487
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
40488
|
-
Button,
|
|
40489
|
-
{
|
|
40490
|
-
size: "small",
|
|
40491
|
-
variant: "secondary",
|
|
40492
|
-
type: "button",
|
|
40493
|
-
className: "ml-4 rounded-full p-0",
|
|
40494
|
-
onClick: () => {
|
|
40495
|
-
removeDenomination(index);
|
|
40496
|
-
},
|
|
40497
|
-
children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
|
|
40498
|
-
}
|
|
40499
|
-
) })
|
|
40500
|
-
]
|
|
40501
|
-
},
|
|
40502
|
-
denominationField.id
|
|
40503
|
-
);
|
|
40504
|
-
}),
|
|
40499
|
+
] }) }),
|
|
40500
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40501
|
+
] });
|
|
40502
|
+
}
|
|
40503
|
+
}
|
|
40504
|
+
),
|
|
40505
40505
|
/* @__PURE__ */ jsx(
|
|
40506
|
-
|
|
40506
|
+
Form$2.Field,
|
|
40507
40507
|
{
|
|
40508
|
-
|
|
40509
|
-
|
|
40510
|
-
|
|
40511
|
-
|
|
40512
|
-
|
|
40513
|
-
|
|
40514
|
-
|
|
40515
|
-
|
|
40508
|
+
control: form.control,
|
|
40509
|
+
name: "description",
|
|
40510
|
+
render: ({ field }) => {
|
|
40511
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
40512
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
|
|
40513
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
40514
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40515
|
+
] });
|
|
40516
|
+
}
|
|
40516
40517
|
}
|
|
40517
|
-
)
|
|
40518
|
-
|
|
40519
|
-
] }) }) }) }),
|
|
40518
|
+
)
|
|
40519
|
+
] }) }) }),
|
|
40520
40520
|
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40521
40521
|
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40522
40522
|
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
@@ -40533,10 +40533,10 @@ const GiftCardProductEdit = () => {
|
|
|
40533
40533
|
}
|
|
40534
40534
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
40535
40535
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
40536
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift
|
|
40537
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card
|
|
40536
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
|
|
40537
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
|
|
40538
40538
|
] }),
|
|
40539
|
-
!isLoading && product && /* @__PURE__ */ jsx(
|
|
40539
|
+
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
|
|
40540
40540
|
] });
|
|
40541
40541
|
};
|
|
40542
40542
|
const EditProductMediaForm = ({ product }) => {
|
|
@@ -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,
|
|
@@ -41492,11 +41492,11 @@ const routeModule = {
|
|
|
41492
41492
|
children: [
|
|
41493
41493
|
{
|
|
41494
41494
|
Component: GiftCardProductEdit$1,
|
|
41495
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41495
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41496
41496
|
},
|
|
41497
41497
|
{
|
|
41498
41498
|
Component: GiftCardProductEdit,
|
|
41499
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41499
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
41500
41500
|
}
|
|
41501
41501
|
]
|
|
41502
41502
|
},
|
|
@@ -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.4-preview-20260521212902",
|
|
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.4-preview-20260521212902",
|
|
53
|
+
"@medusajs/cli": "2.15.4-preview-20260521212902",
|
|
54
|
+
"@medusajs/framework": "2.15.4-preview-20260521212902",
|
|
55
|
+
"@medusajs/icons": "2.15.4-preview-20260521212902",
|
|
56
|
+
"@medusajs/test-utils": "2.15.4-preview-20260521212902",
|
|
57
|
+
"@medusajs/types": "2.15.4-preview-20260521212902",
|
|
58
|
+
"@medusajs/ui": "4.1.14-preview-20260521212902",
|
|
59
|
+
"@medusajs/ui-preset": "2.15.4-preview-20260521212902",
|
|
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.4-preview-20260521212902",
|
|
68
|
+
"@medusajs/cli": "2.15.4-preview-20260521212902",
|
|
69
|
+
"@medusajs/framework": "2.15.4-preview-20260521212902",
|
|
70
|
+
"@medusajs/icons": "2.15.4-preview-20260521212902",
|
|
71
|
+
"@medusajs/test-utils": "2.15.4-preview-20260521212902",
|
|
72
|
+
"@medusajs/ui": "4.1.14-preview-20260521212902",
|
|
73
73
|
"react": "^18.3.1",
|
|
74
74
|
"react-dom": "^18.3.1",
|
|
75
75
|
"react-router-dom": "6.30.3"
|