@lodashventure/medusa-parcel-shipping 0.2.11 → 0.2.13

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.
@@ -3,30 +3,16 @@ const jsxRuntime = require("react/jsx-runtime");
3
3
  const adminSdk = require("@medusajs/admin-sdk");
4
4
  const icons = require("@medusajs/icons");
5
5
  const react = require("react");
6
+ const Medusa = require("@medusajs/js-sdk");
6
7
  const ui = require("@medusajs/ui");
7
- const requestJson$1 = async (url, method = "GET", body) => {
8
- const response = await fetch(url, {
9
- method,
10
- headers: {
11
- "Content-Type": "application/json"
12
- },
13
- body: body ? JSON.stringify(body) : void 0,
14
- credentials: "include"
15
- });
16
- if (!response.ok) {
17
- let message = response.statusText;
18
- try {
19
- const payload = await response.json();
20
- message = (payload == null ? void 0 : payload.code) ?? (payload == null ? void 0 : payload.error) ?? message;
21
- } catch (_) {
22
- }
23
- throw new Error(message);
8
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
+ const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
10
+ const sdk$1 = new Medusa__default.default({
11
+ baseUrl: typeof window !== "undefined" ? window.location.origin : "/",
12
+ auth: {
13
+ type: "session"
24
14
  }
25
- if (response.status === 204) {
26
- return void 0;
27
- }
28
- return await response.json();
29
- };
15
+ });
30
16
  const toNumber$1 = (value) => {
31
17
  if (value.trim().length === 0) {
32
18
  return null;
@@ -52,9 +38,10 @@ function ParcelBoxesPage() {
52
38
  const refresh = react.useCallback(async () => {
53
39
  setLoading(true);
54
40
  try {
55
- const data = await requestJson$1(
56
- "/admin/parcel-boxes"
57
- );
41
+ const response = await sdk$1.client.fetch("/admin/parcel-boxes", {
42
+ method: "GET"
43
+ });
44
+ const data = await response.json();
58
45
  setBoxes(data.boxes ?? []);
59
46
  } catch (error) {
60
47
  ui.toast.error(error.message ?? "Failed to load boxes", {
@@ -101,14 +88,16 @@ function ParcelBoxesPage() {
101
88
  setSaving(true);
102
89
  try {
103
90
  if (formState.id) {
104
- await requestJson$1(
105
- `/admin/parcel-boxes/${formState.id}`,
106
- "PUT",
107
- payload
108
- );
91
+ await sdk$1.client.fetch(`/admin/parcel-boxes/${formState.id}`, {
92
+ method: "PUT",
93
+ body: payload
94
+ });
109
95
  ui.toast.success("Box updated", { dismissable: true });
110
96
  } else {
111
- await requestJson$1("/admin/parcel-boxes", "POST", payload);
97
+ await sdk$1.client.fetch("/admin/parcel-boxes", {
98
+ method: "POST",
99
+ body: payload
100
+ });
112
101
  ui.toast.success("Box created", { dismissable: true });
113
102
  }
114
103
  await refresh();
@@ -124,7 +113,9 @@ function ParcelBoxesPage() {
124
113
  const handleDelete = async (id) => {
125
114
  setDeletingId(id);
126
115
  try {
127
- await requestJson$1(`/admin/parcel-boxes/${id}`, "DELETE");
116
+ await sdk$1.client.fetch(`/admin/parcel-boxes/${id}`, {
117
+ method: "DELETE"
118
+ });
128
119
  ui.toast.success("Box removed", { dismissable: true });
129
120
  await refresh();
130
121
  } catch (error) {
@@ -137,8 +128,9 @@ function ParcelBoxesPage() {
137
128
  };
138
129
  const handleToggle = async (box) => {
139
130
  try {
140
- await requestJson$1(`/admin/parcel-boxes/${box.id}`, "PUT", {
141
- active: !box.active
131
+ await sdk$1.client.fetch(`/admin/parcel-boxes/${box.id}`, {
132
+ method: "PUT",
133
+ body: { active: !box.active }
142
134
  });
143
135
  await refresh();
144
136
  } catch (error) {
@@ -383,29 +375,12 @@ const config$1 = adminSdk.defineRouteConfig({
383
375
  label: "Parcel Boxes",
384
376
  icon: icons.FlyingBox
385
377
  });
386
- const requestJson = async (url, method = "GET", body) => {
387
- const response = await fetch(url, {
388
- method,
389
- headers: {
390
- "Content-Type": "application/json"
391
- },
392
- body: body ? JSON.stringify(body) : void 0,
393
- credentials: "include"
394
- });
395
- if (!response.ok) {
396
- let message = response.statusText;
397
- try {
398
- const payload = await response.json();
399
- message = (payload == null ? void 0 : payload.code) ?? (payload == null ? void 0 : payload.error) ?? message;
400
- } catch (_) {
401
- }
402
- throw new Error(message);
378
+ const sdk = new Medusa__default.default({
379
+ baseUrl: typeof window !== "undefined" ? window.location.origin : "/",
380
+ auth: {
381
+ type: "session"
403
382
  }
404
- if (response.status === 204) {
405
- return void 0;
406
- }
407
- return await response.json();
408
- };
383
+ });
409
384
  const toNumber = (value) => {
410
385
  if (value.trim().length === 0) {
411
386
  return null;
@@ -475,9 +450,10 @@ const BoxesSection = () => {
475
450
  const refresh = react.useCallback(async () => {
476
451
  setLoading(true);
477
452
  try {
478
- const data = await requestJson(
479
- "/admin/parcel-boxes"
480
- );
453
+ const response = await sdk.client.fetch("/admin/parcel-boxes", {
454
+ method: "GET"
455
+ });
456
+ const data = await response.json();
481
457
  setBoxes(data.boxes ?? []);
482
458
  } catch (error) {
483
459
  ui.toast.error(error.message ?? "Failed to load boxes", {
@@ -524,14 +500,16 @@ const BoxesSection = () => {
524
500
  setSaving(true);
525
501
  try {
526
502
  if (formState.id) {
527
- await requestJson(
528
- `/admin/parcel-boxes/${formState.id}`,
529
- "PUT",
530
- payload
531
- );
503
+ await sdk.client.fetch(`/admin/parcel-boxes/${formState.id}`, {
504
+ method: "PUT",
505
+ body: payload
506
+ });
532
507
  ui.toast.success("Box updated", { dismissable: true });
533
508
  } else {
534
- await requestJson("/admin/parcel-boxes", "POST", payload);
509
+ await sdk.client.fetch("/admin/parcel-boxes", {
510
+ method: "POST",
511
+ body: payload
512
+ });
535
513
  ui.toast.success("Box created", { dismissable: true });
536
514
  }
537
515
  await refresh();
@@ -547,7 +525,9 @@ const BoxesSection = () => {
547
525
  const handleDelete = async (id) => {
548
526
  setDeletingId(id);
549
527
  try {
550
- await requestJson(`/admin/parcel-boxes/${id}`, "DELETE");
528
+ await sdk.client.fetch(`/admin/parcel-boxes/${id}`, {
529
+ method: "DELETE"
530
+ });
551
531
  ui.toast.success("Box removed", { dismissable: true });
552
532
  await refresh();
553
533
  } catch (error) {
@@ -560,8 +540,9 @@ const BoxesSection = () => {
560
540
  };
561
541
  const handleToggle = async (box) => {
562
542
  try {
563
- await requestJson(`/admin/parcel-boxes/${box.id}`, "PUT", {
564
- active: !box.active
543
+ await sdk.client.fetch(`/admin/parcel-boxes/${box.id}`, {
544
+ method: "PUT",
545
+ body: { active: !box.active }
565
546
  });
566
547
  await refresh();
567
548
  } catch (error) {
@@ -815,9 +796,10 @@ const RatesSection = () => {
815
796
  const refresh = react.useCallback(async () => {
816
797
  setLoading(true);
817
798
  try {
818
- const data = await requestJson(
819
- "/admin/shipping-config/rates"
820
- );
799
+ const response = await sdk.client.fetch("/admin/shipping-config/rates", {
800
+ method: "GET"
801
+ });
802
+ const data = await response.json();
821
803
  setRates(
822
804
  (data.rates ?? []).map((rate) => ({
823
805
  ...rate,
@@ -836,7 +818,10 @@ const RatesSection = () => {
836
818
  var _a, _b, _c;
837
819
  setCurrenciesLoading(true);
838
820
  try {
839
- const data = await requestJson("/admin/currencies");
821
+ const response = await sdk.client.fetch("/admin/currencies", {
822
+ method: "GET"
823
+ });
824
+ const data = await response.json();
840
825
  const supported = ((_b = (_a = data.store) == null ? void 0 : _a.supported_currencies) == null ? void 0 : _b.map(
841
826
  (item) => item.code.toUpperCase()
842
827
  )) ?? [];
@@ -915,14 +900,16 @@ const RatesSection = () => {
915
900
  setSaving(true);
916
901
  try {
917
902
  if (formState.id) {
918
- await requestJson(
919
- `/admin/shipping-config/rates/${formState.id}`,
920
- "PUT",
921
- payload
922
- );
903
+ await sdk.client.fetch(`/admin/shipping-config/rates/${formState.id}`, {
904
+ method: "PUT",
905
+ body: payload
906
+ });
923
907
  ui.toast.success("Rate updated", { dismissable: true });
924
908
  } else {
925
- await requestJson("/admin/shipping-config/rates", "POST", payload);
909
+ await sdk.client.fetch("/admin/shipping-config/rates", {
910
+ method: "POST",
911
+ body: payload
912
+ });
926
913
  ui.toast.success("Rate created", { dismissable: true });
927
914
  }
928
915
  await refresh();
@@ -938,7 +925,9 @@ const RatesSection = () => {
938
925
  const handleDelete = async (id) => {
939
926
  setDeletingId(id);
940
927
  try {
941
- await requestJson(`/admin/shipping-config/rates/${id}`, "DELETE");
928
+ await sdk.client.fetch(`/admin/shipping-config/rates/${id}`, {
929
+ method: "DELETE"
930
+ });
942
931
  ui.toast.success("Rate removed", { dismissable: true });
943
932
  await refresh();
944
933
  } catch (error) {
@@ -951,8 +940,9 @@ const RatesSection = () => {
951
940
  };
952
941
  const handleToggle = async (rate) => {
953
942
  try {
954
- await requestJson(`/admin/shipping-config/rates/${rate.id}`, "PUT", {
955
- active: !rate.active
943
+ await sdk.client.fetch(`/admin/shipping-config/rates/${rate.id}`, {
944
+ method: "PUT",
945
+ body: { active: !rate.active }
956
946
  });
957
947
  await refresh();
958
948
  } catch (error) {
@@ -1195,9 +1185,10 @@ const AreasSection = () => {
1195
1185
  const refresh = react.useCallback(async () => {
1196
1186
  setLoading(true);
1197
1187
  try {
1198
- const data = await requestJson(
1199
- "/admin/shipping-config/areas"
1200
- );
1188
+ const response = await sdk.client.fetch("/admin/shipping-config/areas", {
1189
+ method: "GET"
1190
+ });
1191
+ const data = await response.json();
1201
1192
  setAreas(data.areas ?? []);
1202
1193
  } catch (error) {
1203
1194
  ui.toast.error(error.message ?? "Failed to load service areas", {
@@ -1237,14 +1228,16 @@ const AreasSection = () => {
1237
1228
  setSaving(true);
1238
1229
  try {
1239
1230
  if (formState.id) {
1240
- await requestJson(
1241
- `/admin/shipping-config/areas/${formState.id}`,
1242
- "PUT",
1243
- payload
1244
- );
1231
+ await sdk.client.fetch(`/admin/shipping-config/areas/${formState.id}`, {
1232
+ method: "PUT",
1233
+ body: payload
1234
+ });
1245
1235
  ui.toast.success("Service area updated", { dismissable: true });
1246
1236
  } else {
1247
- await requestJson("/admin/shipping-config/areas", "POST", payload);
1237
+ await sdk.client.fetch("/admin/shipping-config/areas", {
1238
+ method: "POST",
1239
+ body: payload
1240
+ });
1248
1241
  ui.toast.success("Service area created", { dismissable: true });
1249
1242
  }
1250
1243
  await refresh();
@@ -1260,7 +1253,9 @@ const AreasSection = () => {
1260
1253
  const handleDelete = async (id) => {
1261
1254
  setDeletingId(id);
1262
1255
  try {
1263
- await requestJson(`/admin/shipping-config/areas/${id}`, "DELETE");
1256
+ await sdk.client.fetch(`/admin/shipping-config/areas/${id}`, {
1257
+ method: "DELETE"
1258
+ });
1264
1259
  ui.toast.success("Service area removed", { dismissable: true });
1265
1260
  await refresh();
1266
1261
  } catch (error) {
@@ -1273,8 +1268,9 @@ const AreasSection = () => {
1273
1268
  };
1274
1269
  const handleToggle = async (area) => {
1275
1270
  try {
1276
- await requestJson(`/admin/shipping-config/areas/${area.id}`, "PUT", {
1277
- active: !area.active
1271
+ await sdk.client.fetch(`/admin/shipping-config/areas/${area.id}`, {
1272
+ method: "PUT",
1273
+ body: { active: !area.active }
1278
1274
  });
1279
1275
  await refresh();
1280
1276
  } catch (error) {
@@ -2,30 +2,14 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { defineRouteConfig } from "@medusajs/admin-sdk";
3
3
  import { FlyingBox, Directions } from "@medusajs/icons";
4
4
  import { useState, useCallback, useEffect, useMemo } from "react";
5
+ import Medusa from "@medusajs/js-sdk";
5
6
  import { toast, Table, Text, Badge, Switch, Button, Container, Heading, Label, Input } from "@medusajs/ui";
6
- const requestJson$1 = async (url, method = "GET", body) => {
7
- const response = await fetch(url, {
8
- method,
9
- headers: {
10
- "Content-Type": "application/json"
11
- },
12
- body: body ? JSON.stringify(body) : void 0,
13
- credentials: "include"
14
- });
15
- if (!response.ok) {
16
- let message = response.statusText;
17
- try {
18
- const payload = await response.json();
19
- message = (payload == null ? void 0 : payload.code) ?? (payload == null ? void 0 : payload.error) ?? message;
20
- } catch (_) {
21
- }
22
- throw new Error(message);
7
+ const sdk$1 = new Medusa({
8
+ baseUrl: typeof window !== "undefined" ? window.location.origin : "/",
9
+ auth: {
10
+ type: "session"
23
11
  }
24
- if (response.status === 204) {
25
- return void 0;
26
- }
27
- return await response.json();
28
- };
12
+ });
29
13
  const toNumber$1 = (value) => {
30
14
  if (value.trim().length === 0) {
31
15
  return null;
@@ -51,9 +35,10 @@ function ParcelBoxesPage() {
51
35
  const refresh = useCallback(async () => {
52
36
  setLoading(true);
53
37
  try {
54
- const data = await requestJson$1(
55
- "/admin/parcel-boxes"
56
- );
38
+ const response = await sdk$1.client.fetch("/admin/parcel-boxes", {
39
+ method: "GET"
40
+ });
41
+ const data = await response.json();
57
42
  setBoxes(data.boxes ?? []);
58
43
  } catch (error) {
59
44
  toast.error(error.message ?? "Failed to load boxes", {
@@ -100,14 +85,16 @@ function ParcelBoxesPage() {
100
85
  setSaving(true);
101
86
  try {
102
87
  if (formState.id) {
103
- await requestJson$1(
104
- `/admin/parcel-boxes/${formState.id}`,
105
- "PUT",
106
- payload
107
- );
88
+ await sdk$1.client.fetch(`/admin/parcel-boxes/${formState.id}`, {
89
+ method: "PUT",
90
+ body: payload
91
+ });
108
92
  toast.success("Box updated", { dismissable: true });
109
93
  } else {
110
- await requestJson$1("/admin/parcel-boxes", "POST", payload);
94
+ await sdk$1.client.fetch("/admin/parcel-boxes", {
95
+ method: "POST",
96
+ body: payload
97
+ });
111
98
  toast.success("Box created", { dismissable: true });
112
99
  }
113
100
  await refresh();
@@ -123,7 +110,9 @@ function ParcelBoxesPage() {
123
110
  const handleDelete = async (id) => {
124
111
  setDeletingId(id);
125
112
  try {
126
- await requestJson$1(`/admin/parcel-boxes/${id}`, "DELETE");
113
+ await sdk$1.client.fetch(`/admin/parcel-boxes/${id}`, {
114
+ method: "DELETE"
115
+ });
127
116
  toast.success("Box removed", { dismissable: true });
128
117
  await refresh();
129
118
  } catch (error) {
@@ -136,8 +125,9 @@ function ParcelBoxesPage() {
136
125
  };
137
126
  const handleToggle = async (box) => {
138
127
  try {
139
- await requestJson$1(`/admin/parcel-boxes/${box.id}`, "PUT", {
140
- active: !box.active
128
+ await sdk$1.client.fetch(`/admin/parcel-boxes/${box.id}`, {
129
+ method: "PUT",
130
+ body: { active: !box.active }
141
131
  });
142
132
  await refresh();
143
133
  } catch (error) {
@@ -382,29 +372,12 @@ const config$1 = defineRouteConfig({
382
372
  label: "Parcel Boxes",
383
373
  icon: FlyingBox
384
374
  });
385
- const requestJson = async (url, method = "GET", body) => {
386
- const response = await fetch(url, {
387
- method,
388
- headers: {
389
- "Content-Type": "application/json"
390
- },
391
- body: body ? JSON.stringify(body) : void 0,
392
- credentials: "include"
393
- });
394
- if (!response.ok) {
395
- let message = response.statusText;
396
- try {
397
- const payload = await response.json();
398
- message = (payload == null ? void 0 : payload.code) ?? (payload == null ? void 0 : payload.error) ?? message;
399
- } catch (_) {
400
- }
401
- throw new Error(message);
375
+ const sdk = new Medusa({
376
+ baseUrl: typeof window !== "undefined" ? window.location.origin : "/",
377
+ auth: {
378
+ type: "session"
402
379
  }
403
- if (response.status === 204) {
404
- return void 0;
405
- }
406
- return await response.json();
407
- };
380
+ });
408
381
  const toNumber = (value) => {
409
382
  if (value.trim().length === 0) {
410
383
  return null;
@@ -474,9 +447,10 @@ const BoxesSection = () => {
474
447
  const refresh = useCallback(async () => {
475
448
  setLoading(true);
476
449
  try {
477
- const data = await requestJson(
478
- "/admin/parcel-boxes"
479
- );
450
+ const response = await sdk.client.fetch("/admin/parcel-boxes", {
451
+ method: "GET"
452
+ });
453
+ const data = await response.json();
480
454
  setBoxes(data.boxes ?? []);
481
455
  } catch (error) {
482
456
  toast.error(error.message ?? "Failed to load boxes", {
@@ -523,14 +497,16 @@ const BoxesSection = () => {
523
497
  setSaving(true);
524
498
  try {
525
499
  if (formState.id) {
526
- await requestJson(
527
- `/admin/parcel-boxes/${formState.id}`,
528
- "PUT",
529
- payload
530
- );
500
+ await sdk.client.fetch(`/admin/parcel-boxes/${formState.id}`, {
501
+ method: "PUT",
502
+ body: payload
503
+ });
531
504
  toast.success("Box updated", { dismissable: true });
532
505
  } else {
533
- await requestJson("/admin/parcel-boxes", "POST", payload);
506
+ await sdk.client.fetch("/admin/parcel-boxes", {
507
+ method: "POST",
508
+ body: payload
509
+ });
534
510
  toast.success("Box created", { dismissable: true });
535
511
  }
536
512
  await refresh();
@@ -546,7 +522,9 @@ const BoxesSection = () => {
546
522
  const handleDelete = async (id) => {
547
523
  setDeletingId(id);
548
524
  try {
549
- await requestJson(`/admin/parcel-boxes/${id}`, "DELETE");
525
+ await sdk.client.fetch(`/admin/parcel-boxes/${id}`, {
526
+ method: "DELETE"
527
+ });
550
528
  toast.success("Box removed", { dismissable: true });
551
529
  await refresh();
552
530
  } catch (error) {
@@ -559,8 +537,9 @@ const BoxesSection = () => {
559
537
  };
560
538
  const handleToggle = async (box) => {
561
539
  try {
562
- await requestJson(`/admin/parcel-boxes/${box.id}`, "PUT", {
563
- active: !box.active
540
+ await sdk.client.fetch(`/admin/parcel-boxes/${box.id}`, {
541
+ method: "PUT",
542
+ body: { active: !box.active }
564
543
  });
565
544
  await refresh();
566
545
  } catch (error) {
@@ -814,9 +793,10 @@ const RatesSection = () => {
814
793
  const refresh = useCallback(async () => {
815
794
  setLoading(true);
816
795
  try {
817
- const data = await requestJson(
818
- "/admin/shipping-config/rates"
819
- );
796
+ const response = await sdk.client.fetch("/admin/shipping-config/rates", {
797
+ method: "GET"
798
+ });
799
+ const data = await response.json();
820
800
  setRates(
821
801
  (data.rates ?? []).map((rate) => ({
822
802
  ...rate,
@@ -835,7 +815,10 @@ const RatesSection = () => {
835
815
  var _a, _b, _c;
836
816
  setCurrenciesLoading(true);
837
817
  try {
838
- const data = await requestJson("/admin/currencies");
818
+ const response = await sdk.client.fetch("/admin/currencies", {
819
+ method: "GET"
820
+ });
821
+ const data = await response.json();
839
822
  const supported = ((_b = (_a = data.store) == null ? void 0 : _a.supported_currencies) == null ? void 0 : _b.map(
840
823
  (item) => item.code.toUpperCase()
841
824
  )) ?? [];
@@ -914,14 +897,16 @@ const RatesSection = () => {
914
897
  setSaving(true);
915
898
  try {
916
899
  if (formState.id) {
917
- await requestJson(
918
- `/admin/shipping-config/rates/${formState.id}`,
919
- "PUT",
920
- payload
921
- );
900
+ await sdk.client.fetch(`/admin/shipping-config/rates/${formState.id}`, {
901
+ method: "PUT",
902
+ body: payload
903
+ });
922
904
  toast.success("Rate updated", { dismissable: true });
923
905
  } else {
924
- await requestJson("/admin/shipping-config/rates", "POST", payload);
906
+ await sdk.client.fetch("/admin/shipping-config/rates", {
907
+ method: "POST",
908
+ body: payload
909
+ });
925
910
  toast.success("Rate created", { dismissable: true });
926
911
  }
927
912
  await refresh();
@@ -937,7 +922,9 @@ const RatesSection = () => {
937
922
  const handleDelete = async (id) => {
938
923
  setDeletingId(id);
939
924
  try {
940
- await requestJson(`/admin/shipping-config/rates/${id}`, "DELETE");
925
+ await sdk.client.fetch(`/admin/shipping-config/rates/${id}`, {
926
+ method: "DELETE"
927
+ });
941
928
  toast.success("Rate removed", { dismissable: true });
942
929
  await refresh();
943
930
  } catch (error) {
@@ -950,8 +937,9 @@ const RatesSection = () => {
950
937
  };
951
938
  const handleToggle = async (rate) => {
952
939
  try {
953
- await requestJson(`/admin/shipping-config/rates/${rate.id}`, "PUT", {
954
- active: !rate.active
940
+ await sdk.client.fetch(`/admin/shipping-config/rates/${rate.id}`, {
941
+ method: "PUT",
942
+ body: { active: !rate.active }
955
943
  });
956
944
  await refresh();
957
945
  } catch (error) {
@@ -1194,9 +1182,10 @@ const AreasSection = () => {
1194
1182
  const refresh = useCallback(async () => {
1195
1183
  setLoading(true);
1196
1184
  try {
1197
- const data = await requestJson(
1198
- "/admin/shipping-config/areas"
1199
- );
1185
+ const response = await sdk.client.fetch("/admin/shipping-config/areas", {
1186
+ method: "GET"
1187
+ });
1188
+ const data = await response.json();
1200
1189
  setAreas(data.areas ?? []);
1201
1190
  } catch (error) {
1202
1191
  toast.error(error.message ?? "Failed to load service areas", {
@@ -1236,14 +1225,16 @@ const AreasSection = () => {
1236
1225
  setSaving(true);
1237
1226
  try {
1238
1227
  if (formState.id) {
1239
- await requestJson(
1240
- `/admin/shipping-config/areas/${formState.id}`,
1241
- "PUT",
1242
- payload
1243
- );
1228
+ await sdk.client.fetch(`/admin/shipping-config/areas/${formState.id}`, {
1229
+ method: "PUT",
1230
+ body: payload
1231
+ });
1244
1232
  toast.success("Service area updated", { dismissable: true });
1245
1233
  } else {
1246
- await requestJson("/admin/shipping-config/areas", "POST", payload);
1234
+ await sdk.client.fetch("/admin/shipping-config/areas", {
1235
+ method: "POST",
1236
+ body: payload
1237
+ });
1247
1238
  toast.success("Service area created", { dismissable: true });
1248
1239
  }
1249
1240
  await refresh();
@@ -1259,7 +1250,9 @@ const AreasSection = () => {
1259
1250
  const handleDelete = async (id) => {
1260
1251
  setDeletingId(id);
1261
1252
  try {
1262
- await requestJson(`/admin/shipping-config/areas/${id}`, "DELETE");
1253
+ await sdk.client.fetch(`/admin/shipping-config/areas/${id}`, {
1254
+ method: "DELETE"
1255
+ });
1263
1256
  toast.success("Service area removed", { dismissable: true });
1264
1257
  await refresh();
1265
1258
  } catch (error) {
@@ -1272,8 +1265,9 @@ const AreasSection = () => {
1272
1265
  };
1273
1266
  const handleToggle = async (area) => {
1274
1267
  try {
1275
- await requestJson(`/admin/shipping-config/areas/${area.id}`, "PUT", {
1276
- active: !area.active
1268
+ await sdk.client.fetch(`/admin/shipping-config/areas/${area.id}`, {
1269
+ method: "PUT",
1270
+ body: { active: !area.active }
1277
1271
  });
1278
1272
  await refresh();
1279
1273
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lodashventure/medusa-parcel-shipping",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Parcel box selection and Thailand shipping quotes for Medusa.",
5
5
  "author": "LodashVenture",
6
6
  "license": "MIT",