@lodashventure/medusa-campaign 1.5.25 → 1.5.28
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,39 +738,6 @@ 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
|
-
};
|
|
774
741
|
const useCouponById = (id) => {
|
|
775
742
|
const [data, setData] = react.useState(null);
|
|
776
743
|
const [isLoading, setIsLoading] = react.useState(true);
|
|
@@ -1740,6 +1707,39 @@ const config$1 = adminSdk.defineRouteConfig({
|
|
|
1740
1707
|
label: "Coupon Detail",
|
|
1741
1708
|
icon: icons.Tag
|
|
1742
1709
|
});
|
|
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: CouponCreate,
|
|
2275
|
-
path: "/coupons/create"
|
|
2276
|
-
},
|
|
2277
2273
|
{
|
|
2278
2274
|
Component: CouponDetail,
|
|
2279
2275
|
path: "/coupons/:id"
|
|
2280
2276
|
},
|
|
2277
|
+
{
|
|
2278
|
+
Component: CouponCreate,
|
|
2279
|
+
path: "/coupons/create"
|
|
2280
|
+
},
|
|
2281
2281
|
{
|
|
2282
2282
|
Component: FlashSaleDetail,
|
|
2283
2283
|
path: "/flash-sales/:id"
|
|
@@ -2290,12 +2290,6 @@ const routeModule = {
|
|
|
2290
2290
|
};
|
|
2291
2291
|
const menuItemModule = {
|
|
2292
2292
|
menuItems: [
|
|
2293
|
-
{
|
|
2294
|
-
label: config$2.label,
|
|
2295
|
-
icon: config$2.icon,
|
|
2296
|
-
path: "/flash-sales",
|
|
2297
|
-
nested: void 0
|
|
2298
|
-
},
|
|
2299
2293
|
{
|
|
2300
2294
|
label: config$3.label,
|
|
2301
2295
|
icon: config$3.icon,
|
|
@@ -2303,9 +2297,9 @@ const menuItemModule = {
|
|
|
2303
2297
|
nested: void 0
|
|
2304
2298
|
},
|
|
2305
2299
|
{
|
|
2306
|
-
label: config.label,
|
|
2307
|
-
icon: config.icon,
|
|
2308
|
-
path: "/flash-sales
|
|
2300
|
+
label: config$2.label,
|
|
2301
|
+
icon: config$2.icon,
|
|
2302
|
+
path: "/flash-sales",
|
|
2309
2303
|
nested: void 0
|
|
2310
2304
|
},
|
|
2311
2305
|
{
|
|
@@ -2313,6 +2307,12 @@ const menuItemModule = {
|
|
|
2313
2307
|
icon: config$1.icon,
|
|
2314
2308
|
path: "/coupons/:id",
|
|
2315
2309
|
nested: void 0
|
|
2310
|
+
},
|
|
2311
|
+
{
|
|
2312
|
+
label: config.label,
|
|
2313
|
+
icon: config.icon,
|
|
2314
|
+
path: "/flash-sales/:id",
|
|
2315
|
+
nested: void 0
|
|
2316
2316
|
}
|
|
2317
2317
|
]
|
|
2318
2318
|
};
|
|
@@ -732,39 +732,6 @@ 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
|
-
};
|
|
768
735
|
const useCouponById = (id) => {
|
|
769
736
|
const [data, setData] = useState(null);
|
|
770
737
|
const [isLoading, setIsLoading] = useState(true);
|
|
@@ -1734,6 +1701,39 @@ const config$1 = defineRouteConfig({
|
|
|
1734
1701
|
label: "Coupon Detail",
|
|
1735
1702
|
icon: Tag
|
|
1736
1703
|
});
|
|
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: CouponCreate,
|
|
2269
|
-
path: "/coupons/create"
|
|
2270
|
-
},
|
|
2271
2267
|
{
|
|
2272
2268
|
Component: CouponDetail,
|
|
2273
2269
|
path: "/coupons/:id"
|
|
2274
2270
|
},
|
|
2271
|
+
{
|
|
2272
|
+
Component: CouponCreate,
|
|
2273
|
+
path: "/coupons/create"
|
|
2274
|
+
},
|
|
2275
2275
|
{
|
|
2276
2276
|
Component: FlashSaleDetail,
|
|
2277
2277
|
path: "/flash-sales/:id"
|
|
@@ -2284,12 +2284,6 @@ const routeModule = {
|
|
|
2284
2284
|
};
|
|
2285
2285
|
const menuItemModule = {
|
|
2286
2286
|
menuItems: [
|
|
2287
|
-
{
|
|
2288
|
-
label: config$2.label,
|
|
2289
|
-
icon: config$2.icon,
|
|
2290
|
-
path: "/flash-sales",
|
|
2291
|
-
nested: void 0
|
|
2292
|
-
},
|
|
2293
2287
|
{
|
|
2294
2288
|
label: config$3.label,
|
|
2295
2289
|
icon: config$3.icon,
|
|
@@ -2297,9 +2291,9 @@ const menuItemModule = {
|
|
|
2297
2291
|
nested: void 0
|
|
2298
2292
|
},
|
|
2299
2293
|
{
|
|
2300
|
-
label: config.label,
|
|
2301
|
-
icon: config.icon,
|
|
2302
|
-
path: "/flash-sales
|
|
2294
|
+
label: config$2.label,
|
|
2295
|
+
icon: config$2.icon,
|
|
2296
|
+
path: "/flash-sales",
|
|
2303
2297
|
nested: void 0
|
|
2304
2298
|
},
|
|
2305
2299
|
{
|
|
@@ -2307,6 +2301,12 @@ const menuItemModule = {
|
|
|
2307
2301
|
icon: config$1.icon,
|
|
2308
2302
|
path: "/coupons/:id",
|
|
2309
2303
|
nested: void 0
|
|
2304
|
+
},
|
|
2305
|
+
{
|
|
2306
|
+
label: config.label,
|
|
2307
|
+
icon: config.icon,
|
|
2308
|
+
path: "/flash-sales/:id",
|
|
2309
|
+
nested: void 0
|
|
2310
2310
|
}
|
|
2311
2311
|
]
|
|
2312
2312
|
};
|