@medusajs/loyalty-plugin 2.22.0 → 2.22.1-snapshot-20261025213551

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.
@@ -41628,8 +41628,182 @@ const ProductDetail = () => {
41628
41628
  }
41629
41629
  );
41630
41630
  };
41631
- const DENOMINATION_OPTION_TITLE = "denomination";
41632
41631
  const EditProductSchema$1 = zod.z.object({
41632
+ status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
41633
+ title: zod.z.string().min(1),
41634
+ subtitle: zod.z.string().optional(),
41635
+ handle: zod.z.string().min(1),
41636
+ description: zod.z.string().optional()
41637
+ });
41638
+ const GiftCardProductEditForm = ({
41639
+ product
41640
+ }) => {
41641
+ const { handleSuccess } = useRouteModal();
41642
+ const form = useForm({
41643
+ defaultValues: {
41644
+ status: product.status,
41645
+ title: product.title,
41646
+ subtitle: product.subtitle || "",
41647
+ handle: product.handle || "",
41648
+ description: product.description || ""
41649
+ },
41650
+ resolver: u(EditProductSchema$1)
41651
+ });
41652
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
41653
+ const handleSubmit = form.handleSubmit(async (data) => {
41654
+ const { title, handle, status, ...optional2 } = data;
41655
+ await mutateAsync(
41656
+ {
41657
+ ...optional2,
41658
+ title,
41659
+ handle,
41660
+ status
41661
+ },
41662
+ {
41663
+ onSuccess: ({ product: product2 }) => {
41664
+ ui.toast.success(
41665
+ `Gift card product ${product2.title} updated successfully`
41666
+ );
41667
+ handleSuccess();
41668
+ },
41669
+ onError: (e) => {
41670
+ ui.toast.error(e.message);
41671
+ }
41672
+ }
41673
+ );
41674
+ });
41675
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
41676
+ KeyboundForm,
41677
+ {
41678
+ onSubmit: handleSubmit,
41679
+ className: "flex flex-1 flex-col overflow-hidden",
41680
+ children: [
41681
+ /* @__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: [
41682
+ /* @__PURE__ */ jsxRuntime.jsx(
41683
+ Form$2.Field,
41684
+ {
41685
+ control: form.control,
41686
+ name: "status",
41687
+ render: ({ field: { onChange, ref, ...field } }) => {
41688
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41689
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Status" }),
41690
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { ...field, onValueChange: onChange, children: [
41691
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
41692
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: [
41693
+ "draft",
41694
+ "published",
41695
+ "proposed",
41696
+ "rejected"
41697
+ ].map((status) => {
41698
+ return /* @__PURE__ */ jsxRuntime.jsx(
41699
+ ui.Select.Item,
41700
+ {
41701
+ value: status,
41702
+ className: "capitalize",
41703
+ children: status
41704
+ },
41705
+ status
41706
+ );
41707
+ }) })
41708
+ ] }) }),
41709
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41710
+ ] });
41711
+ }
41712
+ }
41713
+ ),
41714
+ /* @__PURE__ */ jsxRuntime.jsx(
41715
+ Form$2.Field,
41716
+ {
41717
+ control: form.control,
41718
+ name: "title",
41719
+ render: ({ field }) => {
41720
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41721
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
41722
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
41723
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41724
+ ] });
41725
+ }
41726
+ }
41727
+ ),
41728
+ /* @__PURE__ */ jsxRuntime.jsx(
41729
+ Form$2.Field,
41730
+ {
41731
+ control: form.control,
41732
+ name: "subtitle",
41733
+ render: ({ field }) => {
41734
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41735
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
41736
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
41737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41738
+ ] });
41739
+ }
41740
+ }
41741
+ ),
41742
+ /* @__PURE__ */ jsxRuntime.jsx(
41743
+ Form$2.Field,
41744
+ {
41745
+ control: form.control,
41746
+ name: "handle",
41747
+ render: ({ field }) => {
41748
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Handle" }),
41750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
41751
+ /* @__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(
41752
+ ui.Text,
41753
+ {
41754
+ className: "text-ui-fg-muted",
41755
+ size: "small",
41756
+ leading: "compact",
41757
+ weight: "plus",
41758
+ children: "/"
41759
+ }
41760
+ ) }),
41761
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, className: "pl-10" })
41762
+ ] }) }),
41763
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41764
+ ] });
41765
+ }
41766
+ }
41767
+ ),
41768
+ /* @__PURE__ */ jsxRuntime.jsx(
41769
+ Form$2.Field,
41770
+ {
41771
+ control: form.control,
41772
+ name: "description",
41773
+ render: ({ field }) => {
41774
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41775
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Description" }),
41776
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
41777
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41778
+ ] });
41779
+ }
41780
+ }
41781
+ )
41782
+ ] }) }) }),
41783
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
41784
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
41785
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
41786
+ ] }) })
41787
+ ]
41788
+ }
41789
+ ) });
41790
+ };
41791
+ const GiftCardProductEdit$1 = () => {
41792
+ const { id } = reactRouterDom.useParams();
41793
+ const { product, isLoading, isError, error } = useProduct(id, {});
41794
+ if (isError) {
41795
+ throw error;
41796
+ }
41797
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
41798
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
41799
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift card product" }) }),
41800
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
41801
+ ] }),
41802
+ !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
41803
+ ] });
41804
+ };
41805
+ const DENOMINATION_OPTION_TITLE = "denomination";
41806
+ const EditProductSchema = zod.z.object({
41633
41807
  denominations: zod.z.array(
41634
41808
  zod.z.object({
41635
41809
  id: zod.z.string().optional(),
@@ -41649,7 +41823,7 @@ const GiftCardProductEditDenominationsForm = ({
41649
41823
  value: variant.title
41650
41824
  }))
41651
41825
  },
41652
- resolver: u(EditProductSchema$1)
41826
+ resolver: u(EditProductSchema)
41653
41827
  });
41654
41828
  const denominationOption = product.options?.find(
41655
41829
  (option) => option.title === DENOMINATION_OPTION_TITLE
@@ -41791,7 +41965,7 @@ const GiftCardProductEditDenominationsForm = ({
41791
41965
  }
41792
41966
  ) });
41793
41967
  };
41794
- const GiftCardProductEdit$1 = () => {
41968
+ const GiftCardProductEdit = () => {
41795
41969
  const { id } = reactRouterDom.useParams();
41796
41970
  const { product, isLoading, isError, error } = useProduct(id, {});
41797
41971
  if (isError) {
@@ -41805,180 +41979,6 @@ const GiftCardProductEdit$1 = () => {
41805
41979
  !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
41806
41980
  ] });
41807
41981
  };
41808
- const EditProductSchema = zod.z.object({
41809
- status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
41810
- title: zod.z.string().min(1),
41811
- subtitle: zod.z.string().optional(),
41812
- handle: zod.z.string().min(1),
41813
- description: zod.z.string().optional()
41814
- });
41815
- const GiftCardProductEditForm = ({
41816
- product
41817
- }) => {
41818
- const { handleSuccess } = useRouteModal();
41819
- const form = useForm({
41820
- defaultValues: {
41821
- status: product.status,
41822
- title: product.title,
41823
- subtitle: product.subtitle || "",
41824
- handle: product.handle || "",
41825
- description: product.description || ""
41826
- },
41827
- resolver: u(EditProductSchema)
41828
- });
41829
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
41830
- const handleSubmit = form.handleSubmit(async (data) => {
41831
- const { title, handle, status, ...optional2 } = data;
41832
- await mutateAsync(
41833
- {
41834
- ...optional2,
41835
- title,
41836
- handle,
41837
- status
41838
- },
41839
- {
41840
- onSuccess: ({ product: product2 }) => {
41841
- ui.toast.success(
41842
- `Gift card product ${product2.title} updated successfully`
41843
- );
41844
- handleSuccess();
41845
- },
41846
- onError: (e) => {
41847
- ui.toast.error(e.message);
41848
- }
41849
- }
41850
- );
41851
- });
41852
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
41853
- KeyboundForm,
41854
- {
41855
- onSubmit: handleSubmit,
41856
- className: "flex flex-1 flex-col overflow-hidden",
41857
- children: [
41858
- /* @__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: [
41859
- /* @__PURE__ */ jsxRuntime.jsx(
41860
- Form$2.Field,
41861
- {
41862
- control: form.control,
41863
- name: "status",
41864
- render: ({ field: { onChange, ref, ...field } }) => {
41865
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41866
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Status" }),
41867
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { ...field, onValueChange: onChange, children: [
41868
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
41869
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: [
41870
- "draft",
41871
- "published",
41872
- "proposed",
41873
- "rejected"
41874
- ].map((status) => {
41875
- return /* @__PURE__ */ jsxRuntime.jsx(
41876
- ui.Select.Item,
41877
- {
41878
- value: status,
41879
- className: "capitalize",
41880
- children: status
41881
- },
41882
- status
41883
- );
41884
- }) })
41885
- ] }) }),
41886
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41887
- ] });
41888
- }
41889
- }
41890
- ),
41891
- /* @__PURE__ */ jsxRuntime.jsx(
41892
- Form$2.Field,
41893
- {
41894
- control: form.control,
41895
- name: "title",
41896
- render: ({ field }) => {
41897
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41898
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
41899
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
41900
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41901
- ] });
41902
- }
41903
- }
41904
- ),
41905
- /* @__PURE__ */ jsxRuntime.jsx(
41906
- Form$2.Field,
41907
- {
41908
- control: form.control,
41909
- name: "subtitle",
41910
- render: ({ field }) => {
41911
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41912
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
41913
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
41914
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41915
- ] });
41916
- }
41917
- }
41918
- ),
41919
- /* @__PURE__ */ jsxRuntime.jsx(
41920
- Form$2.Field,
41921
- {
41922
- control: form.control,
41923
- name: "handle",
41924
- render: ({ field }) => {
41925
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41926
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Handle" }),
41927
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
41928
- /* @__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(
41929
- ui.Text,
41930
- {
41931
- className: "text-ui-fg-muted",
41932
- size: "small",
41933
- leading: "compact",
41934
- weight: "plus",
41935
- children: "/"
41936
- }
41937
- ) }),
41938
- /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, className: "pl-10" })
41939
- ] }) }),
41940
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41941
- ] });
41942
- }
41943
- }
41944
- ),
41945
- /* @__PURE__ */ jsxRuntime.jsx(
41946
- Form$2.Field,
41947
- {
41948
- control: form.control,
41949
- name: "description",
41950
- render: ({ field }) => {
41951
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
41952
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Description" }),
41953
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
41954
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
41955
- ] });
41956
- }
41957
- }
41958
- )
41959
- ] }) }) }),
41960
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
41961
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
41962
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
41963
- ] }) })
41964
- ]
41965
- }
41966
- ) });
41967
- };
41968
- const GiftCardProductEdit = () => {
41969
- const { id } = reactRouterDom.useParams();
41970
- const { product, isLoading, isError, error } = useProduct(id, {});
41971
- if (isError) {
41972
- throw error;
41973
- }
41974
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
41975
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
41976
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift card product" }) }),
41977
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
41978
- ] }),
41979
- !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
41980
- ] });
41981
- };
41982
41982
  const EditProductMediaForm = ({ product }) => {
41983
41983
  const [selection, setSelection] = React.useState({});
41984
41984
  const { handleSuccess } = useRouteModal();
@@ -42932,11 +42932,11 @@ const routeModule = {
42932
42932
  children: [
42933
42933
  {
42934
42934
  Component: GiftCardProductEdit$1,
42935
- path: "/gift-cards/gift-card-products/:id/denominations"
42935
+ path: "/gift-cards/gift-card-products/:id/edit"
42936
42936
  },
42937
42937
  {
42938
42938
  Component: GiftCardProductEdit,
42939
- path: "/gift-cards/gift-card-products/:id/edit"
42939
+ path: "/gift-cards/gift-card-products/:id/denominations"
42940
42940
  }
42941
42941
  ]
42942
42942
  },
@@ -41608,8 +41608,182 @@ const ProductDetail = () => {
41608
41608
  }
41609
41609
  );
41610
41610
  };
41611
- const DENOMINATION_OPTION_TITLE = "denomination";
41612
41611
  const EditProductSchema$1 = z.object({
41612
+ status: z.enum(["draft", "published", "proposed", "rejected"]),
41613
+ title: z.string().min(1),
41614
+ subtitle: z.string().optional(),
41615
+ handle: z.string().min(1),
41616
+ description: z.string().optional()
41617
+ });
41618
+ const GiftCardProductEditForm = ({
41619
+ product
41620
+ }) => {
41621
+ const { handleSuccess } = useRouteModal();
41622
+ const form = useForm({
41623
+ defaultValues: {
41624
+ status: product.status,
41625
+ title: product.title,
41626
+ subtitle: product.subtitle || "",
41627
+ handle: product.handle || "",
41628
+ description: product.description || ""
41629
+ },
41630
+ resolver: u(EditProductSchema$1)
41631
+ });
41632
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
41633
+ const handleSubmit = form.handleSubmit(async (data) => {
41634
+ const { title, handle, status, ...optional2 } = data;
41635
+ await mutateAsync(
41636
+ {
41637
+ ...optional2,
41638
+ title,
41639
+ handle,
41640
+ status
41641
+ },
41642
+ {
41643
+ onSuccess: ({ product: product2 }) => {
41644
+ toast.success(
41645
+ `Gift card product ${product2.title} updated successfully`
41646
+ );
41647
+ handleSuccess();
41648
+ },
41649
+ onError: (e) => {
41650
+ toast.error(e.message);
41651
+ }
41652
+ }
41653
+ );
41654
+ });
41655
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
41656
+ KeyboundForm,
41657
+ {
41658
+ onSubmit: handleSubmit,
41659
+ className: "flex flex-1 flex-col overflow-hidden",
41660
+ children: [
41661
+ /* @__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: [
41662
+ /* @__PURE__ */ jsx(
41663
+ Form$2.Field,
41664
+ {
41665
+ control: form.control,
41666
+ name: "status",
41667
+ render: ({ field: { onChange, ref, ...field } }) => {
41668
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41669
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Status" }),
41670
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
41671
+ /* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
41672
+ /* @__PURE__ */ jsx(Select.Content, { children: [
41673
+ "draft",
41674
+ "published",
41675
+ "proposed",
41676
+ "rejected"
41677
+ ].map((status) => {
41678
+ return /* @__PURE__ */ jsx(
41679
+ Select.Item,
41680
+ {
41681
+ value: status,
41682
+ className: "capitalize",
41683
+ children: status
41684
+ },
41685
+ status
41686
+ );
41687
+ }) })
41688
+ ] }) }),
41689
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41690
+ ] });
41691
+ }
41692
+ }
41693
+ ),
41694
+ /* @__PURE__ */ jsx(
41695
+ Form$2.Field,
41696
+ {
41697
+ control: form.control,
41698
+ name: "title",
41699
+ render: ({ field }) => {
41700
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41701
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
41702
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
41703
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41704
+ ] });
41705
+ }
41706
+ }
41707
+ ),
41708
+ /* @__PURE__ */ jsx(
41709
+ Form$2.Field,
41710
+ {
41711
+ control: form.control,
41712
+ name: "subtitle",
41713
+ render: ({ field }) => {
41714
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41715
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
41716
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
41717
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41718
+ ] });
41719
+ }
41720
+ }
41721
+ ),
41722
+ /* @__PURE__ */ jsx(
41723
+ Form$2.Field,
41724
+ {
41725
+ control: form.control,
41726
+ name: "handle",
41727
+ render: ({ field }) => {
41728
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41729
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Handle" }),
41730
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
41731
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
41732
+ Text,
41733
+ {
41734
+ className: "text-ui-fg-muted",
41735
+ size: "small",
41736
+ leading: "compact",
41737
+ weight: "plus",
41738
+ children: "/"
41739
+ }
41740
+ ) }),
41741
+ /* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
41742
+ ] }) }),
41743
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41744
+ ] });
41745
+ }
41746
+ }
41747
+ ),
41748
+ /* @__PURE__ */ jsx(
41749
+ Form$2.Field,
41750
+ {
41751
+ control: form.control,
41752
+ name: "description",
41753
+ render: ({ field }) => {
41754
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41755
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
41756
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
41757
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41758
+ ] });
41759
+ }
41760
+ }
41761
+ )
41762
+ ] }) }) }),
41763
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
41764
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
41765
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
41766
+ ] }) })
41767
+ ]
41768
+ }
41769
+ ) });
41770
+ };
41771
+ const GiftCardProductEdit$1 = () => {
41772
+ const { id } = useParams();
41773
+ const { product, isLoading, isError, error } = useProduct(id, {});
41774
+ if (isError) {
41775
+ throw error;
41776
+ }
41777
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
41778
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
41779
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
41780
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
41781
+ ] }),
41782
+ !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
41783
+ ] });
41784
+ };
41785
+ const DENOMINATION_OPTION_TITLE = "denomination";
41786
+ const EditProductSchema = z.object({
41613
41787
  denominations: z.array(
41614
41788
  z.object({
41615
41789
  id: z.string().optional(),
@@ -41629,7 +41803,7 @@ const GiftCardProductEditDenominationsForm = ({
41629
41803
  value: variant.title
41630
41804
  }))
41631
41805
  },
41632
- resolver: u(EditProductSchema$1)
41806
+ resolver: u(EditProductSchema)
41633
41807
  });
41634
41808
  const denominationOption = product.options?.find(
41635
41809
  (option) => option.title === DENOMINATION_OPTION_TITLE
@@ -41771,7 +41945,7 @@ const GiftCardProductEditDenominationsForm = ({
41771
41945
  }
41772
41946
  ) });
41773
41947
  };
41774
- const GiftCardProductEdit$1 = () => {
41948
+ const GiftCardProductEdit = () => {
41775
41949
  const { id } = useParams();
41776
41950
  const { product, isLoading, isError, error } = useProduct(id, {});
41777
41951
  if (isError) {
@@ -41785,180 +41959,6 @@ const GiftCardProductEdit$1 = () => {
41785
41959
  !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
41786
41960
  ] });
41787
41961
  };
41788
- const EditProductSchema = z.object({
41789
- status: z.enum(["draft", "published", "proposed", "rejected"]),
41790
- title: z.string().min(1),
41791
- subtitle: z.string().optional(),
41792
- handle: z.string().min(1),
41793
- description: z.string().optional()
41794
- });
41795
- const GiftCardProductEditForm = ({
41796
- product
41797
- }) => {
41798
- const { handleSuccess } = useRouteModal();
41799
- const form = useForm({
41800
- defaultValues: {
41801
- status: product.status,
41802
- title: product.title,
41803
- subtitle: product.subtitle || "",
41804
- handle: product.handle || "",
41805
- description: product.description || ""
41806
- },
41807
- resolver: u(EditProductSchema)
41808
- });
41809
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
41810
- const handleSubmit = form.handleSubmit(async (data) => {
41811
- const { title, handle, status, ...optional2 } = data;
41812
- await mutateAsync(
41813
- {
41814
- ...optional2,
41815
- title,
41816
- handle,
41817
- status
41818
- },
41819
- {
41820
- onSuccess: ({ product: product2 }) => {
41821
- toast.success(
41822
- `Gift card product ${product2.title} updated successfully`
41823
- );
41824
- handleSuccess();
41825
- },
41826
- onError: (e) => {
41827
- toast.error(e.message);
41828
- }
41829
- }
41830
- );
41831
- });
41832
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
41833
- KeyboundForm,
41834
- {
41835
- onSubmit: handleSubmit,
41836
- className: "flex flex-1 flex-col overflow-hidden",
41837
- children: [
41838
- /* @__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: [
41839
- /* @__PURE__ */ jsx(
41840
- Form$2.Field,
41841
- {
41842
- control: form.control,
41843
- name: "status",
41844
- render: ({ field: { onChange, ref, ...field } }) => {
41845
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41846
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Status" }),
41847
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs(Select, { ...field, onValueChange: onChange, children: [
41848
- /* @__PURE__ */ jsx(Select.Trigger, { ref, className: "capitalize", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
41849
- /* @__PURE__ */ jsx(Select.Content, { children: [
41850
- "draft",
41851
- "published",
41852
- "proposed",
41853
- "rejected"
41854
- ].map((status) => {
41855
- return /* @__PURE__ */ jsx(
41856
- Select.Item,
41857
- {
41858
- value: status,
41859
- className: "capitalize",
41860
- children: status
41861
- },
41862
- status
41863
- );
41864
- }) })
41865
- ] }) }),
41866
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41867
- ] });
41868
- }
41869
- }
41870
- ),
41871
- /* @__PURE__ */ jsx(
41872
- Form$2.Field,
41873
- {
41874
- control: form.control,
41875
- name: "title",
41876
- render: ({ field }) => {
41877
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41878
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Title" }),
41879
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
41880
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41881
- ] });
41882
- }
41883
- }
41884
- ),
41885
- /* @__PURE__ */ jsx(
41886
- Form$2.Field,
41887
- {
41888
- control: form.control,
41889
- name: "subtitle",
41890
- render: ({ field }) => {
41891
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41892
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Subtitle" }),
41893
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
41894
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41895
- ] });
41896
- }
41897
- }
41898
- ),
41899
- /* @__PURE__ */ jsx(
41900
- Form$2.Field,
41901
- {
41902
- control: form.control,
41903
- name: "handle",
41904
- render: ({ field }) => {
41905
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41906
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Handle" }),
41907
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
41908
- /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-0 z-10 flex w-8 items-center justify-center border-r", children: /* @__PURE__ */ jsx(
41909
- Text,
41910
- {
41911
- className: "text-ui-fg-muted",
41912
- size: "small",
41913
- leading: "compact",
41914
- weight: "plus",
41915
- children: "/"
41916
- }
41917
- ) }),
41918
- /* @__PURE__ */ jsx(Input, { ...field, className: "pl-10" })
41919
- ] }) }),
41920
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41921
- ] });
41922
- }
41923
- }
41924
- ),
41925
- /* @__PURE__ */ jsx(
41926
- Form$2.Field,
41927
- {
41928
- control: form.control,
41929
- name: "description",
41930
- render: ({ field }) => {
41931
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
41932
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Description" }),
41933
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
41934
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
41935
- ] });
41936
- }
41937
- }
41938
- )
41939
- ] }) }) }),
41940
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
41941
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
41942
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
41943
- ] }) })
41944
- ]
41945
- }
41946
- ) });
41947
- };
41948
- const GiftCardProductEdit = () => {
41949
- const { id } = useParams();
41950
- const { product, isLoading, isError, error } = useProduct(id, {});
41951
- if (isError) {
41952
- throw error;
41953
- }
41954
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
41955
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
41956
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift card product" }) }),
41957
- /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card product" })
41958
- ] }),
41959
- !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
41960
- ] });
41961
- };
41962
41962
  const EditProductMediaForm = ({ product }) => {
41963
41963
  const [selection, setSelection] = useState({});
41964
41964
  const { handleSuccess } = useRouteModal();
@@ -42912,11 +42912,11 @@ const routeModule = {
42912
42912
  children: [
42913
42913
  {
42914
42914
  Component: GiftCardProductEdit$1,
42915
- path: "/gift-cards/gift-card-products/:id/denominations"
42915
+ path: "/gift-cards/gift-card-products/:id/edit"
42916
42916
  },
42917
42917
  {
42918
42918
  Component: GiftCardProductEdit,
42919
- path: "/gift-cards/gift-card-products/:id/edit"
42919
+ path: "/gift-cards/gift-card-products/:id/denominations"
42920
42920
  }
42921
42921
  ]
42922
42922
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/loyalty-plugin",
3
- "version": "2.22.0",
3
+ "version": "2.22.1-snapshot-20261025213551",
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.0",
63
- "@medusajs/cli": "2.22.0",
64
- "@medusajs/dashboard": "2.22.0",
65
- "@medusajs/framework": "2.22.0",
66
- "@medusajs/icons": "2.22.0",
67
- "@medusajs/medusa": "2.22.0",
68
- "@medusajs/test-utils": "2.22.0",
69
- "@medusajs/types": "2.22.0",
70
- "@medusajs/ui": "4.2.7",
71
- "@medusajs/ui-preset": "2.22.0",
62
+ "@medusajs/admin-sdk": "2.22.1-snapshot-20261025213551",
63
+ "@medusajs/cli": "2.22.1-snapshot-20261025213551",
64
+ "@medusajs/dashboard": "2.22.1-snapshot-20261025213551",
65
+ "@medusajs/framework": "2.22.1-snapshot-20261025213551",
66
+ "@medusajs/icons": "2.22.1-snapshot-20261025213551",
67
+ "@medusajs/medusa": "2.22.1-snapshot-20261025213551",
68
+ "@medusajs/test-utils": "2.22.1-snapshot-20261025213551",
69
+ "@medusajs/types": "2.22.1-snapshot-20261025213551",
70
+ "@medusajs/ui": "4.2.8-snapshot-20261025213551",
71
+ "@medusajs/ui-preset": "2.22.1-snapshot-20261025213551",
72
72
  "@swc/core": "1.5.7",
73
73
  "@types/node": "^20.0.0",
74
74
  "cross-env": "^7.0.3",
@@ -76,14 +76,14 @@
76
76
  "typescript": "^5.7.3"
77
77
  },
78
78
  "peerDependencies": {
79
- "@medusajs/admin-sdk": "2.22.0",
80
- "@medusajs/cli": "2.22.0",
81
- "@medusajs/dashboard": "2.22.0",
82
- "@medusajs/framework": "2.22.0",
83
- "@medusajs/icons": "2.22.0",
84
- "@medusajs/medusa": "2.22.0",
85
- "@medusajs/test-utils": "2.22.0",
86
- "@medusajs/ui": "4.2.7",
79
+ "@medusajs/admin-sdk": "2.22.1-snapshot-20261025213551",
80
+ "@medusajs/cli": "2.22.1-snapshot-20261025213551",
81
+ "@medusajs/dashboard": "2.22.1-snapshot-20261025213551",
82
+ "@medusajs/framework": "2.22.1-snapshot-20261025213551",
83
+ "@medusajs/icons": "2.22.1-snapshot-20261025213551",
84
+ "@medusajs/medusa": "2.22.1-snapshot-20261025213551",
85
+ "@medusajs/test-utils": "2.22.1-snapshot-20261025213551",
86
+ "@medusajs/ui": "4.2.8-snapshot-20261025213551",
87
87
  "react": "^18.3.1",
88
88
  "react-dom": "^18.3.1",
89
89
  "react-router-dom": "^6.30.4 || ^7.0.0"