@lodashventure/medusa-campaign 1.5.24 → 1.5.25

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.
@@ -738,6 +738,39 @@ const CouponForm = ({
738
738
  )
739
739
  ] });
740
740
  };
741
+ const CouponCreate = () => {
742
+ const navigate = reactRouterDom.useNavigate();
743
+ const handleSubmit = async (formData) => {
744
+ var _a, _b;
745
+ try {
746
+ await axios__default.default.post("/admin/coupons", {
747
+ ...formData,
748
+ starts_at: new Date(formData.starts_at).toUTCString(),
749
+ ends_at: new Date(formData.ends_at).toUTCString(),
750
+ currency_code: formData.discount_type === "fixed" ? formData.currency_code : void 0
751
+ });
752
+ ui.toast.success("Coupon created successfully");
753
+ navigate("/coupons");
754
+ } catch (error) {
755
+ let message = "Failed to create coupon";
756
+ if (axios__default.default.isAxiosError(error)) {
757
+ message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) ?? message;
758
+ } else if (error instanceof Error) {
759
+ message = error.message;
760
+ }
761
+ ui.toast.error("Failed to create coupon", {
762
+ description: message
763
+ });
764
+ }
765
+ };
766
+ return /* @__PURE__ */ jsxRuntime.jsx(
767
+ CouponForm,
768
+ {
769
+ onSubmit: handleSubmit,
770
+ onCancel: () => navigate("/coupons")
771
+ }
772
+ );
773
+ };
741
774
  const useCouponById = (id) => {
742
775
  const [data, setData] = react.useState(null);
743
776
  const [isLoading, setIsLoading] = react.useState(true);
@@ -1707,39 +1740,6 @@ const config$1 = adminSdk.defineRouteConfig({
1707
1740
  label: "Coupon Detail",
1708
1741
  icon: icons.Tag
1709
1742
  });
1710
- const CouponCreate = () => {
1711
- const navigate = reactRouterDom.useNavigate();
1712
- const handleSubmit = async (formData) => {
1713
- var _a, _b;
1714
- try {
1715
- await axios__default.default.post("/admin/coupons", {
1716
- ...formData,
1717
- starts_at: new Date(formData.starts_at).toUTCString(),
1718
- ends_at: new Date(formData.ends_at).toUTCString(),
1719
- currency_code: formData.discount_type === "fixed" ? formData.currency_code : void 0
1720
- });
1721
- ui.toast.success("Coupon created successfully");
1722
- navigate("/coupons");
1723
- } catch (error) {
1724
- let message = "Failed to create coupon";
1725
- if (axios__default.default.isAxiosError(error)) {
1726
- message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) ?? message;
1727
- } else if (error instanceof Error) {
1728
- message = error.message;
1729
- }
1730
- ui.toast.error("Failed to create coupon", {
1731
- description: message
1732
- });
1733
- }
1734
- };
1735
- return /* @__PURE__ */ jsxRuntime.jsx(
1736
- CouponForm,
1737
- {
1738
- onSubmit: handleSubmit,
1739
- onCancel: () => navigate("/coupons")
1740
- }
1741
- );
1742
- };
1743
1743
  const sdk = new Medusa__default.default({
1744
1744
  baseUrl: "/",
1745
1745
  debug: false,
@@ -2270,14 +2270,14 @@ const routeModule = {
2270
2270
  Component: FlashSale,
2271
2271
  path: "/flash-sales"
2272
2272
  },
2273
- {
2274
- Component: CouponDetail,
2275
- path: "/coupons/:id"
2276
- },
2277
2273
  {
2278
2274
  Component: CouponCreate,
2279
2275
  path: "/coupons/create"
2280
2276
  },
2277
+ {
2278
+ Component: CouponDetail,
2279
+ path: "/coupons/:id"
2280
+ },
2281
2281
  {
2282
2282
  Component: FlashSaleDetail,
2283
2283
  path: "/flash-sales/:id"
@@ -732,6 +732,39 @@ const CouponForm = ({
732
732
  )
733
733
  ] });
734
734
  };
735
+ const CouponCreate = () => {
736
+ const navigate = useNavigate();
737
+ const handleSubmit = async (formData) => {
738
+ var _a, _b;
739
+ try {
740
+ await axios.post("/admin/coupons", {
741
+ ...formData,
742
+ starts_at: new Date(formData.starts_at).toUTCString(),
743
+ ends_at: new Date(formData.ends_at).toUTCString(),
744
+ currency_code: formData.discount_type === "fixed" ? formData.currency_code : void 0
745
+ });
746
+ toast.success("Coupon created successfully");
747
+ navigate("/coupons");
748
+ } catch (error) {
749
+ let message = "Failed to create coupon";
750
+ if (axios.isAxiosError(error)) {
751
+ message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) ?? message;
752
+ } else if (error instanceof Error) {
753
+ message = error.message;
754
+ }
755
+ toast.error("Failed to create coupon", {
756
+ description: message
757
+ });
758
+ }
759
+ };
760
+ return /* @__PURE__ */ jsx(
761
+ CouponForm,
762
+ {
763
+ onSubmit: handleSubmit,
764
+ onCancel: () => navigate("/coupons")
765
+ }
766
+ );
767
+ };
735
768
  const useCouponById = (id) => {
736
769
  const [data, setData] = useState(null);
737
770
  const [isLoading, setIsLoading] = useState(true);
@@ -1701,39 +1734,6 @@ const config$1 = defineRouteConfig({
1701
1734
  label: "Coupon Detail",
1702
1735
  icon: Tag
1703
1736
  });
1704
- const CouponCreate = () => {
1705
- const navigate = useNavigate();
1706
- const handleSubmit = async (formData) => {
1707
- var _a, _b;
1708
- try {
1709
- await axios.post("/admin/coupons", {
1710
- ...formData,
1711
- starts_at: new Date(formData.starts_at).toUTCString(),
1712
- ends_at: new Date(formData.ends_at).toUTCString(),
1713
- currency_code: formData.discount_type === "fixed" ? formData.currency_code : void 0
1714
- });
1715
- toast.success("Coupon created successfully");
1716
- navigate("/coupons");
1717
- } catch (error) {
1718
- let message = "Failed to create coupon";
1719
- if (axios.isAxiosError(error)) {
1720
- message = ((_b = (_a = error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) ?? message;
1721
- } else if (error instanceof Error) {
1722
- message = error.message;
1723
- }
1724
- toast.error("Failed to create coupon", {
1725
- description: message
1726
- });
1727
- }
1728
- };
1729
- return /* @__PURE__ */ jsx(
1730
- CouponForm,
1731
- {
1732
- onSubmit: handleSubmit,
1733
- onCancel: () => navigate("/coupons")
1734
- }
1735
- );
1736
- };
1737
1737
  const sdk = new Medusa({
1738
1738
  baseUrl: "/",
1739
1739
  debug: false,
@@ -2264,14 +2264,14 @@ const routeModule = {
2264
2264
  Component: FlashSale,
2265
2265
  path: "/flash-sales"
2266
2266
  },
2267
- {
2268
- Component: CouponDetail,
2269
- path: "/coupons/:id"
2270
- },
2271
2267
  {
2272
2268
  Component: CouponCreate,
2273
2269
  path: "/coupons/create"
2274
2270
  },
2271
+ {
2272
+ Component: CouponDetail,
2273
+ path: "/coupons/:id"
2274
+ },
2275
2275
  {
2276
2276
  Component: FlashSaleDetail,
2277
2277
  path: "/flash-sales/:id"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodashventure/medusa-campaign",
3
- "version": "1.5.24",
3
+ "version": "1.5.25",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",