@lodashventure/medusa-parcel-shipping 0.4.5 → 0.4.6

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.
Files changed (46) hide show
  1. package/.medusa/server/src/admin/index.js +9 -459
  2. package/.medusa/server/src/admin/index.mjs +10 -460
  3. package/.medusa/server/src/index.js +2 -7
  4. package/.medusa/server/src/modules/parcel-shipping/migrations/Migration20251106000000.js +42 -0
  5. package/package.json +25 -26
  6. package/.medusa/server/src/api/admin/documents/document-packing-slip-settings/route.js +0 -65
  7. package/.medusa/server/src/api/admin/documents/packing-slip/preview/route.js +0 -47
  8. package/.medusa/server/src/api/admin/documents/packing-slip/route.js +0 -105
  9. package/.medusa/server/src/links/index.js +0 -9
  10. package/.medusa/server/src/links/packing-slip-order.js +0 -13
  11. package/.medusa/server/src/modules/documents/index.js +0 -24
  12. package/.medusa/server/src/modules/documents/models/document-invoice.js +0 -20
  13. package/.medusa/server/src/modules/documents/models/document-packing-slip-settings.js +0 -29
  14. package/.medusa/server/src/modules/documents/models/document-packing-slip.js +0 -32
  15. package/.medusa/server/src/modules/documents/models/document-settings.js +0 -32
  16. package/.medusa/server/src/modules/documents/models/index.js +0 -15
  17. package/.medusa/server/src/modules/documents/service.js +0 -226
  18. package/.medusa/server/src/modules/documents/services/generators/invoice-generator.js +0 -73
  19. package/.medusa/server/src/modules/documents/services/generators/packing-slip-generator.js +0 -73
  20. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/basic-logo.js +0 -55
  21. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/basic.js +0 -52
  22. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/customer-info.js +0 -69
  23. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/header-for-logo.js +0 -32
  24. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/header-logo.js +0 -29
  25. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/header.js +0 -35
  26. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/hr.js +0 -23
  27. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/invoice-info.js +0 -35
  28. package/.medusa/server/src/modules/documents/services/templates/invoices/basic/parts/table.js +0 -97
  29. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/basic.js +0 -52
  30. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/customer-info-small.js +0 -69
  31. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/customer-info.js +0 -65
  32. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/header-small.js +0 -37
  33. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/header.js +0 -37
  34. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/hr.js +0 -32
  35. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/table-items-small.js +0 -44
  36. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/table-items.js +0 -44
  37. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/table-order-info-small.js +0 -35
  38. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/parts/table-order-info.js +0 -36
  39. package/.medusa/server/src/modules/documents/services/templates/packing-slips/basic/small.js +0 -53
  40. package/.medusa/server/src/modules/documents/types/api.js +0 -14
  41. package/.medusa/server/src/modules/documents/types/constants.js +0 -17
  42. package/.medusa/server/src/modules/documents/types/dto.js +0 -14
  43. package/.medusa/server/src/modules/documents/types/template-kind.js +0 -25
  44. package/.medusa/server/src/modules/documents/utils/currency.js +0 -25
  45. package/.medusa/server/src/workflows/assign-packing-slip.js +0 -35
  46. package/.medusa/server/src/workflows/index.js +0 -9
@@ -1,231 +1,10 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { Container, Heading, Text, Toaster, Badge, Button, toast, Drawer, Label, Select, Input, Switch, Table, Prompt, Textarea } from "@medusajs/ui";
4
2
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
5
- import { DocumentText, MapPin, ArchiveBox, CurrencyDollarSolid, HandTruck } from "@medusajs/icons";
6
- import { RefreshCw, Download, Plus, Package, AlertCircle, Truck, Clock, Edit, Trash, Eye } from "lucide-react";
3
+ import { Container, Heading, Button, Text, Badge, Drawer, Label, Select, Input, Switch, toast, Table, Prompt, Textarea } from "@medusajs/ui";
4
+ import { useState, useEffect } from "react";
5
+ import { Package, AlertCircle, Truck, Clock, Plus, Edit, Trash } from "lucide-react";
6
+ import { MapPin, ArchiveBox, CurrencyDollarSolid, HandTruck } from "@medusajs/icons";
7
7
  import "@medusajs/admin-shared";
8
- const OrderPackingSlipWidget = ({ data }) => {
9
- const [packingSlip, setPackingSlip] = useState(null);
10
- const [loading, setLoading] = useState(true);
11
- const [generating, setGenerating] = useState(false);
12
- const [error, setError] = useState(null);
13
- const order = data;
14
- useEffect(() => {
15
- fetchPackingSlip();
16
- }, [order.id]);
17
- const fetchPackingSlip = async () => {
18
- setLoading(true);
19
- setError(null);
20
- try {
21
- const response = await fetch(
22
- `/admin/documents/packing-slip?orderId=${order.id}`,
23
- {
24
- credentials: "include"
25
- }
26
- );
27
- if (!response.ok) {
28
- throw new Error("Failed to fetch packing slip");
29
- }
30
- const data2 = await response.json();
31
- setPackingSlip(data2.packingSlip || null);
32
- } catch (err) {
33
- console.error("Error fetching packing slip:", err);
34
- setError(err.message);
35
- } finally {
36
- setLoading(false);
37
- }
38
- };
39
- const generatePackingSlip = async () => {
40
- setGenerating(true);
41
- setError(null);
42
- try {
43
- const response = await fetch("/admin/documents/packing-slip", {
44
- method: "POST",
45
- headers: {
46
- "Content-Type": "application/json"
47
- },
48
- credentials: "include",
49
- body: JSON.stringify({
50
- order_id: order.id
51
- })
52
- });
53
- if (!response.ok) {
54
- const errorData = await response.json().catch(() => ({
55
- message: `HTTP ${response.status}: ${response.statusText}`
56
- }));
57
- throw new Error(errorData.message || "Failed to generate packing slip");
58
- }
59
- const data2 = await response.json();
60
- setPackingSlip(data2.packingSlip);
61
- toast.success("สร้างใบแพ็คสินค้าสำเร็จ", {
62
- description: `หมายเลขเอกสาร: ${data2.packingSlip.number}`
63
- });
64
- } catch (err) {
65
- setError(err.message);
66
- toast.error("เกิดข้อผิดพลาด", {
67
- description: err.message
68
- });
69
- } finally {
70
- setGenerating(false);
71
- }
72
- };
73
- const downloadPackingSlip = async () => {
74
- var _a;
75
- try {
76
- const response = await fetch(
77
- `/admin/documents/packing-slip?orderId=${order.id}&includeBuffer=true`,
78
- {
79
- credentials: "include"
80
- }
81
- );
82
- if (!response.ok) {
83
- throw new Error("Failed to fetch packing slip");
84
- }
85
- const data2 = await response.json();
86
- if ((_a = data2.packingSlip) == null ? void 0 : _a.pdfBase64) {
87
- const byteCharacters = atob(data2.packingSlip.pdfBase64);
88
- const byteNumbers = new Array(byteCharacters.length);
89
- for (let i = 0; i < byteCharacters.length; i++) {
90
- byteNumbers[i] = byteCharacters.charCodeAt(i);
91
- }
92
- const byteArray = new Uint8Array(byteNumbers);
93
- const blob = new Blob([byteArray], { type: "application/pdf" });
94
- const url = window.URL.createObjectURL(blob);
95
- const link = document.createElement("a");
96
- link.href = url;
97
- link.download = `packing-slip-${data2.packingSlip.number}.pdf`;
98
- document.body.appendChild(link);
99
- link.click();
100
- document.body.removeChild(link);
101
- window.URL.revokeObjectURL(url);
102
- toast.success("ดาวน์โหลดสำเร็จ");
103
- } else {
104
- throw new Error("PDF data not available");
105
- }
106
- } catch (err) {
107
- toast.error("เกิดข้อผิดพลาดในการดาวน์โหลด", {
108
- description: err.message
109
- });
110
- }
111
- };
112
- const formatDateTime = (dateString) => {
113
- const date = new Date(dateString);
114
- return new Intl.DateTimeFormat("th-TH", {
115
- year: "numeric",
116
- month: "short",
117
- day: "numeric",
118
- hour: "2-digit",
119
- minute: "2-digit"
120
- }).format(date);
121
- };
122
- if (loading) {
123
- return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
124
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
125
- /* @__PURE__ */ jsx(DocumentText, { className: "text-ui-fg-subtle" }),
126
- /* @__PURE__ */ jsx(Heading, { level: "h2", children: "ใบแพ็คสินค้า" })
127
- ] }) }),
128
- /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "กำลังโหลด..." }) })
129
- ] });
130
- }
131
- if (error && !packingSlip) {
132
- return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
133
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
134
- /* @__PURE__ */ jsx(DocumentText, { className: "text-ui-fg-subtle" }),
135
- /* @__PURE__ */ jsx(Heading, { level: "h2", children: "ใบแพ็คสินค้า" })
136
- ] }) }),
137
- /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(Text, { className: "text-red-500", children: error }) })
138
- ] });
139
- }
140
- return /* @__PURE__ */ jsxs(Fragment, { children: [
141
- /* @__PURE__ */ jsx(Toaster, {}),
142
- /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
143
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
144
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
145
- /* @__PURE__ */ jsx(DocumentText, { className: "text-ui-fg-subtle" }),
146
- /* @__PURE__ */ jsx(Heading, { level: "h2", children: "ใบแพ็คสินค้า" }),
147
- packingSlip && /* @__PURE__ */ jsx(Badge, { color: "green", size: "small", children: "สร้างแล้ว" })
148
- ] }),
149
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
150
- packingSlip && /* @__PURE__ */ jsxs(Fragment, { children: [
151
- /* @__PURE__ */ jsx(
152
- Button,
153
- {
154
- size: "small",
155
- variant: "transparent",
156
- onClick: fetchPackingSlip,
157
- children: /* @__PURE__ */ jsx(RefreshCw, { size: 16 })
158
- }
159
- ),
160
- /* @__PURE__ */ jsxs(
161
- Button,
162
- {
163
- size: "small",
164
- variant: "secondary",
165
- onClick: downloadPackingSlip,
166
- children: [
167
- /* @__PURE__ */ jsx(Download, { size: 16 }),
168
- "ดาวน์โหลด"
169
- ]
170
- }
171
- )
172
- ] }),
173
- !packingSlip && /* @__PURE__ */ jsxs(
174
- Button,
175
- {
176
- size: "small",
177
- onClick: generatePackingSlip,
178
- isLoading: generating,
179
- children: [
180
- /* @__PURE__ */ jsx(Plus, { size: 16 }),
181
- "สร้างใบแพ็คสินค้า"
182
- ]
183
- }
184
- )
185
- ] })
186
- ] }),
187
- /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: packingSlip ? /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
188
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
189
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
190
- /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: "หมายเลขเอกสาร" }),
191
- /* @__PURE__ */ jsx(Text, { weight: "plus", className: "font-mono", children: packingSlip.number })
192
- ] }),
193
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
194
- /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: "สร้างเมื่อ" }),
195
- /* @__PURE__ */ jsx(Text, { size: "small", children: formatDateTime(packingSlip.created_at) })
196
- ] })
197
- ] }),
198
- /* @__PURE__ */ jsx("div", { className: "pt-4 border-t", children: /* @__PURE__ */ jsxs(Text, { size: "xsmall", className: "text-ui-fg-muted", children: [
199
- "Document ID: ",
200
- packingSlip.id
201
- ] }) }),
202
- /* @__PURE__ */ jsxs("div", { className: "pt-4 border-t", children: [
203
- /* @__PURE__ */ jsxs(
204
- Button,
205
- {
206
- size: "small",
207
- variant: "secondary",
208
- onClick: generatePackingSlip,
209
- isLoading: generating,
210
- children: [
211
- /* @__PURE__ */ jsx(RefreshCw, { size: 16 }),
212
- "สร้างใหม่"
213
- ]
214
- }
215
- ),
216
- /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-muted mt-2", children: "การสร้างใหม่จะแทนที่ใบแพ็คสินค้าเดิม" })
217
- ] })
218
- ] }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-8 text-center", children: [
219
- /* @__PURE__ */ jsx(DocumentText, { className: "text-ui-fg-muted mb-4" }),
220
- /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle mb-2", children: "ยังไม่มีใบแพ็คสินค้าสำหรับคำสั่งซื้อนี้" }),
221
- /* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-muted mb-4", children: "คลิกปุ่มด้านบนเพื่อสร้างใบแพ็คสินค้า" })
222
- ] }) })
223
- ] })
224
- ] });
225
- };
226
- defineWidgetConfig({
227
- zone: "order.details.after"
228
- });
229
8
  const OrderShippingQuoteWidget = ({ data }) => {
230
9
  const [quote, setQuote] = useState(null);
231
10
  const [loading, setLoading] = useState(false);
@@ -873,7 +652,7 @@ const AreasPage = () => {
873
652
  /* @__PURE__ */ jsx(ServiceAreasTable, {})
874
653
  ] }) });
875
654
  };
876
- const config$4 = defineRouteConfig({
655
+ const config$3 = defineRouteConfig({
877
656
  icon: MapPin,
878
657
  label: "พื้นที่บริการ"
879
658
  });
@@ -1281,7 +1060,7 @@ const BoxesPage = () => {
1281
1060
  /* @__PURE__ */ jsx(ParcelBoxesTable, {})
1282
1061
  ] }) });
1283
1062
  };
1284
- const config$3 = defineRouteConfig({
1063
+ const config$2 = defineRouteConfig({
1285
1064
  icon: ArchiveBox,
1286
1065
  label: "กล่องพัสดุ"
1287
1066
  });
@@ -1724,225 +1503,10 @@ const MaterialCostsPage = () => {
1724
1503
  /* @__PURE__ */ jsx(MaterialCostsTable, {})
1725
1504
  ] }) });
1726
1505
  };
1727
- const config$2 = defineRouteConfig({
1506
+ const config$1 = defineRouteConfig({
1728
1507
  icon: CurrencyDollarSolid,
1729
1508
  label: "ต้นทุนวัสดุ"
1730
1509
  });
1731
- const PackingSlipSettingsPage = () => {
1732
- const [settings, setSettings] = useState(null);
1733
- const [loading, setLoading] = useState(true);
1734
- const [saving, setSaving] = useState(false);
1735
- const [formatNumber, setFormatNumber] = useState("");
1736
- const [forcedNumber, setForcedNumber] = useState("");
1737
- const [template, setTemplate] = useState("BASIC");
1738
- useEffect(() => {
1739
- fetchSettings();
1740
- }, []);
1741
- const fetchSettings = async () => {
1742
- setLoading(true);
1743
- try {
1744
- const response = await fetch(
1745
- "/admin/documents/document-packing-slip-settings",
1746
- {
1747
- credentials: "include"
1748
- }
1749
- );
1750
- if (!response.ok) {
1751
- throw new Error("Failed to fetch settings");
1752
- }
1753
- const data = await response.json();
1754
- if (data.settings) {
1755
- setSettings(data.settings);
1756
- setFormatNumber(data.settings.formatNumber || "");
1757
- setForcedNumber(data.settings.forcedNumber || "");
1758
- setTemplate(data.settings.template || "BASIC");
1759
- }
1760
- } catch (err) {
1761
- toast.error("เกิดข้อผิดพลาด", {
1762
- description: err.message
1763
- });
1764
- } finally {
1765
- setLoading(false);
1766
- }
1767
- };
1768
- const handleSave = async () => {
1769
- setSaving(true);
1770
- try {
1771
- const response = await fetch(
1772
- "/admin/documents/document-packing-slip-settings",
1773
- {
1774
- method: "POST",
1775
- headers: {
1776
- "Content-Type": "application/json"
1777
- },
1778
- credentials: "include",
1779
- body: JSON.stringify({
1780
- formatNumber: formatNumber || void 0,
1781
- forcedNumber: forcedNumber || void 0,
1782
- template
1783
- })
1784
- }
1785
- );
1786
- if (!response.ok) {
1787
- const errorData = await response.json().catch(() => ({
1788
- message: `HTTP ${response.status}: ${response.statusText}`
1789
- }));
1790
- throw new Error(errorData.message || "Failed to save settings");
1791
- }
1792
- const data = await response.json();
1793
- setSettings(data.settings);
1794
- toast.success("บันทึกสำเร็จ", {
1795
- description: "ตั้งค่าใบแพ็คสินค้าได้รับการบันทึกแล้ว"
1796
- });
1797
- } catch (err) {
1798
- toast.error("เกิดข้อผิดพลาดในการบันทึก", {
1799
- description: err.message
1800
- });
1801
- } finally {
1802
- setSaving(false);
1803
- }
1804
- };
1805
- const handlePreview = async () => {
1806
- var _a;
1807
- try {
1808
- const response = await fetch(
1809
- `/admin/documents/packing-slip/preview?template=${template}`,
1810
- {
1811
- credentials: "include"
1812
- }
1813
- );
1814
- if (!response.ok) {
1815
- const errorData = await response.json().catch(() => ({
1816
- message: `HTTP ${response.status}: ${response.statusText}`
1817
- }));
1818
- throw new Error(errorData.message || "Failed to generate preview");
1819
- }
1820
- const data = await response.json();
1821
- if ((_a = data.packingSlip) == null ? void 0 : _a.pdfBase64) {
1822
- const byteCharacters = atob(data.packingSlip.pdfBase64);
1823
- const byteNumbers = new Array(byteCharacters.length);
1824
- for (let i = 0; i < byteCharacters.length; i++) {
1825
- byteNumbers[i] = byteCharacters.charCodeAt(i);
1826
- }
1827
- const byteArray = new Uint8Array(byteNumbers);
1828
- const blob = new Blob([byteArray], { type: "application/pdf" });
1829
- const url = window.URL.createObjectURL(blob);
1830
- window.open(url, "_blank");
1831
- toast.success("เปิดตัวอย่างในแท็บใหม่");
1832
- } else {
1833
- throw new Error("PDF data not available");
1834
- }
1835
- } catch (err) {
1836
- toast.error("เกิดข้อผิดพลาดในการแสดงตัวอย่าง", {
1837
- description: err.message
1838
- });
1839
- }
1840
- };
1841
- if (loading) {
1842
- return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
1843
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "ตั้งค่าใบแพ็คสินค้า" }),
1844
- /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "กำลังโหลด..." })
1845
- ] }) });
1846
- }
1847
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1848
- /* @__PURE__ */ jsx(Toaster, {}),
1849
- /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
1850
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs("div", { children: [
1851
- /* @__PURE__ */ jsx(Heading, { level: "h1", children: "ตั้งค่าใบแพ็คสินค้า" }),
1852
- /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle mt-1", children: "กำหนดรูปแบบและเทมเพลตสำหรับใบแพ็คสินค้า" })
1853
- ] }) }),
1854
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-6", children: [
1855
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
1856
- /* @__PURE__ */ jsx(Label, { htmlFor: "template", weight: "plus", children: "เทมเพลต" }),
1857
- /* @__PURE__ */ jsxs(Select, { value: template, onValueChange: setTemplate, children: [
1858
- /* @__PURE__ */ jsx(Select.Trigger, { id: "template", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
1859
- /* @__PURE__ */ jsxs(Select.Content, { children: [
1860
- /* @__PURE__ */ jsx(Select.Item, { value: "BASIC", children: "Basic - ใบแพ็คมาตรฐาน" }),
1861
- /* @__PURE__ */ jsx(Select.Item, { value: "BASIC_SMALL", children: "Basic Small - ใบแพ็คขนาดเล็ก" })
1862
- ] })
1863
- ] }),
1864
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "เลือกรูปแบบเทมเพลตสำหรับใบแพ็คสินค้า" }),
1865
- /* @__PURE__ */ jsxs(
1866
- Button,
1867
- {
1868
- size: "small",
1869
- variant: "secondary",
1870
- onClick: handlePreview,
1871
- className: "mt-2 w-fit",
1872
- children: [
1873
- /* @__PURE__ */ jsx(Eye, { size: 16 }),
1874
- "ดูตัวอย่างเทมเพลต"
1875
- ]
1876
- }
1877
- )
1878
- ] }),
1879
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
1880
- /* @__PURE__ */ jsx(Label, { htmlFor: "formatNumber", weight: "plus", children: "รูปแบบหมายเลขเอกสาร" }),
1881
- /* @__PURE__ */ jsx(
1882
- Input,
1883
- {
1884
- id: "formatNumber",
1885
- placeholder: "เช่น PS-{YYYY}-{0000}",
1886
- value: formatNumber,
1887
- onChange: (e) => setFormatNumber(e.target.value)
1888
- }
1889
- ),
1890
- /* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
1891
- "กำหนดรูปแบบหมายเลขใบแพ็คสินค้า ใช้ ",
1892
- "{YYYY}",
1893
- " สำหรับปี และ",
1894
- " ",
1895
- "{0000}",
1896
- " สำหรับเลขที่เอกสาร"
1897
- ] })
1898
- ] }),
1899
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
1900
- /* @__PURE__ */ jsx(Label, { htmlFor: "forcedNumber", weight: "plus", children: "กำหนดหมายเลขเริ่มต้น" }),
1901
- /* @__PURE__ */ jsx(
1902
- Input,
1903
- {
1904
- id: "forcedNumber",
1905
- type: "number",
1906
- placeholder: "เช่น 1",
1907
- value: forcedNumber,
1908
- onChange: (e) => setForcedNumber(e.target.value)
1909
- }
1910
- ),
1911
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "กำหนดหมายเลขเริ่มต้นสำหรับเอกสารใหม่ (ถ้าไม่ระบุจะนับต่อจากเอกสารล่าสุด)" })
1912
- ] }),
1913
- settings && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4 bg-ui-bg-subtle", children: [
1914
- /* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "mb-2", children: "ข้อมูลการตั้งค่าปัจจุบัน" }),
1915
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 text-sm text-ui-fg-subtle", children: [
1916
- /* @__PURE__ */ jsx("div", { children: "อัปเดตล่าสุด:" }),
1917
- /* @__PURE__ */ jsx("div", { children: new Date(settings.updated_at).toLocaleString("th-TH") }),
1918
- /* @__PURE__ */ jsx("div", { children: "สร้างเมื่อ:" }),
1919
- /* @__PURE__ */ jsx("div", { children: new Date(settings.created_at).toLocaleString("th-TH") })
1920
- ] })
1921
- ] }),
1922
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4", children: [
1923
- /* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "mb-2", children: "ตัวอย่างหมายเลขเอกสาร" }),
1924
- /* @__PURE__ */ jsx("div", { className: "font-mono text-lg", children: formatNumber ? formatNumber.replace("{YYYY}", (/* @__PURE__ */ new Date()).getFullYear().toString()).replace("{0000}", (forcedNumber || "1").padStart(4, "0")) : "ยังไม่ได้กำหนดรูปแบบ" })
1925
- ] }),
1926
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2 justify-end", children: [
1927
- /* @__PURE__ */ jsx(
1928
- Button,
1929
- {
1930
- variant: "secondary",
1931
- onClick: fetchSettings,
1932
- disabled: saving,
1933
- children: "รีเซ็ต"
1934
- }
1935
- ),
1936
- /* @__PURE__ */ jsx(Button, { onClick: handleSave, isLoading: saving, children: "บันทึกการตั้งค่า" })
1937
- ] })
1938
- ] })
1939
- ] }) })
1940
- ] });
1941
- };
1942
- const config$1 = defineRouteConfig({
1943
- icon: DocumentText,
1944
- label: "ตั้งค่าใบแพ็คสินค้า"
1945
- });
1946
1510
  const CARRIER_TYPES$1 = [
1947
1511
  { value: "COMPANY_FLEET", label: "บริษัทรถส่งของ (Messenger)" },
1948
1512
  { value: "COMPANY_TRUCK", label: "รถบริษัท (Same Day)" },
@@ -2431,10 +1995,6 @@ const config = defineRouteConfig({
2431
1995
  label: "อัตราค่าขนส่ง"
2432
1996
  });
2433
1997
  const widgetModule = { widgets: [
2434
- {
2435
- Component: OrderPackingSlipWidget,
2436
- zone: ["order.details.after"]
2437
- },
2438
1998
  {
2439
1999
  Component: OrderShippingQuoteWidget,
2440
2000
  zone: ["order.details.after"]
@@ -2454,10 +2014,6 @@ const routeModule = {
2454
2014
  Component: MaterialCostsPage,
2455
2015
  path: "/material-costs"
2456
2016
  },
2457
- {
2458
- Component: PackingSlipSettingsPage,
2459
- path: "/packing-slip-settings"
2460
- },
2461
2017
  {
2462
2018
  Component: RatesPage,
2463
2019
  path: "/rates"
@@ -2466,28 +2022,22 @@ const routeModule = {
2466
2022
  };
2467
2023
  const menuItemModule = {
2468
2024
  menuItems: [
2469
- {
2470
- label: config$4.label,
2471
- icon: config$4.icon,
2472
- path: "/areas",
2473
- nested: void 0
2474
- },
2475
2025
  {
2476
2026
  label: config$3.label,
2477
2027
  icon: config$3.icon,
2478
- path: "/boxes",
2028
+ path: "/areas",
2479
2029
  nested: void 0
2480
2030
  },
2481
2031
  {
2482
2032
  label: config$2.label,
2483
2033
  icon: config$2.icon,
2484
- path: "/material-costs",
2034
+ path: "/boxes",
2485
2035
  nested: void 0
2486
2036
  },
2487
2037
  {
2488
2038
  label: config$1.label,
2489
2039
  icon: config$1.icon,
2490
- path: "/packing-slip-settings",
2040
+ path: "/material-costs",
2491
2041
  nested: void 0
2492
2042
  },
2493
2043
  {
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.assignPackingSlipToOrderWorkflow = exports.ParcelFulfillmentProvider = exports.DocumentsModule = exports.PARCEL_SHIPPING_MODULE = exports.ParcelShippingModule = void 0;
20
+ exports.ParcelFulfillmentProvider = exports.PARCEL_SHIPPING_MODULE = exports.ParcelShippingModule = void 0;
21
21
  // Export unified types (new)
22
22
  __exportStar(require("./types"), exports);
23
23
  // Export models
@@ -27,12 +27,7 @@ var parcel_shipping_1 = require("./modules/parcel-shipping");
27
27
  Object.defineProperty(exports, "ParcelShippingModule", { enumerable: true, get: function () { return __importDefault(parcel_shipping_1).default; } });
28
28
  var parcel_shipping_2 = require("./modules/parcel-shipping");
29
29
  Object.defineProperty(exports, "PARCEL_SHIPPING_MODULE", { enumerable: true, get: function () { return parcel_shipping_2.PARCEL_SHIPPING_MODULE; } });
30
- var documents_1 = require("./modules/documents");
31
- Object.defineProperty(exports, "DocumentsModule", { enumerable: true, get: function () { return __importDefault(documents_1).default; } });
32
30
  // Export provider
33
31
  var index_1 = require("./providers/index");
34
32
  Object.defineProperty(exports, "ParcelFulfillmentProvider", { enumerable: true, get: function () { return __importDefault(index_1).default; } });
35
- // Export workflows
36
- var assign_packing_slip_1 = require("./workflows/assign-packing-slip");
37
- Object.defineProperty(exports, "assignPackingSlipToOrderWorkflow", { enumerable: true, get: function () { return __importDefault(assign_packing_slip_1).default; } });
38
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw2QkFBNkI7QUFDN0IsMENBQXdCO0FBRXhCLGdCQUFnQjtBQUNoQixtRUFBaUQ7QUFFakQsaUJBQWlCO0FBQ2pCLDZEQUE0RTtBQUFuRSx3SUFBQSxPQUFPLE9BQXdCO0FBQ3hDLDZEQUFtRTtBQUExRCx5SEFBQSxzQkFBc0IsT0FBQTtBQUMvQixpREFBaUU7QUFBeEQsNkhBQUEsT0FBTyxPQUFtQjtBQUVuQyxrQkFBa0I7QUFDbEIsMkNBQXlFO0FBQWhFLG1JQUFBLE9BQU8sT0FBNkI7QUFFN0MsbUJBQW1CO0FBQ25CLHVFQUE4RjtBQUFyRix3SkFBQSxPQUFPLE9BQW9DIn0=
33
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw2QkFBNkI7QUFDN0IsMENBQXdCO0FBRXhCLGdCQUFnQjtBQUNoQixtRUFBaUQ7QUFFakQsaUJBQWlCO0FBQ2pCLDZEQUE0RTtBQUFuRSx3SUFBQSxPQUFPLE9BQXdCO0FBQ3hDLDZEQUFtRTtBQUExRCx5SEFBQSxzQkFBc0IsT0FBQTtBQUUvQixrQkFBa0I7QUFDbEIsMkNBQXlFO0FBQWhFLG1JQUFBLE9BQU8sT0FBNkIifQ==
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20251106000000 = void 0;
4
+ const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
5
+ /**
6
+ * Adds the missing price column to the parcel_shipping_rate table.
7
+ * Older environments were provisioned before the column was introduced in code,
8
+ * so we defensively add it (and enforce NOT NULL) if needed.
9
+ */
10
+ class Migration20251106000000 extends migrations_1.Migration {
11
+ async up() {
12
+ this.addSql(`
13
+ DO $$
14
+ BEGIN
15
+ IF NOT EXISTS (
16
+ SELECT 1 FROM information_schema.columns
17
+ WHERE table_name = 'parcel_shipping_rate'
18
+ AND column_name = 'price'
19
+ ) THEN
20
+ ALTER TABLE "parcel_shipping_rate"
21
+ ADD COLUMN "price" double precision;
22
+ END IF;
23
+
24
+ UPDATE "parcel_shipping_rate"
25
+ SET "price" = 0
26
+ WHERE "price" IS NULL;
27
+
28
+ ALTER TABLE "parcel_shipping_rate"
29
+ ALTER COLUMN "price" SET DEFAULT 0,
30
+ ALTER COLUMN "price" SET NOT NULL;
31
+ END $$;
32
+ `);
33
+ }
34
+ async down() {
35
+ this.addSql(`
36
+ ALTER TABLE "parcel_shipping_rate"
37
+ DROP COLUMN IF EXISTS "price";
38
+ `);
39
+ }
40
+ }
41
+ exports.Migration20251106000000 = Migration20251106000000;
42
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWlncmF0aW9uMjAyNTExMDYwMDAwMDAuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9wYXJjZWwtc2hpcHBpbmcvbWlncmF0aW9ucy9NaWdyYXRpb24yMDI1MTEwNjAwMDAwMC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5RUFBcUU7QUFFckU7Ozs7R0FJRztBQUNILE1BQWEsdUJBQXdCLFNBQVEsc0JBQVM7SUFDM0MsS0FBSyxDQUFDLEVBQUU7UUFDZixJQUFJLENBQUMsTUFBTSxDQUFDOzs7Ozs7Ozs7Ozs7Ozs7Ozs7OztLQW9CWCxDQUFDLENBQUM7SUFDTCxDQUFDO0lBRVEsS0FBSyxDQUFDLElBQUk7UUFDakIsSUFBSSxDQUFDLE1BQU0sQ0FBQzs7O0tBR1gsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztDQUNGO0FBL0JELDBEQStCQyJ9