@medusajs/loyalty-plugin 2.22.7-snapshot-20261113095001 → 2.22.7

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.
@@ -40170,185 +40170,8 @@ const ProductDetail = () => {
40170
40170
  const handle$5 = {
40171
40171
  permissions: ["product:read"]
40172
40172
  };
40173
- const EditProductSchema$1 = zod.z.object({
40174
- status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
40175
- title: zod.z.string().min(1),
40176
- subtitle: zod.z.string().optional(),
40177
- handle: zod.z.string().min(1),
40178
- description: zod.z.string().optional()
40179
- });
40180
- const GiftCardProductEditForm = ({
40181
- product
40182
- }) => {
40183
- const { handleSuccess } = useRouteModal();
40184
- const form = useForm({
40185
- defaultValues: {
40186
- status: product.status,
40187
- title: product.title,
40188
- subtitle: product.subtitle || "",
40189
- handle: product.handle || "",
40190
- description: product.description || ""
40191
- },
40192
- resolver: u(EditProductSchema$1)
40193
- });
40194
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
40195
- const handleSubmit = form.handleSubmit(async (data) => {
40196
- const { title, handle: handle2, status, ...optional } = data;
40197
- await mutateAsync(
40198
- {
40199
- ...optional,
40200
- title,
40201
- handle: handle2,
40202
- status
40203
- },
40204
- {
40205
- onSuccess: ({ product: product2 }) => {
40206
- ui.toast.success(
40207
- `Gift card product ${product2.title} updated successfully`
40208
- );
40209
- handleSuccess();
40210
- },
40211
- onError: (e) => {
40212
- ui.toast.error(e.message);
40213
- }
40214
- }
40215
- );
40216
- });
40217
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
40218
- KeyboundForm,
40219
- {
40220
- onSubmit: handleSubmit,
40221
- className: "flex flex-1 flex-col overflow-hidden",
40222
- children: [
40223
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
40224
- /* @__PURE__ */ jsxRuntime.jsx(
40225
- Form$2.Field,
40226
- {
40227
- control: form.control,
40228
- name: "status",
40229
- render: ({ field: { onChange, ref, ...field } }) => {
40230
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40231
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Status" }),
40232
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { ...field, onValueChange: onChange, children: [
40233
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
40234
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: [
40235
- "draft",
40236
- "published",
40237
- "proposed",
40238
- "rejected"
40239
- ].map((status) => {
40240
- return /* @__PURE__ */ jsxRuntime.jsx(
40241
- ui.Select.Item,
40242
- {
40243
- value: status,
40244
- className: "capitalize",
40245
- children: status
40246
- },
40247
- status
40248
- );
40249
- }) })
40250
- ] }) }),
40251
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40252
- ] });
40253
- }
40254
- }
40255
- ),
40256
- /* @__PURE__ */ jsxRuntime.jsx(
40257
- Form$2.Field,
40258
- {
40259
- control: form.control,
40260
- name: "title",
40261
- render: ({ field }) => {
40262
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40263
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
40264
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
40265
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40266
- ] });
40267
- }
40268
- }
40269
- ),
40270
- /* @__PURE__ */ jsxRuntime.jsx(
40271
- Form$2.Field,
40272
- {
40273
- control: form.control,
40274
- name: "subtitle",
40275
- render: ({ field }) => {
40276
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40277
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
40278
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
40279
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40280
- ] });
40281
- }
40282
- }
40283
- ),
40284
- /* @__PURE__ */ jsxRuntime.jsx(
40285
- Form$2.Field,
40286
- {
40287
- control: form.control,
40288
- name: "handle",
40289
- render: ({ field }) => {
40290
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40291
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Handle" }),
40292
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
40293
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsxRuntime.jsx(
40294
- ui.Text,
40295
- {
40296
- className: "text-ui-fg-muted",
40297
- size: "small",
40298
- leading: "compact",
40299
- weight: "plus",
40300
- children: "/"
40301
- }
40302
- ) }),
40303
- /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, className: "pl-10" })
40304
- ] }) }),
40305
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40306
- ] });
40307
- }
40308
- }
40309
- ),
40310
- /* @__PURE__ */ jsxRuntime.jsx(
40311
- Form$2.Field,
40312
- {
40313
- control: form.control,
40314
- name: "description",
40315
- render: ({ field }) => {
40316
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40317
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Description" }),
40318
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
40319
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40320
- ] });
40321
- }
40322
- }
40323
- )
40324
- ] }) }) }),
40325
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
40326
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
40327
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
40328
- ] }) })
40329
- ]
40330
- }
40331
- ) });
40332
- };
40333
- const GiftCardProductEdit$1 = () => {
40334
- const { id } = reactRouterDom.useParams();
40335
- const { product, isLoading, isError, error } = useProduct(id, {});
40336
- if (isError) {
40337
- throw error;
40338
- }
40339
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
40340
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
40341
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift card product" }) }),
40342
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
40343
- ] }),
40344
- !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
40345
- ] });
40346
- };
40347
- const handle$4 = {
40348
- permissions: ["product:read", "product:update"]
40349
- };
40350
40173
  const DENOMINATION_OPTION_TITLE = "denomination";
40351
- const EditProductSchema = zod.z.object({
40174
+ const EditProductSchema$1 = zod.z.object({
40352
40175
  denominations: zod.z.array(
40353
40176
  zod.z.object({
40354
40177
  id: zod.z.string().optional(),
@@ -40368,7 +40191,7 @@ const GiftCardProductEditDenominationsForm = ({
40368
40191
  value: variant.title
40369
40192
  }))
40370
40193
  },
40371
- resolver: u(EditProductSchema)
40194
+ resolver: u(EditProductSchema$1)
40372
40195
  });
40373
40196
  const denominationOption = product.options?.find(
40374
40197
  (option) => option.title === DENOMINATION_OPTION_TITLE
@@ -40510,7 +40333,7 @@ const GiftCardProductEditDenominationsForm = ({
40510
40333
  }
40511
40334
  ) });
40512
40335
  };
40513
- const GiftCardProductEdit = () => {
40336
+ const GiftCardProductEdit$1 = () => {
40514
40337
  const { id } = reactRouterDom.useParams();
40515
40338
  const { product, isLoading, isError, error } = useProduct(id, {});
40516
40339
  if (isError) {
@@ -40524,9 +40347,186 @@ const GiftCardProductEdit = () => {
40524
40347
  !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
40525
40348
  ] });
40526
40349
  };
40527
- const handle$3 = {
40350
+ const handle$4 = {
40528
40351
  permissions: EDIT_GIFT_CARD_DENOMINATIONS_PERMISSIONS
40529
40352
  };
40353
+ const EditProductSchema = zod.z.object({
40354
+ status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
40355
+ title: zod.z.string().min(1),
40356
+ subtitle: zod.z.string().optional(),
40357
+ handle: zod.z.string().min(1),
40358
+ description: zod.z.string().optional()
40359
+ });
40360
+ const GiftCardProductEditForm = ({
40361
+ product
40362
+ }) => {
40363
+ const { handleSuccess } = useRouteModal();
40364
+ const form = useForm({
40365
+ defaultValues: {
40366
+ status: product.status,
40367
+ title: product.title,
40368
+ subtitle: product.subtitle || "",
40369
+ handle: product.handle || "",
40370
+ description: product.description || ""
40371
+ },
40372
+ resolver: u(EditProductSchema)
40373
+ });
40374
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
40375
+ const handleSubmit = form.handleSubmit(async (data) => {
40376
+ const { title, handle: handle2, status, ...optional } = data;
40377
+ await mutateAsync(
40378
+ {
40379
+ ...optional,
40380
+ title,
40381
+ handle: handle2,
40382
+ status
40383
+ },
40384
+ {
40385
+ onSuccess: ({ product: product2 }) => {
40386
+ ui.toast.success(
40387
+ `Gift card product ${product2.title} updated successfully`
40388
+ );
40389
+ handleSuccess();
40390
+ },
40391
+ onError: (e) => {
40392
+ ui.toast.error(e.message);
40393
+ }
40394
+ }
40395
+ );
40396
+ });
40397
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
40398
+ KeyboundForm,
40399
+ {
40400
+ onSubmit: handleSubmit,
40401
+ className: "flex flex-1 flex-col overflow-hidden",
40402
+ children: [
40403
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
40404
+ /* @__PURE__ */ jsxRuntime.jsx(
40405
+ Form$2.Field,
40406
+ {
40407
+ control: form.control,
40408
+ name: "status",
40409
+ render: ({ field: { onChange, ref, ...field } }) => {
40410
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40411
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Status" }),
40412
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { ...field, onValueChange: onChange, children: [
40413
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
40414
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: [
40415
+ "draft",
40416
+ "published",
40417
+ "proposed",
40418
+ "rejected"
40419
+ ].map((status) => {
40420
+ return /* @__PURE__ */ jsxRuntime.jsx(
40421
+ ui.Select.Item,
40422
+ {
40423
+ value: status,
40424
+ className: "capitalize",
40425
+ children: status
40426
+ },
40427
+ status
40428
+ );
40429
+ }) })
40430
+ ] }) }),
40431
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40432
+ ] });
40433
+ }
40434
+ }
40435
+ ),
40436
+ /* @__PURE__ */ jsxRuntime.jsx(
40437
+ Form$2.Field,
40438
+ {
40439
+ control: form.control,
40440
+ name: "title",
40441
+ render: ({ field }) => {
40442
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40443
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
40444
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
40445
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40446
+ ] });
40447
+ }
40448
+ }
40449
+ ),
40450
+ /* @__PURE__ */ jsxRuntime.jsx(
40451
+ Form$2.Field,
40452
+ {
40453
+ control: form.control,
40454
+ name: "subtitle",
40455
+ render: ({ field }) => {
40456
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40457
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
40458
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
40459
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40460
+ ] });
40461
+ }
40462
+ }
40463
+ ),
40464
+ /* @__PURE__ */ jsxRuntime.jsx(
40465
+ Form$2.Field,
40466
+ {
40467
+ control: form.control,
40468
+ name: "handle",
40469
+ render: ({ field }) => {
40470
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40471
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Handle" }),
40472
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
40473
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsxRuntime.jsx(
40474
+ ui.Text,
40475
+ {
40476
+ className: "text-ui-fg-muted",
40477
+ size: "small",
40478
+ leading: "compact",
40479
+ weight: "plus",
40480
+ children: "/"
40481
+ }
40482
+ ) }),
40483
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, className: "pl-10" })
40484
+ ] }) }),
40485
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40486
+ ] });
40487
+ }
40488
+ }
40489
+ ),
40490
+ /* @__PURE__ */ jsxRuntime.jsx(
40491
+ Form$2.Field,
40492
+ {
40493
+ control: form.control,
40494
+ name: "description",
40495
+ render: ({ field }) => {
40496
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
40497
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Description" }),
40498
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
40499
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40500
+ ] });
40501
+ }
40502
+ }
40503
+ )
40504
+ ] }) }) }),
40505
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
40506
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
40507
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
40508
+ ] }) })
40509
+ ]
40510
+ }
40511
+ ) });
40512
+ };
40513
+ const GiftCardProductEdit = () => {
40514
+ const { id } = reactRouterDom.useParams();
40515
+ const { product, isLoading, isError, error } = useProduct(id, {});
40516
+ if (isError) {
40517
+ throw error;
40518
+ }
40519
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
40520
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
40521
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift card product" }) }),
40522
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
40523
+ ] }),
40524
+ !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
40525
+ ] });
40526
+ };
40527
+ const handle$3 = {
40528
+ permissions: ["product:read", "product:update"]
40529
+ };
40530
40530
  const EditProductMediaForm = ({ product }) => {
40531
40531
  const [selection, setSelection] = React.useState({});
40532
40532
  const { handleSuccess } = useRouteModal();
@@ -41517,12 +41517,12 @@ const routeModule = {
41517
41517
  children: [
41518
41518
  {
41519
41519
  Component: GiftCardProductEdit$1,
41520
- path: "/gift-cards/gift-card-products/:id/edit",
41520
+ path: "/gift-cards/gift-card-products/:id/denominations",
41521
41521
  handle: handle$4
41522
41522
  },
41523
41523
  {
41524
41524
  Component: GiftCardProductEdit,
41525
- path: "/gift-cards/gift-card-products/:id/denominations",
41525
+ path: "/gift-cards/gift-card-products/:id/edit",
41526
41526
  handle: handle$3
41527
41527
  }
41528
41528
  ]
@@ -40150,185 +40150,8 @@ const ProductDetail = () => {
40150
40150
  const handle$5 = {
40151
40151
  permissions: ["product:read"]
40152
40152
  };
40153
- const EditProductSchema$1 = z.object({
40154
- status: z.enum(["draft", "published", "proposed", "rejected"]),
40155
- title: z.string().min(1),
40156
- subtitle: z.string().optional(),
40157
- handle: z.string().min(1),
40158
- description: z.string().optional()
40159
- });
40160
- const GiftCardProductEditForm = ({
40161
- product
40162
- }) => {
40163
- const { handleSuccess } = useRouteModal();
40164
- const form = useForm({
40165
- defaultValues: {
40166
- status: product.status,
40167
- title: product.title,
40168
- subtitle: product.subtitle || "",
40169
- handle: product.handle || "",
40170
- description: product.description || ""
40171
- },
40172
- resolver: u(EditProductSchema$1)
40173
- });
40174
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
40175
- const handleSubmit = form.handleSubmit(async (data) => {
40176
- const { title, handle: handle2, status, ...optional } = data;
40177
- await mutateAsync(
40178
- {
40179
- ...optional,
40180
- title,
40181
- handle: handle2,
40182
- status
40183
- },
40184
- {
40185
- onSuccess: ({ product: product2 }) => {
40186
- toast.success(
40187
- `Gift card product ${product2.title} updated successfully`
40188
- );
40189
- handleSuccess();
40190
- },
40191
- onError: (e) => {
40192
- toast.error(e.message);
40193
- }
40194
- }
40195
- );
40196
- });
40197
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
40198
- KeyboundForm,
40199
- {
40200
- onSubmit: handleSubmit,
40201
- className: "flex flex-1 flex-col overflow-hidden",
40202
- children: [
40203
- /* @__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-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
40204
- /* @__PURE__ */ jsx(
40205
- Form$2.Field,
40206
- {
40207
- control: form.control,
40208
- name: "status",
40209
- render: ({ field: { onChange, ref, ...field } }) => {
40210
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40211
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Status" }),
40212
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
40213
- /* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
40214
- /* @__PURE__ */ jsx(Select.Content, { children: [
40215
- "draft",
40216
- "published",
40217
- "proposed",
40218
- "rejected"
40219
- ].map((status) => {
40220
- return /* @__PURE__ */ jsx(
40221
- Select.Item,
40222
- {
40223
- value: status,
40224
- className: "capitalize",
40225
- children: status
40226
- },
40227
- status
40228
- );
40229
- }) })
40230
- ] }) }),
40231
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40232
- ] });
40233
- }
40234
- }
40235
- ),
40236
- /* @__PURE__ */ jsx(
40237
- Form$2.Field,
40238
- {
40239
- control: form.control,
40240
- name: "title",
40241
- render: ({ field }) => {
40242
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40243
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
40244
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
40245
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40246
- ] });
40247
- }
40248
- }
40249
- ),
40250
- /* @__PURE__ */ jsx(
40251
- Form$2.Field,
40252
- {
40253
- control: form.control,
40254
- name: "subtitle",
40255
- render: ({ field }) => {
40256
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40257
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
40258
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
40259
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40260
- ] });
40261
- }
40262
- }
40263
- ),
40264
- /* @__PURE__ */ jsx(
40265
- Form$2.Field,
40266
- {
40267
- control: form.control,
40268
- name: "handle",
40269
- render: ({ field }) => {
40270
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40271
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Handle" }),
40272
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
40273
- /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
40274
- Text,
40275
- {
40276
- className: "text-ui-fg-muted",
40277
- size: "small",
40278
- leading: "compact",
40279
- weight: "plus",
40280
- children: "/"
40281
- }
40282
- ) }),
40283
- /* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
40284
- ] }) }),
40285
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40286
- ] });
40287
- }
40288
- }
40289
- ),
40290
- /* @__PURE__ */ jsx(
40291
- Form$2.Field,
40292
- {
40293
- control: form.control,
40294
- name: "description",
40295
- render: ({ field }) => {
40296
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40297
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
40298
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
40299
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40300
- ] });
40301
- }
40302
- }
40303
- )
40304
- ] }) }) }),
40305
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
40306
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
40307
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
40308
- ] }) })
40309
- ]
40310
- }
40311
- ) });
40312
- };
40313
- const GiftCardProductEdit$1 = () => {
40314
- const { id } = useParams();
40315
- const { product, isLoading, isError, error } = useProduct(id, {});
40316
- if (isError) {
40317
- throw error;
40318
- }
40319
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
40320
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
40321
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
40322
- /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
40323
- ] }),
40324
- !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
40325
- ] });
40326
- };
40327
- const handle$4 = {
40328
- permissions: ["product:read", "product:update"]
40329
- };
40330
40153
  const DENOMINATION_OPTION_TITLE = "denomination";
40331
- const EditProductSchema = z.object({
40154
+ const EditProductSchema$1 = z.object({
40332
40155
  denominations: z.array(
40333
40156
  z.object({
40334
40157
  id: z.string().optional(),
@@ -40348,7 +40171,7 @@ const GiftCardProductEditDenominationsForm = ({
40348
40171
  value: variant.title
40349
40172
  }))
40350
40173
  },
40351
- resolver: u(EditProductSchema)
40174
+ resolver: u(EditProductSchema$1)
40352
40175
  });
40353
40176
  const denominationOption = product.options?.find(
40354
40177
  (option) => option.title === DENOMINATION_OPTION_TITLE
@@ -40490,7 +40313,7 @@ const GiftCardProductEditDenominationsForm = ({
40490
40313
  }
40491
40314
  ) });
40492
40315
  };
40493
- const GiftCardProductEdit = () => {
40316
+ const GiftCardProductEdit$1 = () => {
40494
40317
  const { id } = useParams();
40495
40318
  const { product, isLoading, isError, error } = useProduct(id, {});
40496
40319
  if (isError) {
@@ -40504,9 +40327,186 @@ const GiftCardProductEdit = () => {
40504
40327
  !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
40505
40328
  ] });
40506
40329
  };
40507
- const handle$3 = {
40330
+ const handle$4 = {
40508
40331
  permissions: EDIT_GIFT_CARD_DENOMINATIONS_PERMISSIONS
40509
40332
  };
40333
+ const EditProductSchema = z.object({
40334
+ status: z.enum(["draft", "published", "proposed", "rejected"]),
40335
+ title: z.string().min(1),
40336
+ subtitle: z.string().optional(),
40337
+ handle: z.string().min(1),
40338
+ description: z.string().optional()
40339
+ });
40340
+ const GiftCardProductEditForm = ({
40341
+ product
40342
+ }) => {
40343
+ const { handleSuccess } = useRouteModal();
40344
+ const form = useForm({
40345
+ defaultValues: {
40346
+ status: product.status,
40347
+ title: product.title,
40348
+ subtitle: product.subtitle || "",
40349
+ handle: product.handle || "",
40350
+ description: product.description || ""
40351
+ },
40352
+ resolver: u(EditProductSchema)
40353
+ });
40354
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
40355
+ const handleSubmit = form.handleSubmit(async (data) => {
40356
+ const { title, handle: handle2, status, ...optional } = data;
40357
+ await mutateAsync(
40358
+ {
40359
+ ...optional,
40360
+ title,
40361
+ handle: handle2,
40362
+ status
40363
+ },
40364
+ {
40365
+ onSuccess: ({ product: product2 }) => {
40366
+ toast.success(
40367
+ `Gift card product ${product2.title} updated successfully`
40368
+ );
40369
+ handleSuccess();
40370
+ },
40371
+ onError: (e) => {
40372
+ toast.error(e.message);
40373
+ }
40374
+ }
40375
+ );
40376
+ });
40377
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
40378
+ KeyboundForm,
40379
+ {
40380
+ onSubmit: handleSubmit,
40381
+ className: "flex flex-1 flex-col overflow-hidden",
40382
+ children: [
40383
+ /* @__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-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
40384
+ /* @__PURE__ */ jsx(
40385
+ Form$2.Field,
40386
+ {
40387
+ control: form.control,
40388
+ name: "status",
40389
+ render: ({ field: { onChange, ref, ...field } }) => {
40390
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40391
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Status" }),
40392
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
40393
+ /* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
40394
+ /* @__PURE__ */ jsx(Select.Content, { children: [
40395
+ "draft",
40396
+ "published",
40397
+ "proposed",
40398
+ "rejected"
40399
+ ].map((status) => {
40400
+ return /* @__PURE__ */ jsx(
40401
+ Select.Item,
40402
+ {
40403
+ value: status,
40404
+ className: "capitalize",
40405
+ children: status
40406
+ },
40407
+ status
40408
+ );
40409
+ }) })
40410
+ ] }) }),
40411
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40412
+ ] });
40413
+ }
40414
+ }
40415
+ ),
40416
+ /* @__PURE__ */ jsx(
40417
+ Form$2.Field,
40418
+ {
40419
+ control: form.control,
40420
+ name: "title",
40421
+ render: ({ field }) => {
40422
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40423
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
40424
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
40425
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40426
+ ] });
40427
+ }
40428
+ }
40429
+ ),
40430
+ /* @__PURE__ */ jsx(
40431
+ Form$2.Field,
40432
+ {
40433
+ control: form.control,
40434
+ name: "subtitle",
40435
+ render: ({ field }) => {
40436
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40437
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
40438
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
40439
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40440
+ ] });
40441
+ }
40442
+ }
40443
+ ),
40444
+ /* @__PURE__ */ jsx(
40445
+ Form$2.Field,
40446
+ {
40447
+ control: form.control,
40448
+ name: "handle",
40449
+ render: ({ field }) => {
40450
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40451
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Handle" }),
40452
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
40453
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
40454
+ Text,
40455
+ {
40456
+ className: "text-ui-fg-muted",
40457
+ size: "small",
40458
+ leading: "compact",
40459
+ weight: "plus",
40460
+ children: "/"
40461
+ }
40462
+ ) }),
40463
+ /* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
40464
+ ] }) }),
40465
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40466
+ ] });
40467
+ }
40468
+ }
40469
+ ),
40470
+ /* @__PURE__ */ jsx(
40471
+ Form$2.Field,
40472
+ {
40473
+ control: form.control,
40474
+ name: "description",
40475
+ render: ({ field }) => {
40476
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
40477
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
40478
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
40479
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
40480
+ ] });
40481
+ }
40482
+ }
40483
+ )
40484
+ ] }) }) }),
40485
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
40486
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
40487
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
40488
+ ] }) })
40489
+ ]
40490
+ }
40491
+ ) });
40492
+ };
40493
+ const GiftCardProductEdit = () => {
40494
+ const { id } = useParams();
40495
+ const { product, isLoading, isError, error } = useProduct(id, {});
40496
+ if (isError) {
40497
+ throw error;
40498
+ }
40499
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
40500
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
40501
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
40502
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
40503
+ ] }),
40504
+ !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
40505
+ ] });
40506
+ };
40507
+ const handle$3 = {
40508
+ permissions: ["product:read", "product:update"]
40509
+ };
40510
40510
  const EditProductMediaForm = ({ product }) => {
40511
40511
  const [selection, setSelection] = useState({});
40512
40512
  const { handleSuccess } = useRouteModal();
@@ -41497,12 +41497,12 @@ const routeModule = {
41497
41497
  children: [
41498
41498
  {
41499
41499
  Component: GiftCardProductEdit$1,
41500
- path: "/gift-cards/gift-card-products/:id/edit",
41500
+ path: "/gift-cards/gift-card-products/:id/denominations",
41501
41501
  handle: handle$4
41502
41502
  },
41503
41503
  {
41504
41504
  Component: GiftCardProductEdit,
41505
- path: "/gift-cards/gift-card-products/:id/denominations",
41505
+ path: "/gift-cards/gift-card-products/:id/edit",
41506
41506
  handle: handle$3
41507
41507
  }
41508
41508
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/loyalty-plugin",
3
- "version": "2.22.7-snapshot-20261113095001",
3
+ "version": "2.22.7",
4
4
  "description": "Medusa Plugin: Loyalty - Gift Cards",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -59,16 +59,16 @@
59
59
  "watch": "medusa plugin:develop"
60
60
  },
61
61
  "devDependencies": {
62
- "@medusajs/admin-sdk": "2.22.7-snapshot-20261113095001",
63
- "@medusajs/cli": "2.22.7-snapshot-20261113095001",
64
- "@medusajs/dashboard": "2.22.7-snapshot-20261113095001",
65
- "@medusajs/framework": "2.22.7-snapshot-20261113095001",
66
- "@medusajs/icons": "2.22.7-snapshot-20261113095001",
67
- "@medusajs/medusa": "2.22.7-snapshot-20261113095001",
68
- "@medusajs/test-utils": "2.22.7-snapshot-20261113095001",
69
- "@medusajs/types": "2.22.7-snapshot-20261113095001",
70
- "@medusajs/ui": "4.2.14-snapshot-20261113095001",
71
- "@medusajs/ui-preset": "2.22.7-snapshot-20261113095001",
62
+ "@medusajs/admin-sdk": "2.22.7",
63
+ "@medusajs/cli": "2.22.7",
64
+ "@medusajs/dashboard": "2.22.7",
65
+ "@medusajs/framework": "2.22.7",
66
+ "@medusajs/icons": "2.22.7",
67
+ "@medusajs/medusa": "2.22.7",
68
+ "@medusajs/test-utils": "2.22.7",
69
+ "@medusajs/types": "2.22.7",
70
+ "@medusajs/ui": "4.2.14",
71
+ "@medusajs/ui-preset": "2.22.7",
72
72
  "@swc/core": "^1.16.20",
73
73
  "@types/node": "^22.20.5",
74
74
  "cross-env": "^10.1.0",
@@ -76,14 +76,14 @@
76
76
  "typescript": "npm:@typescript/typescript6@^6.0.2"
77
77
  },
78
78
  "peerDependencies": {
79
- "@medusajs/admin-sdk": "2.22.7-snapshot-20261113095001",
80
- "@medusajs/cli": "2.22.7-snapshot-20261113095001",
81
- "@medusajs/dashboard": "2.22.7-snapshot-20261113095001",
82
- "@medusajs/framework": "2.22.7-snapshot-20261113095001",
83
- "@medusajs/icons": "2.22.7-snapshot-20261113095001",
84
- "@medusajs/medusa": "2.22.7-snapshot-20261113095001",
85
- "@medusajs/test-utils": "2.22.7-snapshot-20261113095001",
86
- "@medusajs/ui": "4.2.14-snapshot-20261113095001",
79
+ "@medusajs/admin-sdk": "2.22.7",
80
+ "@medusajs/cli": "2.22.7",
81
+ "@medusajs/dashboard": "2.22.7",
82
+ "@medusajs/framework": "2.22.7",
83
+ "@medusajs/icons": "2.22.7",
84
+ "@medusajs/medusa": "2.22.7",
85
+ "@medusajs/test-utils": "2.22.7",
86
+ "@medusajs/ui": "4.2.14",
87
87
  "react": "^18.3.1",
88
88
  "react-dom": "^18.3.1",
89
89
  "react-router-dom": "^6.30.4 || ^7.0.0"