@medusajs/loyalty-plugin 2.15.0 → 2.15.1-preview-20260511150319
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 +389 -389
- package/.medusa/server/src/admin/index.mjs +389 -389
- package/package.json +15 -15
|
@@ -25934,73 +25934,6 @@ const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown,
|
|
|
25934
25934
|
);
|
|
25935
25935
|
});
|
|
25936
25936
|
KeyboundForm.displayName = "KeyboundForm";
|
|
25937
|
-
const Note$1 = () => {
|
|
25938
|
-
const { id } = reactRouterDom.useParams();
|
|
25939
|
-
const {
|
|
25940
|
-
gift_card: giftCard,
|
|
25941
|
-
isPending,
|
|
25942
|
-
isError,
|
|
25943
|
-
error
|
|
25944
|
-
} = useGiftCard(id, {});
|
|
25945
|
-
if (isError) {
|
|
25946
|
-
throw error;
|
|
25947
|
-
}
|
|
25948
|
-
const isReady = !isPending && !!giftCard;
|
|
25949
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
25950
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
25951
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
25952
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
25953
|
-
] }),
|
|
25954
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
25955
|
-
] });
|
|
25956
|
-
};
|
|
25957
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
25958
|
-
const form = useForm({
|
|
25959
|
-
defaultValues: {
|
|
25960
|
-
note: giftCard.note ?? ""
|
|
25961
|
-
},
|
|
25962
|
-
resolver: t(schema$2)
|
|
25963
|
-
});
|
|
25964
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
25965
|
-
const { handleSuccess } = useRouteModal();
|
|
25966
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
25967
|
-
await mutateAsync(
|
|
25968
|
-
{ note: data.note },
|
|
25969
|
-
{
|
|
25970
|
-
onSuccess: () => handleSuccess(),
|
|
25971
|
-
onError: (error) => ui.toast.error(error.message)
|
|
25972
|
-
}
|
|
25973
|
-
);
|
|
25974
|
-
});
|
|
25975
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
25976
|
-
KeyboundForm,
|
|
25977
|
-
{
|
|
25978
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
25979
|
-
onSubmit,
|
|
25980
|
-
children: [
|
|
25981
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25982
|
-
Form$2.Field,
|
|
25983
|
-
{
|
|
25984
|
-
control: form.control,
|
|
25985
|
-
name: "note",
|
|
25986
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
25987
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
25988
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
25989
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
25990
|
-
] })
|
|
25991
|
-
}
|
|
25992
|
-
) }),
|
|
25993
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
25994
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
25995
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
25996
|
-
] }) })
|
|
25997
|
-
]
|
|
25998
|
-
}
|
|
25999
|
-
) });
|
|
26000
|
-
};
|
|
26001
|
-
const schema$2 = zod.z.object({
|
|
26002
|
-
note: zod.z.string().optional()
|
|
26003
|
-
});
|
|
26004
25937
|
const GiftCardExpiration = () => {
|
|
26005
25938
|
const { id } = reactRouterDom.useParams();
|
|
26006
25939
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26021,7 +25954,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26021
25954
|
defaultValues: {
|
|
26022
25955
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26023
25956
|
},
|
|
26024
|
-
resolver: t(schema$
|
|
25957
|
+
resolver: t(schema$2)
|
|
26025
25958
|
});
|
|
26026
25959
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26027
25960
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26116,9 +26049,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26116
26049
|
}
|
|
26117
26050
|
) });
|
|
26118
26051
|
};
|
|
26119
|
-
const schema$
|
|
26052
|
+
const schema$2 = zod.z.object({
|
|
26120
26053
|
expires_at: zod.z.date().nullish()
|
|
26121
26054
|
});
|
|
26055
|
+
const Note$1 = () => {
|
|
26056
|
+
const { id } = reactRouterDom.useParams();
|
|
26057
|
+
const {
|
|
26058
|
+
gift_card: giftCard,
|
|
26059
|
+
isPending,
|
|
26060
|
+
isError,
|
|
26061
|
+
error
|
|
26062
|
+
} = useGiftCard(id, {});
|
|
26063
|
+
if (isError) {
|
|
26064
|
+
throw error;
|
|
26065
|
+
}
|
|
26066
|
+
const isReady = !isPending && !!giftCard;
|
|
26067
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
26068
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
26069
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
26070
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
26071
|
+
] }),
|
|
26072
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
26073
|
+
] });
|
|
26074
|
+
};
|
|
26075
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
26076
|
+
const form = useForm({
|
|
26077
|
+
defaultValues: {
|
|
26078
|
+
note: giftCard.note ?? ""
|
|
26079
|
+
},
|
|
26080
|
+
resolver: t(schema$1)
|
|
26081
|
+
});
|
|
26082
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26083
|
+
const { handleSuccess } = useRouteModal();
|
|
26084
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
26085
|
+
await mutateAsync(
|
|
26086
|
+
{ note: data.note },
|
|
26087
|
+
{
|
|
26088
|
+
onSuccess: () => handleSuccess(),
|
|
26089
|
+
onError: (error) => ui.toast.error(error.message)
|
|
26090
|
+
}
|
|
26091
|
+
);
|
|
26092
|
+
});
|
|
26093
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
26094
|
+
KeyboundForm,
|
|
26095
|
+
{
|
|
26096
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
26097
|
+
onSubmit,
|
|
26098
|
+
children: [
|
|
26099
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
26100
|
+
Form$2.Field,
|
|
26101
|
+
{
|
|
26102
|
+
control: form.control,
|
|
26103
|
+
name: "note",
|
|
26104
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
26105
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
26106
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
26107
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
26108
|
+
] })
|
|
26109
|
+
}
|
|
26110
|
+
) }),
|
|
26111
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26112
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26113
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26114
|
+
] }) })
|
|
26115
|
+
]
|
|
26116
|
+
}
|
|
26117
|
+
) });
|
|
26118
|
+
};
|
|
26119
|
+
const schema$1 = zod.z.object({
|
|
26120
|
+
note: zod.z.string().optional()
|
|
26121
|
+
});
|
|
26122
26122
|
const columnHelper$7 = createColumnHelper();
|
|
26123
26123
|
const useGiftCardProductsTableColumns = () => {
|
|
26124
26124
|
return React.useMemo(
|
|
@@ -40239,54 +40239,41 @@ const ProductDetail = () => {
|
|
|
40239
40239
|
] });
|
|
40240
40240
|
};
|
|
40241
40241
|
const EditProductSchema$1 = zod.z.object({
|
|
40242
|
-
|
|
40243
|
-
|
|
40244
|
-
|
|
40245
|
-
|
|
40246
|
-
|
|
40247
|
-
})
|
|
40248
|
-
).min(1)
|
|
40242
|
+
status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40243
|
+
title: zod.z.string().min(1),
|
|
40244
|
+
subtitle: zod.z.string().optional(),
|
|
40245
|
+
handle: zod.z.string().min(1),
|
|
40246
|
+
description: zod.z.string().optional()
|
|
40249
40247
|
});
|
|
40250
|
-
const
|
|
40248
|
+
const GiftCardProductEditForm = ({
|
|
40251
40249
|
product
|
|
40252
40250
|
}) => {
|
|
40253
|
-
var _a2;
|
|
40254
40251
|
const { handleSuccess } = useRouteModal();
|
|
40255
40252
|
const form = useForm({
|
|
40256
40253
|
defaultValues: {
|
|
40257
|
-
|
|
40258
|
-
|
|
40259
|
-
|
|
40260
|
-
|
|
40254
|
+
status: product.status,
|
|
40255
|
+
title: product.title,
|
|
40256
|
+
subtitle: product.subtitle || "",
|
|
40257
|
+
handle: product.handle || "",
|
|
40258
|
+
description: product.description || ""
|
|
40261
40259
|
},
|
|
40262
40260
|
resolver: t(EditProductSchema$1)
|
|
40263
40261
|
});
|
|
40264
40262
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40265
40263
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40266
|
-
const
|
|
40267
|
-
(denomination) => denomination.value
|
|
40268
|
-
);
|
|
40269
|
-
const options = [
|
|
40270
|
-
{
|
|
40271
|
-
title: "denomination",
|
|
40272
|
-
values: optionValues
|
|
40273
|
-
}
|
|
40274
|
-
];
|
|
40264
|
+
const { title, handle, status, ...optional2 } = data;
|
|
40275
40265
|
await mutateAsync(
|
|
40276
40266
|
{
|
|
40277
|
-
|
|
40278
|
-
|
|
40279
|
-
|
|
40280
|
-
|
|
40281
|
-
manage_inventory: false,
|
|
40282
|
-
options: {
|
|
40283
|
-
denomination: denomination.value
|
|
40284
|
-
}
|
|
40285
|
-
}))
|
|
40267
|
+
...optional2,
|
|
40268
|
+
title,
|
|
40269
|
+
handle,
|
|
40270
|
+
status
|
|
40286
40271
|
},
|
|
40287
40272
|
{
|
|
40288
|
-
onSuccess: () => {
|
|
40289
|
-
ui.toast.success(
|
|
40273
|
+
onSuccess: ({ product: product2 }) => {
|
|
40274
|
+
ui.toast.success(
|
|
40275
|
+
`Gift card product ${product2.title} updated successfully`
|
|
40276
|
+
);
|
|
40290
40277
|
handleSuccess();
|
|
40291
40278
|
},
|
|
40292
40279
|
onError: (e2) => {
|
|
@@ -40295,149 +40282,15 @@ const GiftCardProductEditDenominationsForm = ({
|
|
|
40295
40282
|
}
|
|
40296
40283
|
);
|
|
40297
40284
|
});
|
|
40298
|
-
const {
|
|
40299
|
-
fields: denominationsFields,
|
|
40300
|
-
append: addDenomination,
|
|
40301
|
-
remove: removeDenomination
|
|
40302
|
-
} = useFieldArray({
|
|
40303
|
-
name: "denominations",
|
|
40304
|
-
control: form.control
|
|
40305
|
-
});
|
|
40306
40285
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40307
40286
|
KeyboundForm,
|
|
40308
40287
|
{
|
|
40309
40288
|
onSubmit: handleSubmit,
|
|
40310
40289
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
40311
40290
|
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-
|
|
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
|
-
}),
|
|
40291
|
+
/* @__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-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
40351
40292
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40352
|
-
|
|
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({
|
|
40389
|
-
status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40390
|
-
title: zod.z.string().min(1),
|
|
40391
|
-
subtitle: zod.z.string().optional(),
|
|
40392
|
-
handle: zod.z.string().min(1),
|
|
40393
|
-
description: zod.z.string().optional()
|
|
40394
|
-
});
|
|
40395
|
-
const GiftCardProductEditForm = ({
|
|
40396
|
-
product
|
|
40397
|
-
}) => {
|
|
40398
|
-
const { handleSuccess } = useRouteModal();
|
|
40399
|
-
const form = useForm({
|
|
40400
|
-
defaultValues: {
|
|
40401
|
-
status: product.status,
|
|
40402
|
-
title: product.title,
|
|
40403
|
-
subtitle: product.subtitle || "",
|
|
40404
|
-
handle: product.handle || "",
|
|
40405
|
-
description: product.description || ""
|
|
40406
|
-
},
|
|
40407
|
-
resolver: t(EditProductSchema)
|
|
40408
|
-
});
|
|
40409
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40410
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40411
|
-
const { title, handle, status, ...optional2 } = data;
|
|
40412
|
-
await mutateAsync(
|
|
40413
|
-
{
|
|
40414
|
-
...optional2,
|
|
40415
|
-
title,
|
|
40416
|
-
handle,
|
|
40417
|
-
status
|
|
40418
|
-
},
|
|
40419
|
-
{
|
|
40420
|
-
onSuccess: ({ product: product2 }) => {
|
|
40421
|
-
ui.toast.success(
|
|
40422
|
-
`Gift card product ${product2.title} updated successfully`
|
|
40423
|
-
);
|
|
40424
|
-
handleSuccess();
|
|
40425
|
-
},
|
|
40426
|
-
onError: (e2) => {
|
|
40427
|
-
ui.toast.error(e2.message);
|
|
40428
|
-
}
|
|
40429
|
-
}
|
|
40430
|
-
);
|
|
40431
|
-
});
|
|
40432
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40433
|
-
KeyboundForm,
|
|
40434
|
-
{
|
|
40435
|
-
onSubmit: handleSubmit,
|
|
40436
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
40437
|
-
children: [
|
|
40438
|
-
/* @__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-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
40439
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40440
|
-
Form$2.Field,
|
|
40293
|
+
Form$2.Field,
|
|
40441
40294
|
{
|
|
40442
40295
|
control: form.control,
|
|
40443
40296
|
name: "status",
|
|
@@ -40545,7 +40398,7 @@ const GiftCardProductEditForm = ({
|
|
|
40545
40398
|
}
|
|
40546
40399
|
) });
|
|
40547
40400
|
};
|
|
40548
|
-
const GiftCardProductEdit = () => {
|
|
40401
|
+
const GiftCardProductEdit$1 = () => {
|
|
40549
40402
|
const { id } = reactRouterDom.useParams();
|
|
40550
40403
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40551
40404
|
if (isError) {
|
|
@@ -40559,163 +40412,152 @@ const GiftCardProductEdit = () => {
|
|
|
40559
40412
|
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40560
40413
|
] });
|
|
40561
40414
|
};
|
|
40562
|
-
const
|
|
40563
|
-
|
|
40564
|
-
|
|
40565
|
-
|
|
40566
|
-
|
|
40567
|
-
|
|
40568
|
-
currencies: store == null ? void 0 : store.supported_currencies,
|
|
40569
|
-
regions,
|
|
40570
|
-
pricePreferences
|
|
40571
|
-
});
|
|
40572
|
-
const variants = useWatch({
|
|
40573
|
-
control: form.control,
|
|
40574
|
-
name: "variants"
|
|
40575
|
-
});
|
|
40576
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
40577
|
-
DataGrid,
|
|
40578
|
-
{
|
|
40579
|
-
columns,
|
|
40580
|
-
data: variants,
|
|
40581
|
-
state: form,
|
|
40582
|
-
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
40583
|
-
}
|
|
40584
|
-
);
|
|
40585
|
-
};
|
|
40586
|
-
const columnHelper$1 = createDataGridHelper();
|
|
40587
|
-
const useVariantPriceGridColumns = ({
|
|
40588
|
-
currencies: currencies2 = [],
|
|
40589
|
-
regions = [],
|
|
40590
|
-
pricePreferences = []
|
|
40591
|
-
}) => {
|
|
40592
|
-
return React.useMemo(() => {
|
|
40593
|
-
return [
|
|
40594
|
-
columnHelper$1.column({
|
|
40595
|
-
id: "Title",
|
|
40596
|
-
header: "Title",
|
|
40597
|
-
cell: (context) => {
|
|
40598
|
-
const entity = context.row.original;
|
|
40599
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: entity.title }) }) });
|
|
40600
|
-
},
|
|
40601
|
-
disableHiding: true
|
|
40602
|
-
}),
|
|
40603
|
-
...createDataGridPriceColumns({
|
|
40604
|
-
currencies: currencies2.map((c2) => c2.currency_code),
|
|
40605
|
-
regions,
|
|
40606
|
-
pricePreferences,
|
|
40607
|
-
getFieldName: (context, value) => {
|
|
40608
|
-
return `variants.${context.row.index}.prices.${value}`;
|
|
40609
|
-
}
|
|
40610
|
-
})
|
|
40611
|
-
];
|
|
40612
|
-
}, [currencies2, regions, pricePreferences]);
|
|
40613
|
-
};
|
|
40614
|
-
const UpdateDenominationPricesSchema = zod__namespace.object({
|
|
40615
|
-
variants: zod__namespace.array(
|
|
40616
|
-
zod__namespace.object({
|
|
40617
|
-
prices: zod__namespace.record(zod__namespace.string(), zod__namespace.string().or(zod__namespace.number()).optional()).optional()
|
|
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()
|
|
40618
40421
|
})
|
|
40619
|
-
)
|
|
40422
|
+
).min(1)
|
|
40620
40423
|
});
|
|
40621
|
-
const
|
|
40622
|
-
product
|
|
40623
|
-
variantId
|
|
40424
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
40425
|
+
product
|
|
40624
40426
|
}) => {
|
|
40625
40427
|
var _a2;
|
|
40626
40428
|
const { handleSuccess } = useRouteModal();
|
|
40627
|
-
const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
|
|
40628
|
-
const { regions } = useRegions({ limit: 9999 });
|
|
40629
|
-
const regionsCurrencyMap = React.useMemo(() => {
|
|
40630
|
-
if (!(regions == null ? void 0 : regions.length)) {
|
|
40631
|
-
return {};
|
|
40632
|
-
}
|
|
40633
|
-
return regions.reduce((acc, reg) => {
|
|
40634
|
-
acc[reg.id] = reg.currency_code;
|
|
40635
|
-
return acc;
|
|
40636
|
-
}, {});
|
|
40637
|
-
}, [regions]);
|
|
40638
|
-
const variants = variantId ? (_a2 = product.variants) == null ? void 0 : _a2.filter((v) => v.id === variantId) : product.variants;
|
|
40639
40429
|
const form = useForm({
|
|
40640
40430
|
defaultValues: {
|
|
40641
|
-
|
|
40642
|
-
|
|
40643
|
-
|
|
40644
|
-
var _a3;
|
|
40645
|
-
if ((_a3 = price.rules) == null ? void 0 : _a3.region_id) {
|
|
40646
|
-
acc[price.rules.region_id] = price.amount;
|
|
40647
|
-
} else {
|
|
40648
|
-
acc[price.currency_code] = price.amount;
|
|
40649
|
-
}
|
|
40650
|
-
return acc;
|
|
40651
|
-
}, {})
|
|
40431
|
+
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40432
|
+
id: variant.id,
|
|
40433
|
+
value: variant.title
|
|
40652
40434
|
}))
|
|
40653
40435
|
},
|
|
40654
|
-
resolver: t(
|
|
40436
|
+
resolver: t(EditProductSchema)
|
|
40655
40437
|
});
|
|
40656
|
-
const
|
|
40657
|
-
|
|
40658
|
-
|
|
40659
|
-
|
|
40660
|
-
|
|
40661
|
-
|
|
40662
|
-
|
|
40663
|
-
|
|
40664
|
-
|
|
40665
|
-
|
|
40666
|
-
|
|
40667
|
-
|
|
40668
|
-
|
|
40669
|
-
|
|
40670
|
-
|
|
40671
|
-
|
|
40672
|
-
|
|
40673
|
-
|
|
40674
|
-
|
|
40675
|
-
|
|
40676
|
-
)) == null ? void 0 : _f.id;
|
|
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
|
|
40677
40458
|
}
|
|
40678
|
-
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40682
|
-
|
|
40683
|
-
|
|
40684
|
-
|
|
40685
|
-
|
|
40686
|
-
|
|
40687
|
-
|
|
40688
|
-
await mutateAsync(reqData, {
|
|
40689
|
-
onSuccess: () => {
|
|
40690
|
-
handleSuccess("..");
|
|
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
|
+
}
|
|
40691
40469
|
}
|
|
40692
|
-
|
|
40470
|
+
);
|
|
40693
40471
|
});
|
|
40694
|
-
|
|
40695
|
-
|
|
40696
|
-
|
|
40697
|
-
|
|
40698
|
-
|
|
40699
|
-
|
|
40700
|
-
|
|
40701
|
-
|
|
40702
|
-
|
|
40703
|
-
|
|
40704
|
-
|
|
40705
|
-
|
|
40706
|
-
|
|
40707
|
-
|
|
40708
|
-
|
|
40709
|
-
|
|
40710
|
-
|
|
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
|
+
}),
|
|
40525
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40526
|
+
ui.Button,
|
|
40527
|
+
{
|
|
40528
|
+
size: "small",
|
|
40529
|
+
variant: "secondary",
|
|
40530
|
+
type: "button",
|
|
40531
|
+
className: "w-full",
|
|
40532
|
+
onClick: () => {
|
|
40533
|
+
addDenomination({ value: "", prices: {} });
|
|
40534
|
+
},
|
|
40535
|
+
children: "Add denomination"
|
|
40536
|
+
}
|
|
40537
|
+
),
|
|
40538
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40539
|
+
] }) }) }) }),
|
|
40540
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40541
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40542
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40543
|
+
] }) })
|
|
40544
|
+
]
|
|
40545
|
+
}
|
|
40546
|
+
) });
|
|
40711
40547
|
};
|
|
40712
|
-
const
|
|
40713
|
-
const { id
|
|
40714
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
40548
|
+
const GiftCardProductEdit = () => {
|
|
40549
|
+
const { id } = reactRouterDom.useParams();
|
|
40550
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40715
40551
|
if (isError) {
|
|
40716
40552
|
throw error;
|
|
40717
40553
|
}
|
|
40718
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
40554
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40555
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40556
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
40557
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40558
|
+
] }),
|
|
40559
|
+
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40560
|
+
] });
|
|
40719
40561
|
};
|
|
40720
40562
|
const EditProductMediaForm = ({ product }) => {
|
|
40721
40563
|
const [selection, setSelection] = React.useState({});
|
|
@@ -41330,6 +41172,164 @@ const ProductMedia = () => {
|
|
|
41330
41172
|
ready && /* @__PURE__ */ jsxRuntime.jsx(ProductMediaView, { product })
|
|
41331
41173
|
] });
|
|
41332
41174
|
};
|
|
41175
|
+
const VariantPricingForm = ({ form }) => {
|
|
41176
|
+
const { store } = useStore$2();
|
|
41177
|
+
const { regions } = useRegions({ limit: 9999 });
|
|
41178
|
+
const { price_preferences: pricePreferences } = usePricePreferences({});
|
|
41179
|
+
const { setCloseOnEscape } = useRouteModal();
|
|
41180
|
+
const columns = useVariantPriceGridColumns({
|
|
41181
|
+
currencies: store == null ? void 0 : store.supported_currencies,
|
|
41182
|
+
regions,
|
|
41183
|
+
pricePreferences
|
|
41184
|
+
});
|
|
41185
|
+
const variants = useWatch({
|
|
41186
|
+
control: form.control,
|
|
41187
|
+
name: "variants"
|
|
41188
|
+
});
|
|
41189
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
41190
|
+
DataGrid,
|
|
41191
|
+
{
|
|
41192
|
+
columns,
|
|
41193
|
+
data: variants,
|
|
41194
|
+
state: form,
|
|
41195
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
41196
|
+
}
|
|
41197
|
+
);
|
|
41198
|
+
};
|
|
41199
|
+
const columnHelper$1 = createDataGridHelper();
|
|
41200
|
+
const useVariantPriceGridColumns = ({
|
|
41201
|
+
currencies: currencies2 = [],
|
|
41202
|
+
regions = [],
|
|
41203
|
+
pricePreferences = []
|
|
41204
|
+
}) => {
|
|
41205
|
+
return React.useMemo(() => {
|
|
41206
|
+
return [
|
|
41207
|
+
columnHelper$1.column({
|
|
41208
|
+
id: "Title",
|
|
41209
|
+
header: "Title",
|
|
41210
|
+
cell: (context) => {
|
|
41211
|
+
const entity = context.row.original;
|
|
41212
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: entity.title }) }) });
|
|
41213
|
+
},
|
|
41214
|
+
disableHiding: true
|
|
41215
|
+
}),
|
|
41216
|
+
...createDataGridPriceColumns({
|
|
41217
|
+
currencies: currencies2.map((c2) => c2.currency_code),
|
|
41218
|
+
regions,
|
|
41219
|
+
pricePreferences,
|
|
41220
|
+
getFieldName: (context, value) => {
|
|
41221
|
+
return `variants.${context.row.index}.prices.${value}`;
|
|
41222
|
+
}
|
|
41223
|
+
})
|
|
41224
|
+
];
|
|
41225
|
+
}, [currencies2, regions, pricePreferences]);
|
|
41226
|
+
};
|
|
41227
|
+
const UpdateDenominationPricesSchema = zod__namespace.object({
|
|
41228
|
+
variants: zod__namespace.array(
|
|
41229
|
+
zod__namespace.object({
|
|
41230
|
+
prices: zod__namespace.record(zod__namespace.string(), zod__namespace.string().or(zod__namespace.number()).optional()).optional()
|
|
41231
|
+
})
|
|
41232
|
+
)
|
|
41233
|
+
});
|
|
41234
|
+
const PricingEdit = ({
|
|
41235
|
+
product,
|
|
41236
|
+
variantId
|
|
41237
|
+
}) => {
|
|
41238
|
+
var _a2;
|
|
41239
|
+
const { handleSuccess } = useRouteModal();
|
|
41240
|
+
const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
|
|
41241
|
+
const { regions } = useRegions({ limit: 9999 });
|
|
41242
|
+
const regionsCurrencyMap = React.useMemo(() => {
|
|
41243
|
+
if (!(regions == null ? void 0 : regions.length)) {
|
|
41244
|
+
return {};
|
|
41245
|
+
}
|
|
41246
|
+
return regions.reduce((acc, reg) => {
|
|
41247
|
+
acc[reg.id] = reg.currency_code;
|
|
41248
|
+
return acc;
|
|
41249
|
+
}, {});
|
|
41250
|
+
}, [regions]);
|
|
41251
|
+
const variants = variantId ? (_a2 = product.variants) == null ? void 0 : _a2.filter((v) => v.id === variantId) : product.variants;
|
|
41252
|
+
const form = useForm({
|
|
41253
|
+
defaultValues: {
|
|
41254
|
+
variants: variants == null ? void 0 : variants.map((variant) => ({
|
|
41255
|
+
title: variant.title,
|
|
41256
|
+
prices: variant.prices.reduce((acc, price) => {
|
|
41257
|
+
var _a3;
|
|
41258
|
+
if ((_a3 = price.rules) == null ? void 0 : _a3.region_id) {
|
|
41259
|
+
acc[price.rules.region_id] = price.amount;
|
|
41260
|
+
} else {
|
|
41261
|
+
acc[price.currency_code] = price.amount;
|
|
41262
|
+
}
|
|
41263
|
+
return acc;
|
|
41264
|
+
}, {})
|
|
41265
|
+
}))
|
|
41266
|
+
},
|
|
41267
|
+
resolver: t(UpdateDenominationPricesSchema, {})
|
|
41268
|
+
});
|
|
41269
|
+
const handleSubmit = form.handleSubmit(async (values) => {
|
|
41270
|
+
const reqData = values.variants.map((variant, ind) => {
|
|
41271
|
+
var _a3;
|
|
41272
|
+
return {
|
|
41273
|
+
id: (_a3 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a3.id,
|
|
41274
|
+
prices: Object.entries(variant.prices || {}).filter(
|
|
41275
|
+
([_, value]) => value !== "" && typeof value !== "undefined"
|
|
41276
|
+
// deleted cells
|
|
41277
|
+
).map(([currencyCodeOrRegionId, value]) => {
|
|
41278
|
+
var _a4, _b, _c, _d, _e, _f;
|
|
41279
|
+
const regionId = currencyCodeOrRegionId.startsWith("reg_") ? currencyCodeOrRegionId : void 0;
|
|
41280
|
+
const currencyCode = currencyCodeOrRegionId.startsWith("reg_") ? regionsCurrencyMap[regionId] : currencyCodeOrRegionId;
|
|
41281
|
+
let existingId = void 0;
|
|
41282
|
+
if (regionId) {
|
|
41283
|
+
existingId = (_c = (_b = (_a4 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a4.prices) == null ? void 0 : _b.find(
|
|
41284
|
+
(p) => p.rules["region_id"] === regionId
|
|
41285
|
+
)) == null ? void 0 : _c.id;
|
|
41286
|
+
} else {
|
|
41287
|
+
existingId = (_f = (_e = (_d = variants == null ? void 0 : variants[ind]) == null ? void 0 : _d.prices) == null ? void 0 : _e.find(
|
|
41288
|
+
(p) => p.currency_code === currencyCode && Object.keys(p.rules ?? {}).length === 0
|
|
41289
|
+
)) == null ? void 0 : _f.id;
|
|
41290
|
+
}
|
|
41291
|
+
const amount = castNumber(value);
|
|
41292
|
+
return {
|
|
41293
|
+
id: existingId,
|
|
41294
|
+
currency_code: currencyCode,
|
|
41295
|
+
amount,
|
|
41296
|
+
...regionId ? { rules: { region_id: regionId } } : {}
|
|
41297
|
+
};
|
|
41298
|
+
})
|
|
41299
|
+
};
|
|
41300
|
+
});
|
|
41301
|
+
await mutateAsync(reqData, {
|
|
41302
|
+
onSuccess: () => {
|
|
41303
|
+
handleSuccess("..");
|
|
41304
|
+
}
|
|
41305
|
+
});
|
|
41306
|
+
});
|
|
41307
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex size-full flex-col", children: [
|
|
41308
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41309
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(VariantPricingForm, { form }) }),
|
|
41310
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-end gap-x-2", children: [
|
|
41311
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
41312
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
41313
|
+
ui.Button,
|
|
41314
|
+
{
|
|
41315
|
+
type: "submit",
|
|
41316
|
+
variant: "primary",
|
|
41317
|
+
size: "small",
|
|
41318
|
+
isLoading: isPending,
|
|
41319
|
+
children: "Save"
|
|
41320
|
+
}
|
|
41321
|
+
)
|
|
41322
|
+
] }) })
|
|
41323
|
+
] }) });
|
|
41324
|
+
};
|
|
41325
|
+
const ProductPrices = () => {
|
|
41326
|
+
const { id, variant_id } = reactRouterDom.useParams();
|
|
41327
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
41328
|
+
if (isError) {
|
|
41329
|
+
throw error;
|
|
41330
|
+
}
|
|
41331
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41332
|
+
};
|
|
41333
41333
|
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41334
41334
|
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41335
41335
|
});
|
|
@@ -41476,13 +41476,13 @@ const routeModule = {
|
|
|
41476
41476
|
Component: GiftCardDetailsPage,
|
|
41477
41477
|
path: "/gift-cards/:id",
|
|
41478
41478
|
children: [
|
|
41479
|
-
{
|
|
41480
|
-
Component: Note$1,
|
|
41481
|
-
path: "/gift-cards/:id/note"
|
|
41482
|
-
},
|
|
41483
41479
|
{
|
|
41484
41480
|
Component: GiftCardExpiration,
|
|
41485
41481
|
path: "/gift-cards/:id/expiration"
|
|
41482
|
+
},
|
|
41483
|
+
{
|
|
41484
|
+
Component: Note$1,
|
|
41485
|
+
path: "/gift-cards/:id/note"
|
|
41486
41486
|
}
|
|
41487
41487
|
]
|
|
41488
41488
|
},
|
|
@@ -41512,22 +41512,22 @@ 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/edit"
|
|
41516
41516
|
},
|
|
41517
41517
|
{
|
|
41518
41518
|
Component: GiftCardProductEdit,
|
|
41519
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41519
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41520
41520
|
}
|
|
41521
41521
|
]
|
|
41522
41522
|
},
|
|
41523
|
-
{
|
|
41524
|
-
Component: ProductPrices,
|
|
41525
|
-
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41526
|
-
},
|
|
41527
41523
|
{
|
|
41528
41524
|
Component: ProductMedia,
|
|
41529
41525
|
path: "/gift-cards/gift-card-products/:id/media"
|
|
41530
41526
|
},
|
|
41527
|
+
{
|
|
41528
|
+
Component: ProductPrices,
|
|
41529
|
+
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41530
|
+
},
|
|
41531
41531
|
{
|
|
41532
41532
|
Component: ProductSalesChannels,
|
|
41533
41533
|
path: "/gift-cards/gift-card-products/:id/sales-channels"
|