@medusajs/loyalty-plugin 2.16.1-snapshot-20260624095924 → 2.17.0
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 +17 -17
|
@@ -25947,73 +25947,6 @@ const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown,
|
|
|
25947
25947
|
);
|
|
25948
25948
|
});
|
|
25949
25949
|
KeyboundForm.displayName = "KeyboundForm";
|
|
25950
|
-
const Note$1 = () => {
|
|
25951
|
-
const { id } = reactRouterDom.useParams();
|
|
25952
|
-
const {
|
|
25953
|
-
gift_card: giftCard,
|
|
25954
|
-
isPending,
|
|
25955
|
-
isError,
|
|
25956
|
-
error
|
|
25957
|
-
} = useGiftCard(id, {});
|
|
25958
|
-
if (isError) {
|
|
25959
|
-
throw error;
|
|
25960
|
-
}
|
|
25961
|
-
const isReady = !isPending && !!giftCard;
|
|
25962
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
25963
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
25964
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
25965
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
25966
|
-
] }),
|
|
25967
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
25968
|
-
] });
|
|
25969
|
-
};
|
|
25970
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
25971
|
-
const form = useForm({
|
|
25972
|
-
defaultValues: {
|
|
25973
|
-
note: giftCard.note ?? ""
|
|
25974
|
-
},
|
|
25975
|
-
resolver: t(schema$2)
|
|
25976
|
-
});
|
|
25977
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
25978
|
-
const { handleSuccess } = useRouteModal();
|
|
25979
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
25980
|
-
await mutateAsync(
|
|
25981
|
-
{ note: data.note },
|
|
25982
|
-
{
|
|
25983
|
-
onSuccess: () => handleSuccess(),
|
|
25984
|
-
onError: (error) => ui.toast.error(error.message)
|
|
25985
|
-
}
|
|
25986
|
-
);
|
|
25987
|
-
});
|
|
25988
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
25989
|
-
KeyboundForm,
|
|
25990
|
-
{
|
|
25991
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
25992
|
-
onSubmit,
|
|
25993
|
-
children: [
|
|
25994
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25995
|
-
Form$2.Field,
|
|
25996
|
-
{
|
|
25997
|
-
control: form.control,
|
|
25998
|
-
name: "note",
|
|
25999
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
26000
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
26001
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
26002
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
26003
|
-
] })
|
|
26004
|
-
}
|
|
26005
|
-
) }),
|
|
26006
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26007
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26008
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26009
|
-
] }) })
|
|
26010
|
-
]
|
|
26011
|
-
}
|
|
26012
|
-
) });
|
|
26013
|
-
};
|
|
26014
|
-
const schema$2 = zod.z.object({
|
|
26015
|
-
note: zod.z.string().optional()
|
|
26016
|
-
});
|
|
26017
25950
|
const GiftCardExpiration = () => {
|
|
26018
25951
|
const { id } = reactRouterDom.useParams();
|
|
26019
25952
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26034,7 +25967,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26034
25967
|
defaultValues: {
|
|
26035
25968
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26036
25969
|
},
|
|
26037
|
-
resolver: t(schema$
|
|
25970
|
+
resolver: t(schema$2)
|
|
26038
25971
|
});
|
|
26039
25972
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26040
25973
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26129,9 +26062,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26129
26062
|
}
|
|
26130
26063
|
) });
|
|
26131
26064
|
};
|
|
26132
|
-
const schema$
|
|
26065
|
+
const schema$2 = zod.z.object({
|
|
26133
26066
|
expires_at: zod.z.date().nullish()
|
|
26134
26067
|
});
|
|
26068
|
+
const Note$1 = () => {
|
|
26069
|
+
const { id } = reactRouterDom.useParams();
|
|
26070
|
+
const {
|
|
26071
|
+
gift_card: giftCard,
|
|
26072
|
+
isPending,
|
|
26073
|
+
isError,
|
|
26074
|
+
error
|
|
26075
|
+
} = useGiftCard(id, {});
|
|
26076
|
+
if (isError) {
|
|
26077
|
+
throw error;
|
|
26078
|
+
}
|
|
26079
|
+
const isReady = !isPending && !!giftCard;
|
|
26080
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
26081
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
26082
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
26083
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
26084
|
+
] }),
|
|
26085
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
26086
|
+
] });
|
|
26087
|
+
};
|
|
26088
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
26089
|
+
const form = useForm({
|
|
26090
|
+
defaultValues: {
|
|
26091
|
+
note: giftCard.note ?? ""
|
|
26092
|
+
},
|
|
26093
|
+
resolver: t(schema$1)
|
|
26094
|
+
});
|
|
26095
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26096
|
+
const { handleSuccess } = useRouteModal();
|
|
26097
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
26098
|
+
await mutateAsync(
|
|
26099
|
+
{ note: data.note },
|
|
26100
|
+
{
|
|
26101
|
+
onSuccess: () => handleSuccess(),
|
|
26102
|
+
onError: (error) => ui.toast.error(error.message)
|
|
26103
|
+
}
|
|
26104
|
+
);
|
|
26105
|
+
});
|
|
26106
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
26107
|
+
KeyboundForm,
|
|
26108
|
+
{
|
|
26109
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
26110
|
+
onSubmit,
|
|
26111
|
+
children: [
|
|
26112
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
26113
|
+
Form$2.Field,
|
|
26114
|
+
{
|
|
26115
|
+
control: form.control,
|
|
26116
|
+
name: "note",
|
|
26117
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
26118
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
26119
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
26120
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
26121
|
+
] })
|
|
26122
|
+
}
|
|
26123
|
+
) }),
|
|
26124
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26125
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26126
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26127
|
+
] }) })
|
|
26128
|
+
]
|
|
26129
|
+
}
|
|
26130
|
+
) });
|
|
26131
|
+
};
|
|
26132
|
+
const schema$1 = zod.z.object({
|
|
26133
|
+
note: zod.z.string().optional()
|
|
26134
|
+
});
|
|
26135
26135
|
const columnHelper$7 = createColumnHelper();
|
|
26136
26136
|
const useGiftCardProductsTableColumns = () => {
|
|
26137
26137
|
return React.useMemo(
|
|
@@ -40268,6 +40268,153 @@ const ProductDetail = () => {
|
|
|
40268
40268
|
);
|
|
40269
40269
|
};
|
|
40270
40270
|
const EditProductSchema$1 = zod.z.object({
|
|
40271
|
+
denominations: zod.z.array(
|
|
40272
|
+
zod.z.object({
|
|
40273
|
+
id: zod.z.string().optional(),
|
|
40274
|
+
value: zod.z.string().min(1),
|
|
40275
|
+
prices: zod.z.record(zod.z.string(), optionalFloat).optional()
|
|
40276
|
+
})
|
|
40277
|
+
).min(1)
|
|
40278
|
+
});
|
|
40279
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
40280
|
+
product
|
|
40281
|
+
}) => {
|
|
40282
|
+
var _a2;
|
|
40283
|
+
const { handleSuccess } = useRouteModal();
|
|
40284
|
+
const form = useForm({
|
|
40285
|
+
defaultValues: {
|
|
40286
|
+
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40287
|
+
id: variant.id,
|
|
40288
|
+
value: variant.title
|
|
40289
|
+
}))
|
|
40290
|
+
},
|
|
40291
|
+
resolver: t(EditProductSchema$1)
|
|
40292
|
+
});
|
|
40293
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40294
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40295
|
+
const optionValues = data.denominations.map(
|
|
40296
|
+
(denomination) => denomination.value
|
|
40297
|
+
);
|
|
40298
|
+
const options = [
|
|
40299
|
+
{
|
|
40300
|
+
title: "denomination",
|
|
40301
|
+
values: optionValues
|
|
40302
|
+
}
|
|
40303
|
+
];
|
|
40304
|
+
await mutateAsync(
|
|
40305
|
+
{
|
|
40306
|
+
options,
|
|
40307
|
+
variants: data.denominations.map((denomination) => ({
|
|
40308
|
+
id: denomination.id,
|
|
40309
|
+
title: denomination.value,
|
|
40310
|
+
manage_inventory: false,
|
|
40311
|
+
options: {
|
|
40312
|
+
denomination: denomination.value
|
|
40313
|
+
}
|
|
40314
|
+
}))
|
|
40315
|
+
},
|
|
40316
|
+
{
|
|
40317
|
+
onSuccess: () => {
|
|
40318
|
+
ui.toast.success(`Denominations updated successfully`);
|
|
40319
|
+
handleSuccess();
|
|
40320
|
+
},
|
|
40321
|
+
onError: (e2) => {
|
|
40322
|
+
ui.toast.error(e2.message);
|
|
40323
|
+
}
|
|
40324
|
+
}
|
|
40325
|
+
);
|
|
40326
|
+
});
|
|
40327
|
+
const {
|
|
40328
|
+
fields: denominationsFields,
|
|
40329
|
+
append: addDenomination,
|
|
40330
|
+
remove: removeDenomination
|
|
40331
|
+
} = useFieldArray({
|
|
40332
|
+
name: "denominations",
|
|
40333
|
+
control: form.control
|
|
40334
|
+
});
|
|
40335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40336
|
+
KeyboundForm,
|
|
40337
|
+
{
|
|
40338
|
+
onSubmit: handleSubmit,
|
|
40339
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
40340
|
+
children: [
|
|
40341
|
+
/* @__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: [
|
|
40342
|
+
denominationsFields.map((denominationField, index) => {
|
|
40343
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40344
|
+
"div",
|
|
40345
|
+
{
|
|
40346
|
+
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40347
|
+
children: [
|
|
40348
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40349
|
+
Form$2.Field,
|
|
40350
|
+
{
|
|
40351
|
+
control: form.control,
|
|
40352
|
+
name: `denominations.${index}.value`,
|
|
40353
|
+
render: ({ field }) => {
|
|
40354
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40355
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
40356
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40357
|
+
] });
|
|
40358
|
+
}
|
|
40359
|
+
},
|
|
40360
|
+
denominationField.id
|
|
40361
|
+
),
|
|
40362
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40363
|
+
ui.Button,
|
|
40364
|
+
{
|
|
40365
|
+
size: "small",
|
|
40366
|
+
variant: "secondary",
|
|
40367
|
+
type: "button",
|
|
40368
|
+
className: "ml-4 rounded-full p-0",
|
|
40369
|
+
onClick: () => {
|
|
40370
|
+
removeDenomination(index);
|
|
40371
|
+
},
|
|
40372
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
40373
|
+
}
|
|
40374
|
+
) })
|
|
40375
|
+
]
|
|
40376
|
+
},
|
|
40377
|
+
denominationField.id
|
|
40378
|
+
);
|
|
40379
|
+
}),
|
|
40380
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40381
|
+
ui.Button,
|
|
40382
|
+
{
|
|
40383
|
+
size: "small",
|
|
40384
|
+
variant: "secondary",
|
|
40385
|
+
type: "button",
|
|
40386
|
+
className: "w-full",
|
|
40387
|
+
onClick: () => {
|
|
40388
|
+
addDenomination({ value: "", prices: {} });
|
|
40389
|
+
},
|
|
40390
|
+
children: "Add denomination"
|
|
40391
|
+
}
|
|
40392
|
+
),
|
|
40393
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40394
|
+
] }) }) }) }),
|
|
40395
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40396
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40397
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40398
|
+
] }) })
|
|
40399
|
+
]
|
|
40400
|
+
}
|
|
40401
|
+
) });
|
|
40402
|
+
};
|
|
40403
|
+
const GiftCardProductEdit$1 = () => {
|
|
40404
|
+
const { id } = reactRouterDom.useParams();
|
|
40405
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40406
|
+
if (isError) {
|
|
40407
|
+
throw error;
|
|
40408
|
+
}
|
|
40409
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40410
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40411
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
40412
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40413
|
+
] }),
|
|
40414
|
+
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40415
|
+
] });
|
|
40416
|
+
};
|
|
40417
|
+
const EditProductSchema = zod.z.object({
|
|
40271
40418
|
status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40272
40419
|
title: zod.z.string().min(1),
|
|
40273
40420
|
subtitle: zod.z.string().optional(),
|
|
@@ -40286,7 +40433,7 @@ const GiftCardProductEditForm = ({
|
|
|
40286
40433
|
handle: product.handle || "",
|
|
40287
40434
|
description: product.description || ""
|
|
40288
40435
|
},
|
|
40289
|
-
resolver: t(EditProductSchema
|
|
40436
|
+
resolver: t(EditProductSchema)
|
|
40290
40437
|
});
|
|
40291
40438
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40292
40439
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -40427,7 +40574,7 @@ const GiftCardProductEditForm = ({
|
|
|
40427
40574
|
}
|
|
40428
40575
|
) });
|
|
40429
40576
|
};
|
|
40430
|
-
const GiftCardProductEdit
|
|
40577
|
+
const GiftCardProductEdit = () => {
|
|
40431
40578
|
const { id } = reactRouterDom.useParams();
|
|
40432
40579
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40433
40580
|
if (isError) {
|
|
@@ -40441,153 +40588,6 @@ const GiftCardProductEdit$1 = () => {
|
|
|
40441
40588
|
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40442
40589
|
] });
|
|
40443
40590
|
};
|
|
40444
|
-
const EditProductSchema = zod.z.object({
|
|
40445
|
-
denominations: zod.z.array(
|
|
40446
|
-
zod.z.object({
|
|
40447
|
-
id: zod.z.string().optional(),
|
|
40448
|
-
value: zod.z.string().min(1),
|
|
40449
|
-
prices: zod.z.record(zod.z.string(), optionalFloat).optional()
|
|
40450
|
-
})
|
|
40451
|
-
).min(1)
|
|
40452
|
-
});
|
|
40453
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
40454
|
-
product
|
|
40455
|
-
}) => {
|
|
40456
|
-
var _a2;
|
|
40457
|
-
const { handleSuccess } = useRouteModal();
|
|
40458
|
-
const form = useForm({
|
|
40459
|
-
defaultValues: {
|
|
40460
|
-
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40461
|
-
id: variant.id,
|
|
40462
|
-
value: variant.title
|
|
40463
|
-
}))
|
|
40464
|
-
},
|
|
40465
|
-
resolver: t(EditProductSchema)
|
|
40466
|
-
});
|
|
40467
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40468
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40469
|
-
const optionValues = data.denominations.map(
|
|
40470
|
-
(denomination) => denomination.value
|
|
40471
|
-
);
|
|
40472
|
-
const options = [
|
|
40473
|
-
{
|
|
40474
|
-
title: "denomination",
|
|
40475
|
-
values: optionValues
|
|
40476
|
-
}
|
|
40477
|
-
];
|
|
40478
|
-
await mutateAsync(
|
|
40479
|
-
{
|
|
40480
|
-
options,
|
|
40481
|
-
variants: data.denominations.map((denomination) => ({
|
|
40482
|
-
id: denomination.id,
|
|
40483
|
-
title: denomination.value,
|
|
40484
|
-
manage_inventory: false,
|
|
40485
|
-
options: {
|
|
40486
|
-
denomination: denomination.value
|
|
40487
|
-
}
|
|
40488
|
-
}))
|
|
40489
|
-
},
|
|
40490
|
-
{
|
|
40491
|
-
onSuccess: () => {
|
|
40492
|
-
ui.toast.success(`Denominations updated successfully`);
|
|
40493
|
-
handleSuccess();
|
|
40494
|
-
},
|
|
40495
|
-
onError: (e2) => {
|
|
40496
|
-
ui.toast.error(e2.message);
|
|
40497
|
-
}
|
|
40498
|
-
}
|
|
40499
|
-
);
|
|
40500
|
-
});
|
|
40501
|
-
const {
|
|
40502
|
-
fields: denominationsFields,
|
|
40503
|
-
append: addDenomination,
|
|
40504
|
-
remove: removeDenomination
|
|
40505
|
-
} = useFieldArray({
|
|
40506
|
-
name: "denominations",
|
|
40507
|
-
control: form.control
|
|
40508
|
-
});
|
|
40509
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40510
|
-
KeyboundForm,
|
|
40511
|
-
{
|
|
40512
|
-
onSubmit: handleSubmit,
|
|
40513
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
40514
|
-
children: [
|
|
40515
|
-
/* @__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: [
|
|
40516
|
-
denominationsFields.map((denominationField, index) => {
|
|
40517
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40518
|
-
"div",
|
|
40519
|
-
{
|
|
40520
|
-
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40521
|
-
children: [
|
|
40522
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40523
|
-
Form$2.Field,
|
|
40524
|
-
{
|
|
40525
|
-
control: form.control,
|
|
40526
|
-
name: `denominations.${index}.value`,
|
|
40527
|
-
render: ({ field }) => {
|
|
40528
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40529
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
40530
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40531
|
-
] });
|
|
40532
|
-
}
|
|
40533
|
-
},
|
|
40534
|
-
denominationField.id
|
|
40535
|
-
),
|
|
40536
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40537
|
-
ui.Button,
|
|
40538
|
-
{
|
|
40539
|
-
size: "small",
|
|
40540
|
-
variant: "secondary",
|
|
40541
|
-
type: "button",
|
|
40542
|
-
className: "ml-4 rounded-full p-0",
|
|
40543
|
-
onClick: () => {
|
|
40544
|
-
removeDenomination(index);
|
|
40545
|
-
},
|
|
40546
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
40547
|
-
}
|
|
40548
|
-
) })
|
|
40549
|
-
]
|
|
40550
|
-
},
|
|
40551
|
-
denominationField.id
|
|
40552
|
-
);
|
|
40553
|
-
}),
|
|
40554
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40555
|
-
ui.Button,
|
|
40556
|
-
{
|
|
40557
|
-
size: "small",
|
|
40558
|
-
variant: "secondary",
|
|
40559
|
-
type: "button",
|
|
40560
|
-
className: "w-full",
|
|
40561
|
-
onClick: () => {
|
|
40562
|
-
addDenomination({ value: "", prices: {} });
|
|
40563
|
-
},
|
|
40564
|
-
children: "Add denomination"
|
|
40565
|
-
}
|
|
40566
|
-
),
|
|
40567
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40568
|
-
] }) }) }) }),
|
|
40569
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40570
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40571
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40572
|
-
] }) })
|
|
40573
|
-
]
|
|
40574
|
-
}
|
|
40575
|
-
) });
|
|
40576
|
-
};
|
|
40577
|
-
const GiftCardProductEdit = () => {
|
|
40578
|
-
const { id } = reactRouterDom.useParams();
|
|
40579
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40580
|
-
if (isError) {
|
|
40581
|
-
throw error;
|
|
40582
|
-
}
|
|
40583
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40584
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40585
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
40586
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40587
|
-
] }),
|
|
40588
|
-
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40589
|
-
] });
|
|
40590
|
-
};
|
|
40591
40591
|
const EditProductMediaForm = ({ product }) => {
|
|
40592
40592
|
const [selection, setSelection] = React.useState({});
|
|
40593
40593
|
const { handleSuccess } = useRouteModal();
|
|
@@ -41505,13 +41505,13 @@ const routeModule = {
|
|
|
41505
41505
|
Component: GiftCardDetailsPage,
|
|
41506
41506
|
path: "/gift-cards/:id",
|
|
41507
41507
|
children: [
|
|
41508
|
-
{
|
|
41509
|
-
Component: Note$1,
|
|
41510
|
-
path: "/gift-cards/:id/note"
|
|
41511
|
-
},
|
|
41512
41508
|
{
|
|
41513
41509
|
Component: GiftCardExpiration,
|
|
41514
41510
|
path: "/gift-cards/:id/expiration"
|
|
41511
|
+
},
|
|
41512
|
+
{
|
|
41513
|
+
Component: Note$1,
|
|
41514
|
+
path: "/gift-cards/:id/note"
|
|
41515
41515
|
}
|
|
41516
41516
|
]
|
|
41517
41517
|
},
|
|
@@ -41541,11 +41541,11 @@ const routeModule = {
|
|
|
41541
41541
|
children: [
|
|
41542
41542
|
{
|
|
41543
41543
|
Component: GiftCardProductEdit$1,
|
|
41544
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41544
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41545
41545
|
},
|
|
41546
41546
|
{
|
|
41547
41547
|
Component: GiftCardProductEdit,
|
|
41548
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41548
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
41549
41549
|
}
|
|
41550
41550
|
]
|
|
41551
41551
|
},
|
|
@@ -25927,73 +25927,6 @@ const KeyboundForm = React__default.forwardRef(({ onSubmit, onKeyDown, ...rest }
|
|
|
25927
25927
|
);
|
|
25928
25928
|
});
|
|
25929
25929
|
KeyboundForm.displayName = "KeyboundForm";
|
|
25930
|
-
const Note$1 = () => {
|
|
25931
|
-
const { id } = useParams();
|
|
25932
|
-
const {
|
|
25933
|
-
gift_card: giftCard,
|
|
25934
|
-
isPending,
|
|
25935
|
-
isError,
|
|
25936
|
-
error
|
|
25937
|
-
} = useGiftCard(id, {});
|
|
25938
|
-
if (isError) {
|
|
25939
|
-
throw error;
|
|
25940
|
-
}
|
|
25941
|
-
const isReady = !isPending && !!giftCard;
|
|
25942
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
25943
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
25944
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
|
|
25945
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
25946
|
-
] }),
|
|
25947
|
-
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
25948
|
-
] });
|
|
25949
|
-
};
|
|
25950
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
25951
|
-
const form = useForm({
|
|
25952
|
-
defaultValues: {
|
|
25953
|
-
note: giftCard.note ?? ""
|
|
25954
|
-
},
|
|
25955
|
-
resolver: t(schema$2)
|
|
25956
|
-
});
|
|
25957
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
25958
|
-
const { handleSuccess } = useRouteModal();
|
|
25959
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
25960
|
-
await mutateAsync(
|
|
25961
|
-
{ note: data.note },
|
|
25962
|
-
{
|
|
25963
|
-
onSuccess: () => handleSuccess(),
|
|
25964
|
-
onError: (error) => toast.error(error.message)
|
|
25965
|
-
}
|
|
25966
|
-
);
|
|
25967
|
-
});
|
|
25968
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
25969
|
-
KeyboundForm,
|
|
25970
|
-
{
|
|
25971
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
25972
|
-
onSubmit,
|
|
25973
|
-
children: [
|
|
25974
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
25975
|
-
Form$2.Field,
|
|
25976
|
-
{
|
|
25977
|
-
control: form.control,
|
|
25978
|
-
name: "note",
|
|
25979
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
25980
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
25981
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
25982
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
25983
|
-
] })
|
|
25984
|
-
}
|
|
25985
|
-
) }),
|
|
25986
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
25987
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
25988
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
25989
|
-
] }) })
|
|
25990
|
-
]
|
|
25991
|
-
}
|
|
25992
|
-
) });
|
|
25993
|
-
};
|
|
25994
|
-
const schema$2 = z.object({
|
|
25995
|
-
note: z.string().optional()
|
|
25996
|
-
});
|
|
25997
25930
|
const GiftCardExpiration = () => {
|
|
25998
25931
|
const { id } = useParams();
|
|
25999
25932
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26014,7 +25947,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26014
25947
|
defaultValues: {
|
|
26015
25948
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26016
25949
|
},
|
|
26017
|
-
resolver: t(schema$
|
|
25950
|
+
resolver: t(schema$2)
|
|
26018
25951
|
});
|
|
26019
25952
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26020
25953
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26109,9 +26042,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26109
26042
|
}
|
|
26110
26043
|
) });
|
|
26111
26044
|
};
|
|
26112
|
-
const schema$
|
|
26045
|
+
const schema$2 = z.object({
|
|
26113
26046
|
expires_at: z.date().nullish()
|
|
26114
26047
|
});
|
|
26048
|
+
const Note$1 = () => {
|
|
26049
|
+
const { id } = useParams();
|
|
26050
|
+
const {
|
|
26051
|
+
gift_card: giftCard,
|
|
26052
|
+
isPending,
|
|
26053
|
+
isError,
|
|
26054
|
+
error
|
|
26055
|
+
} = useGiftCard(id, {});
|
|
26056
|
+
if (isError) {
|
|
26057
|
+
throw error;
|
|
26058
|
+
}
|
|
26059
|
+
const isReady = !isPending && !!giftCard;
|
|
26060
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
26061
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
26062
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
|
|
26063
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
26064
|
+
] }),
|
|
26065
|
+
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
26066
|
+
] });
|
|
26067
|
+
};
|
|
26068
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
26069
|
+
const form = useForm({
|
|
26070
|
+
defaultValues: {
|
|
26071
|
+
note: giftCard.note ?? ""
|
|
26072
|
+
},
|
|
26073
|
+
resolver: t(schema$1)
|
|
26074
|
+
});
|
|
26075
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26076
|
+
const { handleSuccess } = useRouteModal();
|
|
26077
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
26078
|
+
await mutateAsync(
|
|
26079
|
+
{ note: data.note },
|
|
26080
|
+
{
|
|
26081
|
+
onSuccess: () => handleSuccess(),
|
|
26082
|
+
onError: (error) => toast.error(error.message)
|
|
26083
|
+
}
|
|
26084
|
+
);
|
|
26085
|
+
});
|
|
26086
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
26087
|
+
KeyboundForm,
|
|
26088
|
+
{
|
|
26089
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
26090
|
+
onSubmit,
|
|
26091
|
+
children: [
|
|
26092
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
26093
|
+
Form$2.Field,
|
|
26094
|
+
{
|
|
26095
|
+
control: form.control,
|
|
26096
|
+
name: "note",
|
|
26097
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
26098
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
26099
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
26100
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
26101
|
+
] })
|
|
26102
|
+
}
|
|
26103
|
+
) }),
|
|
26104
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26105
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26106
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26107
|
+
] }) })
|
|
26108
|
+
]
|
|
26109
|
+
}
|
|
26110
|
+
) });
|
|
26111
|
+
};
|
|
26112
|
+
const schema$1 = z.object({
|
|
26113
|
+
note: z.string().optional()
|
|
26114
|
+
});
|
|
26115
26115
|
const columnHelper$7 = createColumnHelper();
|
|
26116
26116
|
const useGiftCardProductsTableColumns = () => {
|
|
26117
26117
|
return useMemo(
|
|
@@ -40248,6 +40248,153 @@ const ProductDetail = () => {
|
|
|
40248
40248
|
);
|
|
40249
40249
|
};
|
|
40250
40250
|
const EditProductSchema$1 = z.object({
|
|
40251
|
+
denominations: z.array(
|
|
40252
|
+
z.object({
|
|
40253
|
+
id: z.string().optional(),
|
|
40254
|
+
value: z.string().min(1),
|
|
40255
|
+
prices: z.record(z.string(), optionalFloat).optional()
|
|
40256
|
+
})
|
|
40257
|
+
).min(1)
|
|
40258
|
+
});
|
|
40259
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
40260
|
+
product
|
|
40261
|
+
}) => {
|
|
40262
|
+
var _a2;
|
|
40263
|
+
const { handleSuccess } = useRouteModal();
|
|
40264
|
+
const form = useForm({
|
|
40265
|
+
defaultValues: {
|
|
40266
|
+
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40267
|
+
id: variant.id,
|
|
40268
|
+
value: variant.title
|
|
40269
|
+
}))
|
|
40270
|
+
},
|
|
40271
|
+
resolver: t(EditProductSchema$1)
|
|
40272
|
+
});
|
|
40273
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40274
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40275
|
+
const optionValues = data.denominations.map(
|
|
40276
|
+
(denomination) => denomination.value
|
|
40277
|
+
);
|
|
40278
|
+
const options = [
|
|
40279
|
+
{
|
|
40280
|
+
title: "denomination",
|
|
40281
|
+
values: optionValues
|
|
40282
|
+
}
|
|
40283
|
+
];
|
|
40284
|
+
await mutateAsync(
|
|
40285
|
+
{
|
|
40286
|
+
options,
|
|
40287
|
+
variants: data.denominations.map((denomination) => ({
|
|
40288
|
+
id: denomination.id,
|
|
40289
|
+
title: denomination.value,
|
|
40290
|
+
manage_inventory: false,
|
|
40291
|
+
options: {
|
|
40292
|
+
denomination: denomination.value
|
|
40293
|
+
}
|
|
40294
|
+
}))
|
|
40295
|
+
},
|
|
40296
|
+
{
|
|
40297
|
+
onSuccess: () => {
|
|
40298
|
+
toast.success(`Denominations updated successfully`);
|
|
40299
|
+
handleSuccess();
|
|
40300
|
+
},
|
|
40301
|
+
onError: (e2) => {
|
|
40302
|
+
toast.error(e2.message);
|
|
40303
|
+
}
|
|
40304
|
+
}
|
|
40305
|
+
);
|
|
40306
|
+
});
|
|
40307
|
+
const {
|
|
40308
|
+
fields: denominationsFields,
|
|
40309
|
+
append: addDenomination,
|
|
40310
|
+
remove: removeDenomination
|
|
40311
|
+
} = useFieldArray({
|
|
40312
|
+
name: "denominations",
|
|
40313
|
+
control: form.control
|
|
40314
|
+
});
|
|
40315
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
40316
|
+
KeyboundForm,
|
|
40317
|
+
{
|
|
40318
|
+
onSubmit: handleSubmit,
|
|
40319
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
40320
|
+
children: [
|
|
40321
|
+
/* @__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: [
|
|
40322
|
+
denominationsFields.map((denominationField, index) => {
|
|
40323
|
+
return /* @__PURE__ */ jsxs(
|
|
40324
|
+
"div",
|
|
40325
|
+
{
|
|
40326
|
+
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40327
|
+
children: [
|
|
40328
|
+
/* @__PURE__ */ jsx(
|
|
40329
|
+
Form$2.Field,
|
|
40330
|
+
{
|
|
40331
|
+
control: form.control,
|
|
40332
|
+
name: `denominations.${index}.value`,
|
|
40333
|
+
render: ({ field }) => {
|
|
40334
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40335
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
|
|
40336
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40337
|
+
] });
|
|
40338
|
+
}
|
|
40339
|
+
},
|
|
40340
|
+
denominationField.id
|
|
40341
|
+
),
|
|
40342
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
40343
|
+
Button,
|
|
40344
|
+
{
|
|
40345
|
+
size: "small",
|
|
40346
|
+
variant: "secondary",
|
|
40347
|
+
type: "button",
|
|
40348
|
+
className: "ml-4 rounded-full p-0",
|
|
40349
|
+
onClick: () => {
|
|
40350
|
+
removeDenomination(index);
|
|
40351
|
+
},
|
|
40352
|
+
children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
|
|
40353
|
+
}
|
|
40354
|
+
) })
|
|
40355
|
+
]
|
|
40356
|
+
},
|
|
40357
|
+
denominationField.id
|
|
40358
|
+
);
|
|
40359
|
+
}),
|
|
40360
|
+
/* @__PURE__ */ jsx(
|
|
40361
|
+
Button,
|
|
40362
|
+
{
|
|
40363
|
+
size: "small",
|
|
40364
|
+
variant: "secondary",
|
|
40365
|
+
type: "button",
|
|
40366
|
+
className: "w-full",
|
|
40367
|
+
onClick: () => {
|
|
40368
|
+
addDenomination({ value: "", prices: {} });
|
|
40369
|
+
},
|
|
40370
|
+
children: "Add denomination"
|
|
40371
|
+
}
|
|
40372
|
+
),
|
|
40373
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40374
|
+
] }) }) }) }),
|
|
40375
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40376
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40377
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40378
|
+
] }) })
|
|
40379
|
+
]
|
|
40380
|
+
}
|
|
40381
|
+
) });
|
|
40382
|
+
};
|
|
40383
|
+
const GiftCardProductEdit$1 = () => {
|
|
40384
|
+
const { id } = useParams();
|
|
40385
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40386
|
+
if (isError) {
|
|
40387
|
+
throw error;
|
|
40388
|
+
}
|
|
40389
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
40390
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
40391
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
|
|
40392
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40393
|
+
] }),
|
|
40394
|
+
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40395
|
+
] });
|
|
40396
|
+
};
|
|
40397
|
+
const EditProductSchema = z.object({
|
|
40251
40398
|
status: z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40252
40399
|
title: z.string().min(1),
|
|
40253
40400
|
subtitle: z.string().optional(),
|
|
@@ -40266,7 +40413,7 @@ const GiftCardProductEditForm = ({
|
|
|
40266
40413
|
handle: product.handle || "",
|
|
40267
40414
|
description: product.description || ""
|
|
40268
40415
|
},
|
|
40269
|
-
resolver: t(EditProductSchema
|
|
40416
|
+
resolver: t(EditProductSchema)
|
|
40270
40417
|
});
|
|
40271
40418
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40272
40419
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -40407,7 +40554,7 @@ const GiftCardProductEditForm = ({
|
|
|
40407
40554
|
}
|
|
40408
40555
|
) });
|
|
40409
40556
|
};
|
|
40410
|
-
const GiftCardProductEdit
|
|
40557
|
+
const GiftCardProductEdit = () => {
|
|
40411
40558
|
const { id } = useParams();
|
|
40412
40559
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40413
40560
|
if (isError) {
|
|
@@ -40421,153 +40568,6 @@ const GiftCardProductEdit$1 = () => {
|
|
|
40421
40568
|
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
|
|
40422
40569
|
] });
|
|
40423
40570
|
};
|
|
40424
|
-
const EditProductSchema = z.object({
|
|
40425
|
-
denominations: z.array(
|
|
40426
|
-
z.object({
|
|
40427
|
-
id: z.string().optional(),
|
|
40428
|
-
value: z.string().min(1),
|
|
40429
|
-
prices: z.record(z.string(), optionalFloat).optional()
|
|
40430
|
-
})
|
|
40431
|
-
).min(1)
|
|
40432
|
-
});
|
|
40433
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
40434
|
-
product
|
|
40435
|
-
}) => {
|
|
40436
|
-
var _a2;
|
|
40437
|
-
const { handleSuccess } = useRouteModal();
|
|
40438
|
-
const form = useForm({
|
|
40439
|
-
defaultValues: {
|
|
40440
|
-
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40441
|
-
id: variant.id,
|
|
40442
|
-
value: variant.title
|
|
40443
|
-
}))
|
|
40444
|
-
},
|
|
40445
|
-
resolver: t(EditProductSchema)
|
|
40446
|
-
});
|
|
40447
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40448
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40449
|
-
const optionValues = data.denominations.map(
|
|
40450
|
-
(denomination) => denomination.value
|
|
40451
|
-
);
|
|
40452
|
-
const options = [
|
|
40453
|
-
{
|
|
40454
|
-
title: "denomination",
|
|
40455
|
-
values: optionValues
|
|
40456
|
-
}
|
|
40457
|
-
];
|
|
40458
|
-
await mutateAsync(
|
|
40459
|
-
{
|
|
40460
|
-
options,
|
|
40461
|
-
variants: data.denominations.map((denomination) => ({
|
|
40462
|
-
id: denomination.id,
|
|
40463
|
-
title: denomination.value,
|
|
40464
|
-
manage_inventory: false,
|
|
40465
|
-
options: {
|
|
40466
|
-
denomination: denomination.value
|
|
40467
|
-
}
|
|
40468
|
-
}))
|
|
40469
|
-
},
|
|
40470
|
-
{
|
|
40471
|
-
onSuccess: () => {
|
|
40472
|
-
toast.success(`Denominations updated successfully`);
|
|
40473
|
-
handleSuccess();
|
|
40474
|
-
},
|
|
40475
|
-
onError: (e2) => {
|
|
40476
|
-
toast.error(e2.message);
|
|
40477
|
-
}
|
|
40478
|
-
}
|
|
40479
|
-
);
|
|
40480
|
-
});
|
|
40481
|
-
const {
|
|
40482
|
-
fields: denominationsFields,
|
|
40483
|
-
append: addDenomination,
|
|
40484
|
-
remove: removeDenomination
|
|
40485
|
-
} = useFieldArray({
|
|
40486
|
-
name: "denominations",
|
|
40487
|
-
control: form.control
|
|
40488
|
-
});
|
|
40489
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
40490
|
-
KeyboundForm,
|
|
40491
|
-
{
|
|
40492
|
-
onSubmit: handleSubmit,
|
|
40493
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
40494
|
-
children: [
|
|
40495
|
-
/* @__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: [
|
|
40496
|
-
denominationsFields.map((denominationField, index) => {
|
|
40497
|
-
return /* @__PURE__ */ jsxs(
|
|
40498
|
-
"div",
|
|
40499
|
-
{
|
|
40500
|
-
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40501
|
-
children: [
|
|
40502
|
-
/* @__PURE__ */ jsx(
|
|
40503
|
-
Form$2.Field,
|
|
40504
|
-
{
|
|
40505
|
-
control: form.control,
|
|
40506
|
-
name: `denominations.${index}.value`,
|
|
40507
|
-
render: ({ field }) => {
|
|
40508
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40509
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
|
|
40510
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
40511
|
-
] });
|
|
40512
|
-
}
|
|
40513
|
-
},
|
|
40514
|
-
denominationField.id
|
|
40515
|
-
),
|
|
40516
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
40517
|
-
Button,
|
|
40518
|
-
{
|
|
40519
|
-
size: "small",
|
|
40520
|
-
variant: "secondary",
|
|
40521
|
-
type: "button",
|
|
40522
|
-
className: "ml-4 rounded-full p-0",
|
|
40523
|
-
onClick: () => {
|
|
40524
|
-
removeDenomination(index);
|
|
40525
|
-
},
|
|
40526
|
-
children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
|
|
40527
|
-
}
|
|
40528
|
-
) })
|
|
40529
|
-
]
|
|
40530
|
-
},
|
|
40531
|
-
denominationField.id
|
|
40532
|
-
);
|
|
40533
|
-
}),
|
|
40534
|
-
/* @__PURE__ */ jsx(
|
|
40535
|
-
Button,
|
|
40536
|
-
{
|
|
40537
|
-
size: "small",
|
|
40538
|
-
variant: "secondary",
|
|
40539
|
-
type: "button",
|
|
40540
|
-
className: "w-full",
|
|
40541
|
-
onClick: () => {
|
|
40542
|
-
addDenomination({ value: "", prices: {} });
|
|
40543
|
-
},
|
|
40544
|
-
children: "Add denomination"
|
|
40545
|
-
}
|
|
40546
|
-
),
|
|
40547
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40548
|
-
] }) }) }) }),
|
|
40549
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40550
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40551
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40552
|
-
] }) })
|
|
40553
|
-
]
|
|
40554
|
-
}
|
|
40555
|
-
) });
|
|
40556
|
-
};
|
|
40557
|
-
const GiftCardProductEdit = () => {
|
|
40558
|
-
const { id } = useParams();
|
|
40559
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40560
|
-
if (isError) {
|
|
40561
|
-
throw error;
|
|
40562
|
-
}
|
|
40563
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
40564
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
40565
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
|
|
40566
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40567
|
-
] }),
|
|
40568
|
-
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40569
|
-
] });
|
|
40570
|
-
};
|
|
40571
40571
|
const EditProductMediaForm = ({ product }) => {
|
|
40572
40572
|
const [selection, setSelection] = useState({});
|
|
40573
40573
|
const { handleSuccess } = useRouteModal();
|
|
@@ -41485,13 +41485,13 @@ const routeModule = {
|
|
|
41485
41485
|
Component: GiftCardDetailsPage,
|
|
41486
41486
|
path: "/gift-cards/:id",
|
|
41487
41487
|
children: [
|
|
41488
|
-
{
|
|
41489
|
-
Component: Note$1,
|
|
41490
|
-
path: "/gift-cards/:id/note"
|
|
41491
|
-
},
|
|
41492
41488
|
{
|
|
41493
41489
|
Component: GiftCardExpiration,
|
|
41494
41490
|
path: "/gift-cards/:id/expiration"
|
|
41491
|
+
},
|
|
41492
|
+
{
|
|
41493
|
+
Component: Note$1,
|
|
41494
|
+
path: "/gift-cards/:id/note"
|
|
41495
41495
|
}
|
|
41496
41496
|
]
|
|
41497
41497
|
},
|
|
@@ -41521,11 +41521,11 @@ const routeModule = {
|
|
|
41521
41521
|
children: [
|
|
41522
41522
|
{
|
|
41523
41523
|
Component: GiftCardProductEdit$1,
|
|
41524
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41524
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41525
41525
|
},
|
|
41526
41526
|
{
|
|
41527
41527
|
Component: GiftCardProductEdit,
|
|
41528
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41528
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
41529
41529
|
}
|
|
41530
41530
|
]
|
|
41531
41531
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/loyalty-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Medusa Plugin: Loyalty - Gift Cards",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"watch": "medusa plugin:develop"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@medusajs/admin-sdk": "2.
|
|
55
|
-
"@medusajs/cli": "2.
|
|
56
|
-
"@medusajs/dashboard": "2.
|
|
57
|
-
"@medusajs/framework": "2.
|
|
58
|
-
"@medusajs/icons": "2.
|
|
59
|
-
"@medusajs/test-utils": "2.
|
|
60
|
-
"@medusajs/types": "2.
|
|
61
|
-
"@medusajs/ui": "4.1.17
|
|
62
|
-
"@medusajs/ui-preset": "2.
|
|
54
|
+
"@medusajs/admin-sdk": "2.17.0",
|
|
55
|
+
"@medusajs/cli": "2.17.0",
|
|
56
|
+
"@medusajs/dashboard": "2.17.0",
|
|
57
|
+
"@medusajs/framework": "2.17.0",
|
|
58
|
+
"@medusajs/icons": "2.17.0",
|
|
59
|
+
"@medusajs/test-utils": "2.17.0",
|
|
60
|
+
"@medusajs/types": "2.17.0",
|
|
61
|
+
"@medusajs/ui": "4.1.17",
|
|
62
|
+
"@medusajs/ui-preset": "2.17.0",
|
|
63
63
|
"@swc/core": "1.5.7",
|
|
64
64
|
"@types/node": "^20.0.0",
|
|
65
65
|
"cross-env": "^7.0.3",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"typescript": "^5.7.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@medusajs/admin-sdk": "2.
|
|
71
|
-
"@medusajs/cli": "2.
|
|
72
|
-
"@medusajs/dashboard": "2.
|
|
73
|
-
"@medusajs/framework": "2.
|
|
74
|
-
"@medusajs/icons": "2.
|
|
75
|
-
"@medusajs/test-utils": "2.
|
|
76
|
-
"@medusajs/ui": "4.1.17
|
|
70
|
+
"@medusajs/admin-sdk": "2.17.0",
|
|
71
|
+
"@medusajs/cli": "2.17.0",
|
|
72
|
+
"@medusajs/dashboard": "2.17.0",
|
|
73
|
+
"@medusajs/framework": "2.17.0",
|
|
74
|
+
"@medusajs/icons": "2.17.0",
|
|
75
|
+
"@medusajs/test-utils": "2.17.0",
|
|
76
|
+
"@medusajs/ui": "4.1.17",
|
|
77
77
|
"react": "^18.3.1",
|
|
78
78
|
"react-dom": "^18.3.1",
|
|
79
79
|
"react-router-dom": "6.30.4"
|