@medusajs/loyalty-plugin 2.15.2 → 2.15.3-preview-20260514122911
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 +224 -224
- package/.medusa/server/src/admin/index.mjs +224 -224
- 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,153 +40239,6 @@ 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({
|
|
40389
40242
|
status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40390
40243
|
title: zod.z.string().min(1),
|
|
40391
40244
|
subtitle: zod.z.string().optional(),
|
|
@@ -40404,7 +40257,7 @@ const GiftCardProductEditForm = ({
|
|
|
40404
40257
|
handle: product.handle || "",
|
|
40405
40258
|
description: product.description || ""
|
|
40406
40259
|
},
|
|
40407
|
-
resolver: t(EditProductSchema)
|
|
40260
|
+
resolver: t(EditProductSchema$1)
|
|
40408
40261
|
});
|
|
40409
40262
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40410
40263
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -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,6 +40412,153 @@ const GiftCardProductEdit = () => {
|
|
|
40559
40412
|
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40560
40413
|
] });
|
|
40561
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
|
+
}),
|
|
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
|
+
) });
|
|
40547
|
+
};
|
|
40548
|
+
const GiftCardProductEdit = () => {
|
|
40549
|
+
const { id } = reactRouterDom.useParams();
|
|
40550
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40551
|
+
if (isError) {
|
|
40552
|
+
throw error;
|
|
40553
|
+
}
|
|
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
|
+
] });
|
|
40561
|
+
};
|
|
40562
40562
|
const EditProductMediaForm = ({ product }) => {
|
|
40563
40563
|
const [selection, setSelection] = React.useState({});
|
|
40564
40564
|
const { handleSuccess } = useRouteModal();
|
|
@@ -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,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/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
|
},
|
|
@@ -25914,73 +25914,6 @@ const KeyboundForm = React__default.forwardRef(({ onSubmit, onKeyDown, ...rest }
|
|
|
25914
25914
|
);
|
|
25915
25915
|
});
|
|
25916
25916
|
KeyboundForm.displayName = "KeyboundForm";
|
|
25917
|
-
const Note$1 = () => {
|
|
25918
|
-
const { id } = useParams();
|
|
25919
|
-
const {
|
|
25920
|
-
gift_card: giftCard,
|
|
25921
|
-
isPending,
|
|
25922
|
-
isError,
|
|
25923
|
-
error
|
|
25924
|
-
} = useGiftCard(id, {});
|
|
25925
|
-
if (isError) {
|
|
25926
|
-
throw error;
|
|
25927
|
-
}
|
|
25928
|
-
const isReady = !isPending && !!giftCard;
|
|
25929
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
25930
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
25931
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
|
|
25932
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
25933
|
-
] }),
|
|
25934
|
-
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
25935
|
-
] });
|
|
25936
|
-
};
|
|
25937
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
25938
|
-
const form = useForm({
|
|
25939
|
-
defaultValues: {
|
|
25940
|
-
note: giftCard.note ?? ""
|
|
25941
|
-
},
|
|
25942
|
-
resolver: t(schema$2)
|
|
25943
|
-
});
|
|
25944
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
25945
|
-
const { handleSuccess } = useRouteModal();
|
|
25946
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
25947
|
-
await mutateAsync(
|
|
25948
|
-
{ note: data.note },
|
|
25949
|
-
{
|
|
25950
|
-
onSuccess: () => handleSuccess(),
|
|
25951
|
-
onError: (error) => toast.error(error.message)
|
|
25952
|
-
}
|
|
25953
|
-
);
|
|
25954
|
-
});
|
|
25955
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
25956
|
-
KeyboundForm,
|
|
25957
|
-
{
|
|
25958
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
25959
|
-
onSubmit,
|
|
25960
|
-
children: [
|
|
25961
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
25962
|
-
Form$2.Field,
|
|
25963
|
-
{
|
|
25964
|
-
control: form.control,
|
|
25965
|
-
name: "note",
|
|
25966
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
25967
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
25968
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
25969
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
25970
|
-
] })
|
|
25971
|
-
}
|
|
25972
|
-
) }),
|
|
25973
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
25974
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
25975
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
25976
|
-
] }) })
|
|
25977
|
-
]
|
|
25978
|
-
}
|
|
25979
|
-
) });
|
|
25980
|
-
};
|
|
25981
|
-
const schema$2 = z.object({
|
|
25982
|
-
note: z.string().optional()
|
|
25983
|
-
});
|
|
25984
25917
|
const GiftCardExpiration = () => {
|
|
25985
25918
|
const { id } = useParams();
|
|
25986
25919
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26001,7 +25934,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26001
25934
|
defaultValues: {
|
|
26002
25935
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26003
25936
|
},
|
|
26004
|
-
resolver: t(schema$
|
|
25937
|
+
resolver: t(schema$2)
|
|
26005
25938
|
});
|
|
26006
25939
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26007
25940
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26096,9 +26029,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26096
26029
|
}
|
|
26097
26030
|
) });
|
|
26098
26031
|
};
|
|
26099
|
-
const schema$
|
|
26032
|
+
const schema$2 = z.object({
|
|
26100
26033
|
expires_at: z.date().nullish()
|
|
26101
26034
|
});
|
|
26035
|
+
const Note$1 = () => {
|
|
26036
|
+
const { id } = useParams();
|
|
26037
|
+
const {
|
|
26038
|
+
gift_card: giftCard,
|
|
26039
|
+
isPending,
|
|
26040
|
+
isError,
|
|
26041
|
+
error
|
|
26042
|
+
} = useGiftCard(id, {});
|
|
26043
|
+
if (isError) {
|
|
26044
|
+
throw error;
|
|
26045
|
+
}
|
|
26046
|
+
const isReady = !isPending && !!giftCard;
|
|
26047
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
26048
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
26049
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
|
|
26050
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
26051
|
+
] }),
|
|
26052
|
+
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
26053
|
+
] });
|
|
26054
|
+
};
|
|
26055
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
26056
|
+
const form = useForm({
|
|
26057
|
+
defaultValues: {
|
|
26058
|
+
note: giftCard.note ?? ""
|
|
26059
|
+
},
|
|
26060
|
+
resolver: t(schema$1)
|
|
26061
|
+
});
|
|
26062
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26063
|
+
const { handleSuccess } = useRouteModal();
|
|
26064
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
26065
|
+
await mutateAsync(
|
|
26066
|
+
{ note: data.note },
|
|
26067
|
+
{
|
|
26068
|
+
onSuccess: () => handleSuccess(),
|
|
26069
|
+
onError: (error) => toast.error(error.message)
|
|
26070
|
+
}
|
|
26071
|
+
);
|
|
26072
|
+
});
|
|
26073
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
26074
|
+
KeyboundForm,
|
|
26075
|
+
{
|
|
26076
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
26077
|
+
onSubmit,
|
|
26078
|
+
children: [
|
|
26079
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
26080
|
+
Form$2.Field,
|
|
26081
|
+
{
|
|
26082
|
+
control: form.control,
|
|
26083
|
+
name: "note",
|
|
26084
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
26085
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
26086
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
26087
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
26088
|
+
] })
|
|
26089
|
+
}
|
|
26090
|
+
) }),
|
|
26091
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26092
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26093
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26094
|
+
] }) })
|
|
26095
|
+
]
|
|
26096
|
+
}
|
|
26097
|
+
) });
|
|
26098
|
+
};
|
|
26099
|
+
const schema$1 = z.object({
|
|
26100
|
+
note: z.string().optional()
|
|
26101
|
+
});
|
|
26102
26102
|
const columnHelper$7 = createColumnHelper();
|
|
26103
26103
|
const useGiftCardProductsTableColumns = () => {
|
|
26104
26104
|
return useMemo(
|
|
@@ -40219,153 +40219,6 @@ 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({
|
|
40369
40222
|
status: z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40370
40223
|
title: z.string().min(1),
|
|
40371
40224
|
subtitle: z.string().optional(),
|
|
@@ -40384,7 +40237,7 @@ const GiftCardProductEditForm = ({
|
|
|
40384
40237
|
handle: product.handle || "",
|
|
40385
40238
|
description: product.description || ""
|
|
40386
40239
|
},
|
|
40387
|
-
resolver: t(EditProductSchema)
|
|
40240
|
+
resolver: t(EditProductSchema$1)
|
|
40388
40241
|
});
|
|
40389
40242
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40390
40243
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -40525,7 +40378,7 @@ const GiftCardProductEditForm = ({
|
|
|
40525
40378
|
}
|
|
40526
40379
|
) });
|
|
40527
40380
|
};
|
|
40528
|
-
const GiftCardProductEdit = () => {
|
|
40381
|
+
const GiftCardProductEdit$1 = () => {
|
|
40529
40382
|
const { id } = useParams();
|
|
40530
40383
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40531
40384
|
if (isError) {
|
|
@@ -40539,6 +40392,153 @@ const GiftCardProductEdit = () => {
|
|
|
40539
40392
|
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
|
|
40540
40393
|
] });
|
|
40541
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
|
+
}),
|
|
40505
|
+
/* @__PURE__ */ jsx(
|
|
40506
|
+
Button,
|
|
40507
|
+
{
|
|
40508
|
+
size: "small",
|
|
40509
|
+
variant: "secondary",
|
|
40510
|
+
type: "button",
|
|
40511
|
+
className: "w-full",
|
|
40512
|
+
onClick: () => {
|
|
40513
|
+
addDenomination({ value: "", prices: {} });
|
|
40514
|
+
},
|
|
40515
|
+
children: "Add denomination"
|
|
40516
|
+
}
|
|
40517
|
+
),
|
|
40518
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40519
|
+
] }) }) }) }),
|
|
40520
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40521
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40522
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40523
|
+
] }) })
|
|
40524
|
+
]
|
|
40525
|
+
}
|
|
40526
|
+
) });
|
|
40527
|
+
};
|
|
40528
|
+
const GiftCardProductEdit = () => {
|
|
40529
|
+
const { id } = useParams();
|
|
40530
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40531
|
+
if (isError) {
|
|
40532
|
+
throw error;
|
|
40533
|
+
}
|
|
40534
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
40535
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
40536
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
|
|
40537
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40538
|
+
] }),
|
|
40539
|
+
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40540
|
+
] });
|
|
40541
|
+
};
|
|
40542
40542
|
const EditProductMediaForm = ({ product }) => {
|
|
40543
40543
|
const [selection, setSelection] = useState({});
|
|
40544
40544
|
const { handleSuccess } = useRouteModal();
|
|
@@ -41456,13 +41456,13 @@ const routeModule = {
|
|
|
41456
41456
|
Component: GiftCardDetailsPage,
|
|
41457
41457
|
path: "/gift-cards/:id",
|
|
41458
41458
|
children: [
|
|
41459
|
-
{
|
|
41460
|
-
Component: Note$1,
|
|
41461
|
-
path: "/gift-cards/:id/note"
|
|
41462
|
-
},
|
|
41463
41459
|
{
|
|
41464
41460
|
Component: GiftCardExpiration,
|
|
41465
41461
|
path: "/gift-cards/:id/expiration"
|
|
41462
|
+
},
|
|
41463
|
+
{
|
|
41464
|
+
Component: Note$1,
|
|
41465
|
+
path: "/gift-cards/:id/note"
|
|
41466
41466
|
}
|
|
41467
41467
|
]
|
|
41468
41468
|
},
|
|
@@ -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/edit"
|
|
41496
41496
|
},
|
|
41497
41497
|
{
|
|
41498
41498
|
Component: GiftCardProductEdit,
|
|
41499
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41499
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41500
41500
|
}
|
|
41501
41501
|
]
|
|
41502
41502
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/loyalty-plugin",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.3-preview-20260514122911",
|
|
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.3-preview-20260514122911",
|
|
53
|
+
"@medusajs/cli": "2.15.3-preview-20260514122911",
|
|
54
|
+
"@medusajs/framework": "2.15.3-preview-20260514122911",
|
|
55
|
+
"@medusajs/icons": "2.15.3-preview-20260514122911",
|
|
56
|
+
"@medusajs/test-utils": "2.15.3-preview-20260514122911",
|
|
57
|
+
"@medusajs/types": "2.15.3-preview-20260514122911",
|
|
58
|
+
"@medusajs/ui": "4.1.13-preview-20260514122911",
|
|
59
|
+
"@medusajs/ui-preset": "2.15.3-preview-20260514122911",
|
|
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.3-preview-20260514122911",
|
|
68
|
+
"@medusajs/cli": "2.15.3-preview-20260514122911",
|
|
69
|
+
"@medusajs/framework": "2.15.3-preview-20260514122911",
|
|
70
|
+
"@medusajs/icons": "2.15.3-preview-20260514122911",
|
|
71
|
+
"@medusajs/test-utils": "2.15.3-preview-20260514122911",
|
|
72
|
+
"@medusajs/ui": "4.1.13-preview-20260514122911",
|
|
73
73
|
"react": "^18.3.1",
|
|
74
74
|
"react-dom": "^18.3.1",
|
|
75
75
|
"react-router-dom": "6.30.3"
|