@lodashventure/medusa-campaign 1.5.7 → 1.5.9

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.
@@ -2101,6 +2101,41 @@ const FlashSaleForm = ({
2101
2101
  ] }) })
2102
2102
  ] });
2103
2103
  };
2104
+ const FlashSaleCreate = () => {
2105
+ const navigate = reactRouterDom.useNavigate();
2106
+ async function handleSubmit(campaignData) {
2107
+ var _a;
2108
+ try {
2109
+ await axios__default.default.post("/admin/flash-sales", {
2110
+ ...campaignData,
2111
+ starts_at: new Date(campaignData.starts_at).toUTCString(),
2112
+ ends_at: new Date(campaignData.ends_at).toUTCString()
2113
+ });
2114
+ ui.toast.success("Flash sale created successfully");
2115
+ navigate("/flash-sales");
2116
+ } catch (error) {
2117
+ let message;
2118
+ if (axios__default.default.isAxiosError(error)) {
2119
+ console.log(error);
2120
+ message = (_a = error.response) == null ? void 0 : _a.data.message;
2121
+ } else if (error instanceof Error) {
2122
+ message = error.message;
2123
+ } else {
2124
+ message = "Failed to create flash sale";
2125
+ }
2126
+ ui.toast.error("Failed to create flash sale", {
2127
+ description: message
2128
+ });
2129
+ }
2130
+ }
2131
+ return /* @__PURE__ */ jsxRuntime.jsx(
2132
+ FlashSaleForm,
2133
+ {
2134
+ onSubmit: handleSubmit,
2135
+ onCancel: () => navigate("/flash-sales")
2136
+ }
2137
+ );
2138
+ };
2104
2139
  const useFlashSaleById = (id) => {
2105
2140
  const [data, setData] = react.useState(null);
2106
2141
  const [isLoading, setIsLoading] = react.useState(true);
@@ -2219,41 +2254,6 @@ const config = adminSdk.defineRouteConfig({
2219
2254
  label: "Flash Sale Detail",
2220
2255
  icon: icons.Sparkles
2221
2256
  });
2222
- const FlashSaleCreate = () => {
2223
- const navigate = reactRouterDom.useNavigate();
2224
- async function handleSubmit(campaignData) {
2225
- var _a;
2226
- try {
2227
- await axios__default.default.post("/admin/flash-sales", {
2228
- ...campaignData,
2229
- starts_at: new Date(campaignData.starts_at).toUTCString(),
2230
- ends_at: new Date(campaignData.ends_at).toUTCString()
2231
- });
2232
- ui.toast.success("Flash sale created successfully");
2233
- navigate("/flash-sales");
2234
- } catch (error) {
2235
- let message;
2236
- if (axios__default.default.isAxiosError(error)) {
2237
- console.log(error);
2238
- message = (_a = error.response) == null ? void 0 : _a.data.message;
2239
- } else if (error instanceof Error) {
2240
- message = error.message;
2241
- } else {
2242
- message = "Failed to create flash sale";
2243
- }
2244
- ui.toast.error("Failed to create flash sale", {
2245
- description: message
2246
- });
2247
- }
2248
- }
2249
- return /* @__PURE__ */ jsxRuntime.jsx(
2250
- FlashSaleForm,
2251
- {
2252
- onSubmit: handleSubmit,
2253
- onCancel: () => navigate("/flash-sales")
2254
- }
2255
- );
2256
- };
2257
2257
  const widgetModule = { widgets: [
2258
2258
  {
2259
2259
  Component: CampaignDetailWidget,
@@ -2278,13 +2278,13 @@ const routeModule = {
2278
2278
  Component: CouponCreate,
2279
2279
  path: "/coupons/create"
2280
2280
  },
2281
- {
2282
- Component: FlashSaleDetail,
2283
- path: "/flash-sales/:id"
2284
- },
2285
2281
  {
2286
2282
  Component: FlashSaleCreate,
2287
2283
  path: "/flash-sales/create"
2284
+ },
2285
+ {
2286
+ Component: FlashSaleDetail,
2287
+ path: "/flash-sales/:id"
2288
2288
  }
2289
2289
  ]
2290
2290
  };
@@ -2095,6 +2095,41 @@ const FlashSaleForm = ({
2095
2095
  ] }) })
2096
2096
  ] });
2097
2097
  };
2098
+ const FlashSaleCreate = () => {
2099
+ const navigate = useNavigate();
2100
+ async function handleSubmit(campaignData) {
2101
+ var _a;
2102
+ try {
2103
+ await axios.post("/admin/flash-sales", {
2104
+ ...campaignData,
2105
+ starts_at: new Date(campaignData.starts_at).toUTCString(),
2106
+ ends_at: new Date(campaignData.ends_at).toUTCString()
2107
+ });
2108
+ toast.success("Flash sale created successfully");
2109
+ navigate("/flash-sales");
2110
+ } catch (error) {
2111
+ let message;
2112
+ if (axios.isAxiosError(error)) {
2113
+ console.log(error);
2114
+ message = (_a = error.response) == null ? void 0 : _a.data.message;
2115
+ } else if (error instanceof Error) {
2116
+ message = error.message;
2117
+ } else {
2118
+ message = "Failed to create flash sale";
2119
+ }
2120
+ toast.error("Failed to create flash sale", {
2121
+ description: message
2122
+ });
2123
+ }
2124
+ }
2125
+ return /* @__PURE__ */ jsx(
2126
+ FlashSaleForm,
2127
+ {
2128
+ onSubmit: handleSubmit,
2129
+ onCancel: () => navigate("/flash-sales")
2130
+ }
2131
+ );
2132
+ };
2098
2133
  const useFlashSaleById = (id) => {
2099
2134
  const [data, setData] = useState(null);
2100
2135
  const [isLoading, setIsLoading] = useState(true);
@@ -2213,41 +2248,6 @@ const config = defineRouteConfig({
2213
2248
  label: "Flash Sale Detail",
2214
2249
  icon: Sparkles
2215
2250
  });
2216
- const FlashSaleCreate = () => {
2217
- const navigate = useNavigate();
2218
- async function handleSubmit(campaignData) {
2219
- var _a;
2220
- try {
2221
- await axios.post("/admin/flash-sales", {
2222
- ...campaignData,
2223
- starts_at: new Date(campaignData.starts_at).toUTCString(),
2224
- ends_at: new Date(campaignData.ends_at).toUTCString()
2225
- });
2226
- toast.success("Flash sale created successfully");
2227
- navigate("/flash-sales");
2228
- } catch (error) {
2229
- let message;
2230
- if (axios.isAxiosError(error)) {
2231
- console.log(error);
2232
- message = (_a = error.response) == null ? void 0 : _a.data.message;
2233
- } else if (error instanceof Error) {
2234
- message = error.message;
2235
- } else {
2236
- message = "Failed to create flash sale";
2237
- }
2238
- toast.error("Failed to create flash sale", {
2239
- description: message
2240
- });
2241
- }
2242
- }
2243
- return /* @__PURE__ */ jsx(
2244
- FlashSaleForm,
2245
- {
2246
- onSubmit: handleSubmit,
2247
- onCancel: () => navigate("/flash-sales")
2248
- }
2249
- );
2250
- };
2251
2251
  const widgetModule = { widgets: [
2252
2252
  {
2253
2253
  Component: CampaignDetailWidget,
@@ -2272,13 +2272,13 @@ const routeModule = {
2272
2272
  Component: CouponCreate,
2273
2273
  path: "/coupons/create"
2274
2274
  },
2275
- {
2276
- Component: FlashSaleDetail,
2277
- path: "/flash-sales/:id"
2278
- },
2279
2275
  {
2280
2276
  Component: FlashSaleCreate,
2281
2277
  path: "/flash-sales/create"
2278
+ },
2279
+ {
2280
+ Component: FlashSaleDetail,
2281
+ path: "/flash-sales/:id"
2282
2282
  }
2283
2283
  ]
2284
2284
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodashventure/medusa-campaign",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",