@argusoft/medplat-product-management 1.0.3 → 1.0.5
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.
- package/dist/{BrandsPage-NSvaMXWg.js → BrandsPage-CjL0bBk0.js} +80 -78
- package/dist/{BrandsPage-NSvaMXWg.js.map → BrandsPage-CjL0bBk0.js.map} +1 -1
- package/dist/{CategoriesPage-aZBZrDOi.js → CategoriesPage-CLcAUEvh.js} +72 -70
- package/dist/{CategoriesPage-aZBZrDOi.js.map → CategoriesPage-CLcAUEvh.js.map} +1 -1
- package/dist/{DashboardPage-DjwlOhrd.js → DashboardPage-C_H1Jrey.js} +91 -90
- package/dist/{DashboardPage-DjwlOhrd.js.map → DashboardPage-C_H1Jrey.js.map} +1 -1
- package/dist/{FacilityPicker-Chh-ZaR0.js → FacilityPicker-Diq2hnYg.js} +2 -2
- package/dist/{FacilityPicker-Chh-ZaR0.js.map → FacilityPicker-Diq2hnYg.js.map} +1 -1
- package/dist/{InventoryPage-cy76UsMp.js → InventoryPage-C1ho56CY.js} +113 -112
- package/dist/{InventoryPage-cy76UsMp.js.map → InventoryPage-C1ho56CY.js.map} +1 -1
- package/dist/{MemberProfileCard-CinPt09F.js → MemberProfileCard-BLUVRILO.js} +6 -5
- package/dist/{MemberProfileCard-CinPt09F.js.map → MemberProfileCard-BLUVRILO.js.map} +1 -1
- package/dist/{PaymentCreatePage-BJe3LyFF.js → PaymentCreatePage-mvUFdr7u.js} +125 -124
- package/dist/{PaymentCreatePage-BJe3LyFF.js.map → PaymentCreatePage-mvUFdr7u.js.map} +1 -1
- package/dist/{PaymentsPage-DxHoKksN.js → PaymentsPage-DY6BclkN.js} +21 -20
- package/dist/{PaymentsPage-DxHoKksN.js.map → PaymentsPage-DY6BclkN.js.map} +1 -1
- package/dist/{PickupCreatePage-Cq8zJ62Y.js → PickupCreatePage-CCSiyFQF.js} +63 -62
- package/dist/{PickupCreatePage-Cq8zJ62Y.js.map → PickupCreatePage-CCSiyFQF.js.map} +1 -1
- package/dist/{PickupsPage-BOygBQAb.js → PickupsPage-DGi6T5Of.js} +42 -41
- package/dist/{PickupsPage-BOygBQAb.js.map → PickupsPage-DGi6T5Of.js.map} +1 -1
- package/dist/PmGuard-C90yhpsN.js +592 -0
- package/dist/PmGuard-C90yhpsN.js.map +1 -0
- package/dist/{PmTable-CCpaJEA_.js → PmTable-BkK65bJQ.js} +96 -96
- package/dist/{PmTable-CCpaJEA_.js.map → PmTable-BkK65bJQ.js.map} +1 -1
- package/dist/{ProductEditPage-DmdHO-fS.js → ProductEditPage-CIQKtw2Z.js} +130 -129
- package/dist/{ProductEditPage-DmdHO-fS.js.map → ProductEditPage-CIQKtw2Z.js.map} +1 -1
- package/dist/{ProductsPage-BglMe8EM.js → ProductsPage-i8QVw_Jm.js} +64 -63
- package/dist/{ProductsPage-BglMe8EM.js.map → ProductsPage-i8QVw_Jm.js.map} +1 -1
- package/dist/{PurchaseCreatePage-1tYk41RS.js → PurchaseCreatePage-73Q_xY7S.js} +120 -119
- package/dist/{PurchaseCreatePage-1tYk41RS.js.map → PurchaseCreatePage-73Q_xY7S.js.map} +1 -1
- package/dist/{PurchaseRequestDetailPage-BYLx3aBI.js → PurchaseRequestDetailPage-BR20EKBJ.js} +217 -215
- package/dist/{PurchaseRequestDetailPage-BYLx3aBI.js.map → PurchaseRequestDetailPage-BR20EKBJ.js.map} +1 -1
- package/dist/{PurchaseRequestsPage-D2yorc4s.js → PurchaseRequestsPage-BJqDlNrc.js} +57 -56
- package/dist/{PurchaseRequestsPage-D2yorc4s.js.map → PurchaseRequestsPage-BJqDlNrc.js.map} +1 -1
- package/dist/{PurchasesPage-CanQTjlw.js → PurchasesPage-BQEToymQ.js} +76 -75
- package/dist/{PurchasesPage-CanQTjlw.js.map → PurchasesPage-BQEToymQ.js.map} +1 -1
- package/dist/{SaleCreatePage-DxFvPvju.js → SaleCreatePage-BVThnWsk.js} +89 -88
- package/dist/{SaleCreatePage-DxFvPvju.js.map → SaleCreatePage-BVThnWsk.js.map} +1 -1
- package/dist/{SalesPage-CPMrdr5-.js → SalesPage-CTBJMxZe.js} +46 -45
- package/dist/{SalesPage-CPMrdr5-.js.map → SalesPage-CTBJMxZe.js.map} +1 -1
- package/dist/{SettingsPage-CEy922rW.js → SettingsPage-CiwVmzM3.js} +47 -46
- package/dist/{SettingsPage-CEy922rW.js.map → SettingsPage-CiwVmzM3.js.map} +1 -1
- package/dist/{StorageUnitsPage-DfLT6xC_.js → StorageUnitsPage--ECPMVhB.js} +55 -54
- package/dist/{StorageUnitsPage-DfLT6xC_.js.map → StorageUnitsPage--ECPMVhB.js.map} +1 -1
- package/dist/{TransactionsPage-KFUJ4O5g.js → TransactionsPage-Cocn4901.js} +54 -53
- package/dist/{TransactionsPage-KFUJ4O5g.js.map → TransactionsPage-Cocn4901.js.map} +1 -1
- package/dist/{TransferCreatePage-k1tsRGB3.js → TransferCreatePage-DbjcjuOg.js} +74 -73
- package/dist/{TransferCreatePage-k1tsRGB3.js.map → TransferCreatePage-DbjcjuOg.js.map} +1 -1
- package/dist/{TransfersPage-CDafSVO9.js → TransfersPage-BFVF7Xvc.js} +108 -107
- package/dist/{TransfersPage-CDafSVO9.js.map → TransfersPage-BFVF7Xvc.js.map} +1 -1
- package/dist/VialsPage-hZmS5xPt.js +321 -0
- package/dist/VialsPage-hZmS5xPt.js.map +1 -0
- package/dist/format-UOyOu75i.js.map +1 -1
- package/dist/index.js +652 -34
- package/dist/index.js.map +1 -1
- package/dist/settingsStore-KW217unV.js +417 -0
- package/dist/settingsStore-KW217unV.js.map +1 -0
- package/dist/{validation-Ba7puFIO.js → validation-BkUPqrdA.js} +11 -12
- package/dist/{validation-Ba7puFIO.js.map → validation-BkUPqrdA.js.map} +1 -1
- package/package.json +1 -1
- package/dist/VialsPage-DPsYFgaQ.js +0 -897
- package/dist/VialsPage-DPsYFgaQ.js.map +0 -1
- package/dist/currency-bVQ7aEk2.js +0 -1007
- package/dist/currency-bVQ7aEk2.js.map +0 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as
|
|
3
|
-
import { i as
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Alert as
|
|
9
|
-
import w from "
|
|
10
|
-
import he from "
|
|
11
|
-
import ge from "
|
|
12
|
-
import
|
|
13
|
-
import E from "
|
|
14
|
-
import
|
|
1
|
+
import { Z as e, p as t, r as n } from "./settingsStore-KW217unV.js";
|
|
2
|
+
import { c as r, n as i, s as a, t as ee } from "./PmTable-BkK65bJQ.js";
|
|
3
|
+
import { i as te, m as o, t as s } from "./validation-BkUPqrdA.js";
|
|
4
|
+
import { t as c } from "./useFieldErrors-hDG8ox_x.js";
|
|
5
|
+
import { a as ne, i as re, n as ie, r as ae, t as l } from "./PmGuard-C90yhpsN.js";
|
|
6
|
+
import { useState as u } from "react";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
import { Alert as oe, Box as p, Button as m, Checkbox as se, Chip as ce, Dialog as le, DialogActions as ue, DialogContent as h, DialogTitle as de, FormControlLabel as g, InputAdornment as fe, Skeleton as _, Stack as v, TableBody as y, TableCell as b, TableHead as pe, TableRow as x, TextField as S, Typography as C } from "@mui/material";
|
|
9
|
+
import { showToast as w } from "@/common/toaster/toaster";
|
|
10
|
+
import { findCountry as me, validatePhoneForCountry as he } from "@/common/constants/countries";
|
|
11
|
+
import { v4 as ge } from "uuid";
|
|
12
|
+
import T from "@mui/icons-material/AddRounded";
|
|
13
|
+
import E from "@mui/icons-material/RefreshRounded";
|
|
14
|
+
import D from "@mui/icons-material/SellRounded";
|
|
15
|
+
import O from "@/views/custom-components/CustomSwitch";
|
|
15
16
|
//#region src/views/BrandsPage.jsx
|
|
16
17
|
function k(e) {
|
|
17
18
|
if (!e) return {
|
|
@@ -36,7 +37,7 @@ function A({ phone: e, email: t }) {
|
|
|
36
37
|
return e?.trim() && (n.phone = e.trim()), t?.trim() && (n.email = t.trim()), Object.keys(n).length ? JSON.stringify(n) : null;
|
|
37
38
|
}
|
|
38
39
|
function j() {
|
|
39
|
-
let j =
|
|
40
|
+
let j = re().has("update.manage.productManagement.brand"), M = me(n()?.countryCode), [N, P] = u([]), [F, I] = u(!1), [L, R] = u(""), [_e, z] = u(!1), [B, V] = u(null), [H, ve] = u(!1), [U, W] = u(K()), G = c();
|
|
40
41
|
function K() {
|
|
41
42
|
return {
|
|
42
43
|
id: "",
|
|
@@ -50,10 +51,11 @@ function j() {
|
|
|
50
51
|
async function q() {
|
|
51
52
|
I(!0), R("");
|
|
52
53
|
try {
|
|
53
|
-
|
|
54
|
+
let e = await t(void 0, !0);
|
|
55
|
+
P(e);
|
|
54
56
|
} catch (e) {
|
|
55
57
|
let t = e?.response?.data?.message ?? e?.message ?? "Failed to load brands";
|
|
56
|
-
R(t),
|
|
58
|
+
R(t), w({
|
|
57
59
|
message: t,
|
|
58
60
|
type: "error"
|
|
59
61
|
});
|
|
@@ -61,13 +63,13 @@ function j() {
|
|
|
61
63
|
I(!1);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
|
-
|
|
66
|
+
ae("view.manage.productManagement.brand", () => {
|
|
65
67
|
q();
|
|
66
68
|
}, []);
|
|
67
69
|
function J() {
|
|
68
70
|
V(null), W({
|
|
69
71
|
...K(),
|
|
70
|
-
id:
|
|
72
|
+
id: ge()
|
|
71
73
|
}), G.reset(), R(""), z(!0);
|
|
72
74
|
}
|
|
73
75
|
function ye(e) {
|
|
@@ -81,19 +83,19 @@ function j() {
|
|
|
81
83
|
isActive: e.isActive !== !1
|
|
82
84
|
}), z(!0);
|
|
83
85
|
}
|
|
84
|
-
let Y =
|
|
85
|
-
name:
|
|
86
|
+
let Y = o(U.manufacturerCode, "Manufacturer code"), X = U.manufacturerCode.trim().toUpperCase(), be = !Y && X && N.some((e) => e.id !== U.id && (e.manufacturerCode || "").toUpperCase() === X), Z = {
|
|
87
|
+
name: o(U.name, "Name"),
|
|
86
88
|
manufacturerCode: Y || (be ? "Code is already in use — edit it manually to make it unique." : ""),
|
|
87
|
-
contactPhone:
|
|
88
|
-
contactEmail:
|
|
89
|
-
}, Q =
|
|
89
|
+
contactPhone: he(U.contactPhone, M),
|
|
90
|
+
contactEmail: te(U.contactEmail)
|
|
91
|
+
}, Q = s(Z);
|
|
90
92
|
async function xe() {
|
|
91
93
|
if (!Q) {
|
|
92
94
|
G.markAllTouched(), R("Please fix the highlighted fields.");
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
95
97
|
try {
|
|
96
|
-
await
|
|
98
|
+
await e({
|
|
97
99
|
id: U.id,
|
|
98
100
|
name: U.name.trim(),
|
|
99
101
|
manufacturerCode: U.manufacturerCode.trim().toUpperCase(),
|
|
@@ -102,54 +104,54 @@ function j() {
|
|
|
102
104
|
email: U.contactEmail
|
|
103
105
|
}),
|
|
104
106
|
isActive: U.isActive
|
|
105
|
-
}),
|
|
107
|
+
}), w({
|
|
106
108
|
message: "Brand saved.",
|
|
107
109
|
type: "success"
|
|
108
110
|
}), z(!1), await q();
|
|
109
111
|
} catch (e) {
|
|
110
112
|
let t = e?.response?.data?.message ?? e?.message ?? "Failed to save brand";
|
|
111
|
-
R(t),
|
|
113
|
+
R(t), w({
|
|
112
114
|
message: t,
|
|
113
115
|
type: "error"
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
let $ = H ? N : N.filter((e) => e.isActive !== !1);
|
|
118
|
-
return /* @__PURE__ */
|
|
120
|
+
return /* @__PURE__ */ f(p, { children: [/* @__PURE__ */ d(ie, {}), /* @__PURE__ */ f(l, {
|
|
119
121
|
perm: "view.manage.productManagement.brand",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
122
|
+
children: [/* @__PURE__ */ f(ne, {
|
|
121
123
|
title: "Brands",
|
|
122
124
|
subtitle: "The manufacturer or supplier of each product.",
|
|
123
125
|
chips: ["Catalog"],
|
|
124
|
-
actions: /* @__PURE__ */
|
|
126
|
+
actions: /* @__PURE__ */ f(v, {
|
|
125
127
|
direction: "row",
|
|
126
128
|
spacing: 1,
|
|
127
|
-
children: [/* @__PURE__ */
|
|
129
|
+
children: [/* @__PURE__ */ d(m, {
|
|
128
130
|
variant: "outlined",
|
|
129
|
-
startIcon: /* @__PURE__ */
|
|
131
|
+
startIcon: /* @__PURE__ */ d(E, {}),
|
|
130
132
|
onClick: () => void q(),
|
|
131
133
|
children: "Refresh"
|
|
132
|
-
}), j ? /* @__PURE__ */
|
|
134
|
+
}), j ? /* @__PURE__ */ d(m, {
|
|
133
135
|
variant: "contained",
|
|
134
|
-
startIcon: /* @__PURE__ */
|
|
136
|
+
startIcon: /* @__PURE__ */ d(T, {}),
|
|
135
137
|
onClick: J,
|
|
136
138
|
children: "New Brand"
|
|
137
139
|
}) : null]
|
|
138
140
|
}),
|
|
139
|
-
children: [L ? /* @__PURE__ */
|
|
141
|
+
children: [L ? /* @__PURE__ */ d(oe, {
|
|
140
142
|
severity: "error",
|
|
141
143
|
sx: { mb: 2 },
|
|
142
144
|
children: L
|
|
143
|
-
}) : null, /* @__PURE__ */
|
|
145
|
+
}) : null, /* @__PURE__ */ d(r, {
|
|
144
146
|
eyebrow: "Master data",
|
|
145
147
|
title: "Brands",
|
|
146
148
|
subtitle: F ? "Loading…" : `${$.length} ${$.length === 1 ? "brand" : "brands"}`,
|
|
147
|
-
actions: /* @__PURE__ */
|
|
148
|
-
control: /* @__PURE__ */
|
|
149
|
+
actions: /* @__PURE__ */ d(g, {
|
|
150
|
+
control: /* @__PURE__ */ d(O, {
|
|
149
151
|
checked: H,
|
|
150
152
|
onChange: (e) => ve(e.target.checked)
|
|
151
153
|
}),
|
|
152
|
-
label: /* @__PURE__ */
|
|
154
|
+
label: /* @__PURE__ */ d(C, {
|
|
153
155
|
variant: "body2",
|
|
154
156
|
sx: { fontWeight: 600 },
|
|
155
157
|
children: "Show inactive"
|
|
@@ -160,35 +162,35 @@ function j() {
|
|
|
160
162
|
ml: 0
|
|
161
163
|
}
|
|
162
164
|
}),
|
|
163
|
-
children: /* @__PURE__ */
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */
|
|
165
|
+
children: /* @__PURE__ */ f(a, { children: [/* @__PURE__ */ d(pe, { children: /* @__PURE__ */ f(x, { children: [
|
|
166
|
+
/* @__PURE__ */ d(b, { children: "Name" }),
|
|
167
|
+
/* @__PURE__ */ d(b, { children: "Manufacturer Code" }),
|
|
168
|
+
/* @__PURE__ */ d(b, { children: "Contact" }),
|
|
169
|
+
/* @__PURE__ */ d(b, { children: "Status" }),
|
|
170
|
+
/* @__PURE__ */ d(b, {
|
|
169
171
|
align: "right",
|
|
170
172
|
children: "Action"
|
|
171
173
|
})
|
|
172
|
-
] }) }), /* @__PURE__ */
|
|
174
|
+
] }) }), /* @__PURE__ */ d(y, { children: F ? Array.from({ length: 4 }).map((e, t) => /* @__PURE__ */ d(x, { children: Array.from({ length: 5 }).map((e, t) => /* @__PURE__ */ d(b, { children: /* @__PURE__ */ d(_, { height: 22 }) }, t)) }, t)) : $.length === 0 ? /* @__PURE__ */ d(ee, {
|
|
173
175
|
colSpan: 5,
|
|
174
|
-
icon:
|
|
176
|
+
icon: D,
|
|
175
177
|
title: N.length === 0 ? "No brands yet" : "No active brands",
|
|
176
178
|
hint: N.length === 0 ? "Add manufacturers so you can link them to your products." : "Turn on “Show inactive” to see deactivated brands.",
|
|
177
|
-
action: N.length === 0 && j ? /* @__PURE__ */
|
|
179
|
+
action: N.length === 0 && j ? /* @__PURE__ */ d(m, {
|
|
178
180
|
variant: "contained",
|
|
179
181
|
size: "small",
|
|
180
|
-
startIcon: /* @__PURE__ */
|
|
182
|
+
startIcon: /* @__PURE__ */ d(T, {}),
|
|
181
183
|
onClick: J,
|
|
182
184
|
children: "Create first brand"
|
|
183
185
|
}) : null
|
|
184
186
|
}) : $.map((e) => {
|
|
185
187
|
let { phone: t, email: n } = k(e.contactInfo);
|
|
186
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ f(x, {
|
|
187
189
|
hover: !0,
|
|
188
190
|
children: [
|
|
189
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ d(b, {
|
|
190
192
|
sx: { maxWidth: 240 },
|
|
191
|
-
children: /* @__PURE__ */
|
|
193
|
+
children: /* @__PURE__ */ d(C, {
|
|
192
194
|
variant: "body2",
|
|
193
195
|
sx: {
|
|
194
196
|
fontWeight: 700,
|
|
@@ -197,9 +199,9 @@ function j() {
|
|
|
197
199
|
children: e.name
|
|
198
200
|
})
|
|
199
201
|
}),
|
|
200
|
-
/* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ d(b, {
|
|
201
203
|
sx: { maxWidth: 160 },
|
|
202
|
-
children: /* @__PURE__ */
|
|
204
|
+
children: /* @__PURE__ */ d(p, {
|
|
203
205
|
component: "span",
|
|
204
206
|
sx: {
|
|
205
207
|
display: "inline-block",
|
|
@@ -216,23 +218,23 @@ function j() {
|
|
|
216
218
|
children: e.manufacturerCode
|
|
217
219
|
})
|
|
218
220
|
}),
|
|
219
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ d(b, { children: t || n ? /* @__PURE__ */ f(v, {
|
|
220
222
|
spacing: .25,
|
|
221
|
-
children: [t ? /* @__PURE__ */
|
|
223
|
+
children: [t ? /* @__PURE__ */ d(C, {
|
|
222
224
|
variant: "caption",
|
|
223
225
|
sx: { fontWeight: 600 },
|
|
224
226
|
children: t
|
|
225
|
-
}) : null, n ? /* @__PURE__ */
|
|
227
|
+
}) : null, n ? /* @__PURE__ */ d(C, {
|
|
226
228
|
variant: "caption",
|
|
227
229
|
color: "text.secondary",
|
|
228
230
|
children: n
|
|
229
231
|
}) : null]
|
|
230
|
-
}) : /* @__PURE__ */
|
|
232
|
+
}) : /* @__PURE__ */ d(C, {
|
|
231
233
|
variant: "caption",
|
|
232
234
|
color: "text.disabled",
|
|
233
235
|
children: "—"
|
|
234
236
|
}) }),
|
|
235
|
-
/* @__PURE__ */
|
|
237
|
+
/* @__PURE__ */ d(b, { children: /* @__PURE__ */ d(ce, {
|
|
236
238
|
size: "small",
|
|
237
239
|
label: e.isActive ? "Active" : "Inactive",
|
|
238
240
|
color: e.isActive ? "success" : "default",
|
|
@@ -243,9 +245,9 @@ function j() {
|
|
|
243
245
|
height: 22
|
|
244
246
|
}
|
|
245
247
|
}) }),
|
|
246
|
-
/* @__PURE__ */
|
|
248
|
+
/* @__PURE__ */ d(b, {
|
|
247
249
|
align: "right",
|
|
248
|
-
children: j ? /* @__PURE__ */
|
|
250
|
+
children: j ? /* @__PURE__ */ d(m, {
|
|
249
251
|
size: "small",
|
|
250
252
|
variant: "outlined",
|
|
251
253
|
onClick: () => ye(e),
|
|
@@ -256,20 +258,20 @@ function j() {
|
|
|
256
258
|
}, e.id);
|
|
257
259
|
}) })] })
|
|
258
260
|
})]
|
|
259
|
-
}), /* @__PURE__ */
|
|
261
|
+
}), /* @__PURE__ */ f(le, {
|
|
260
262
|
open: _e,
|
|
261
263
|
onClose: () => z(!1),
|
|
262
264
|
fullWidth: !0,
|
|
263
265
|
maxWidth: "sm",
|
|
264
266
|
children: [
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
267
|
+
/* @__PURE__ */ d(de, { children: B ? "Edit Brand" : "New Brand" }),
|
|
268
|
+
/* @__PURE__ */ d(h, {
|
|
267
269
|
dividers: !0,
|
|
268
|
-
children: /* @__PURE__ */
|
|
270
|
+
children: /* @__PURE__ */ f(v, {
|
|
269
271
|
spacing: 2,
|
|
270
272
|
sx: { pt: 1 },
|
|
271
273
|
children: [
|
|
272
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ d(S, {
|
|
273
275
|
required: !0,
|
|
274
276
|
label: "Name",
|
|
275
277
|
size: "small",
|
|
@@ -287,13 +289,13 @@ function j() {
|
|
|
287
289
|
onBlur: G.onBlur("name"),
|
|
288
290
|
error: G.show("name") && !!Z.name,
|
|
289
291
|
FormHelperTextProps: { component: "div" },
|
|
290
|
-
helperText: /* @__PURE__ */
|
|
292
|
+
helperText: /* @__PURE__ */ d(i, {
|
|
291
293
|
message: G.show("name") ? Z.name : "",
|
|
292
294
|
value: U.name,
|
|
293
295
|
max: 255
|
|
294
296
|
})
|
|
295
297
|
}),
|
|
296
|
-
/* @__PURE__ */
|
|
298
|
+
/* @__PURE__ */ d(S, {
|
|
297
299
|
required: !0,
|
|
298
300
|
label: "Manufacturer code",
|
|
299
301
|
size: "small",
|
|
@@ -307,13 +309,13 @@ function j() {
|
|
|
307
309
|
onBlur: G.onBlur("manufacturerCode"),
|
|
308
310
|
error: G.show("manufacturerCode") && !!Z.manufacturerCode,
|
|
309
311
|
FormHelperTextProps: { component: "div" },
|
|
310
|
-
helperText: /* @__PURE__ */
|
|
312
|
+
helperText: /* @__PURE__ */ d(i, {
|
|
311
313
|
message: G.show("manufacturerCode") && Z.manufacturerCode ? Z.manufacturerCode : "Auto-generated from the name as initials. Edit if needed to make it unique.",
|
|
312
314
|
value: U.manufacturerCode,
|
|
313
315
|
max: 100
|
|
314
316
|
})
|
|
315
317
|
}),
|
|
316
|
-
/* @__PURE__ */
|
|
318
|
+
/* @__PURE__ */ d(S, {
|
|
317
319
|
label: "Contact Number",
|
|
318
320
|
size: "small",
|
|
319
321
|
fullWidth: !0,
|
|
@@ -327,9 +329,9 @@ function j() {
|
|
|
327
329
|
onBlur: G.onBlur("contactPhone"),
|
|
328
330
|
error: G.show("contactPhone") && !!Z.contactPhone,
|
|
329
331
|
helperText: G.show("contactPhone") && Z.contactPhone ? Z.contactPhone : M ? `Format for ${M.name}: ${M.phoneCode} followed by ${M.phoneMin}${M.phoneMin === M.phoneMax ? "" : `–${M.phoneMax}`} digits.` : "Local number, digits only.",
|
|
330
|
-
InputProps: M ? { startAdornment: /* @__PURE__ */
|
|
332
|
+
InputProps: M ? { startAdornment: /* @__PURE__ */ d(fe, {
|
|
331
333
|
position: "start",
|
|
332
|
-
children: /* @__PURE__ */
|
|
334
|
+
children: /* @__PURE__ */ d(p, {
|
|
333
335
|
component: "span",
|
|
334
336
|
sx: {
|
|
335
337
|
fontWeight: 700,
|
|
@@ -339,7 +341,7 @@ function j() {
|
|
|
339
341
|
})
|
|
340
342
|
}) } : void 0
|
|
341
343
|
}),
|
|
342
|
-
/* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ d(S, {
|
|
343
345
|
label: "Email",
|
|
344
346
|
size: "small",
|
|
345
347
|
fullWidth: !0,
|
|
@@ -354,8 +356,8 @@ function j() {
|
|
|
354
356
|
error: G.show("contactEmail") && !!Z.contactEmail,
|
|
355
357
|
helperText: G.show("contactEmail") ? Z.contactEmail : ""
|
|
356
358
|
}),
|
|
357
|
-
/* @__PURE__ */
|
|
358
|
-
control: /* @__PURE__ */
|
|
359
|
+
/* @__PURE__ */ d(g, {
|
|
360
|
+
control: /* @__PURE__ */ d(se, {
|
|
359
361
|
checked: U.isActive,
|
|
360
362
|
onChange: (e) => W({
|
|
361
363
|
...U,
|
|
@@ -367,10 +369,10 @@ function j() {
|
|
|
367
369
|
]
|
|
368
370
|
})
|
|
369
371
|
}),
|
|
370
|
-
/* @__PURE__ */
|
|
372
|
+
/* @__PURE__ */ f(ue, { children: [/* @__PURE__ */ d(m, {
|
|
371
373
|
onClick: () => z(!1),
|
|
372
374
|
children: "Cancel"
|
|
373
|
-
}), /* @__PURE__ */
|
|
375
|
+
}), /* @__PURE__ */ d(m, {
|
|
374
376
|
variant: "contained",
|
|
375
377
|
disabled: !Q,
|
|
376
378
|
onClick: () => void xe(),
|
|
@@ -383,4 +385,4 @@ function j() {
|
|
|
383
385
|
//#endregion
|
|
384
386
|
export { j as default };
|
|
385
387
|
|
|
386
|
-
//# sourceMappingURL=BrandsPage-
|
|
388
|
+
//# sourceMappingURL=BrandsPage-CjL0bBk0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrandsPage-NSvaMXWg.js","names":[],"sources":["../src/views/BrandsPage.jsx"],"sourcesContent":["import { useState } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport {\n Alert,\n Box,\n Button,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n InputAdornment,\n Skeleton,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n TextField,\n Typography,\n} from '@mui/material';\nimport AddRoundedIcon from '@mui/icons-material/AddRounded';\nimport RefreshRoundedIcon from '@mui/icons-material/RefreshRounded';\nimport SellRoundedIcon from '@mui/icons-material/SellRounded';\nimport { showToast } from '@/common/toaster/toaster';\nimport CustomSwitch from '@/views/custom-components/CustomSwitch';\nimport PmPageShell from '@pm/components/PmPageShell';\nimport PmNav from '@pm/components/PmNav';\nimport PmGuard from '@pm/components/PmGuard';\nimport { usePermissionedEffect, usePmPermissions } from '@pm/utils/permissions';\nimport { PmEmptyRow, PmFieldHelp, PmTable, PmTableCard } from '@pm/components/PmTable';\nimport { getBrands, upsertBrand } from '@pm/services/pmApi';\nimport { isClean, validateEmail, validateRequired } from '@pm/utils/validation';\nimport { findCountry, validatePhoneForCountry } from '@/common/constants/countries';\nimport { usePmSettings } from '@pm/utils/settingsStore';\nimport { useFieldErrors } from '@pm/utils/useFieldErrors';\n\n// Backend stores contact_info as a JSON-encoded string. We keep the discrete\n// fields here so the UI is form-friendly, and only ever round-trip the JSON.\nfunction parseContactInfo(raw) {\n if (!raw) return { phone: '', email: '' };\n try {\n const obj = JSON.parse(raw);\n return {\n phone: typeof obj?.phone === 'string' ? obj.phone : '',\n email: typeof obj?.email === 'string' ? obj.email : '',\n };\n } catch {\n return { phone: '', email: '' };\n }\n}\n\nfunction serializeContactInfo({ phone, email }) {\n const out = {};\n if (phone?.trim()) out.phone = phone.trim();\n if (email?.trim()) out.email = email.trim();\n return Object.keys(out).length ? JSON.stringify(out) : null;\n}\n\nexport default function BrandsPage() {\n const perms = usePmPermissions();\n const canWrite = perms.has('update.manage.productManagement.brand');\n const settings = usePmSettings();\n const country = findCountry(settings?.countryCode);\n const [items, setItems] = useState([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState('');\n const [openDialog, setOpenDialog] = useState(false);\n const [editing, setEditing] = useState(null);\n // Default to active-only; the toggle above the table reveals inactive rows.\n const [showInactive, setShowInactive] = useState(false);\n const [form, setForm] = useState(emptyForm());\n const fieldErrors = useFieldErrors();\n\n function emptyForm() {\n return {\n id: '',\n name: '',\n manufacturerCode: '',\n contactPhone: '',\n contactEmail: '',\n isActive: true,\n };\n }\n\n async function load() {\n setLoading(true);\n setError('');\n try {\n const data = await getBrands(undefined, true);\n setItems(data);\n } catch (err) {\n const message = err?.response?.data?.message ?? err?.message ?? 'Failed to load brands';\n setError(message);\n showToast({ message, type: 'error' });\n } finally {\n setLoading(false);\n }\n }\n\n usePermissionedEffect('view.manage.productManagement.brand', () => {\n void load();\n }, []);\n\n function openCreate() {\n setEditing(null);\n setForm({ ...emptyForm(), id: uuidv4() });\n fieldErrors.reset();\n setError('');\n setOpenDialog(true);\n }\n\n function openEdit(item) {\n const { phone, email } = parseContactInfo(item.contactInfo);\n setEditing(item);\n fieldErrors.reset();\n setError('');\n setForm({\n id: item.id,\n name: item.name ?? '',\n manufacturerCode: item.manufacturerCode ?? '',\n contactPhone: phone,\n contactEmail: email,\n isActive: item.isActive !== false,\n });\n setOpenDialog(true);\n }\n\n const mfrCodeBase = validateRequired(form.manufacturerCode, 'Manufacturer code');\n const mfrNorm = form.manufacturerCode.trim().toUpperCase();\n const mfrClash = !mfrCodeBase\n && mfrNorm\n && items.some((b) => b.id !== form.id && (b.manufacturerCode || '').toUpperCase() === mfrNorm);\n const formErrors = {\n name: validateRequired(form.name, 'Name'),\n manufacturerCode: mfrCodeBase || (mfrClash ? 'Code is already in use — edit it manually to make it unique.' : ''),\n contactPhone: validatePhoneForCountry(form.contactPhone, country),\n contactEmail: validateEmail(form.contactEmail),\n };\n const formIsValid = isClean(formErrors);\n\n async function save() {\n if (!formIsValid) {\n fieldErrors.markAllTouched();\n setError('Please fix the highlighted fields.');\n return;\n }\n try {\n await upsertBrand({\n id: form.id,\n name: form.name.trim(),\n manufacturerCode: form.manufacturerCode.trim().toUpperCase(),\n contactInfo: serializeContactInfo({\n phone: form.contactPhone,\n email: form.contactEmail,\n }),\n isActive: form.isActive,\n });\n showToast({ message: 'Brand saved.', type: 'success' });\n setOpenDialog(false);\n await load();\n } catch (err) {\n const message = err?.response?.data?.message ?? err?.message ?? 'Failed to save brand';\n setError(message);\n showToast({ message, type: 'error' });\n }\n }\n\n const visible = showInactive ? items : items.filter((b) => b.isActive !== false);\n\n return (\n <Box>\n <PmNav />\n <PmGuard perm={'view.manage.productManagement.brand'}>\n <PmPageShell\n title=\"Brands\"\n subtitle=\"The manufacturer or supplier of each product.\"\n chips={['Catalog']}\n actions={\n <Stack direction=\"row\" spacing={1}>\n <Button variant=\"outlined\" startIcon={<RefreshRoundedIcon />} onClick={() => void load()}>Refresh</Button>\n {canWrite ? (\n <Button variant=\"contained\" startIcon={<AddRoundedIcon />} onClick={openCreate}>New Brand</Button>\n ) : null}\n </Stack>\n }\n >\n {error ? <Alert severity=\"error\" sx={{ mb: 2 }}>{error}</Alert> : null}\n\n <PmTableCard\n eyebrow=\"Master data\"\n title=\"Brands\"\n subtitle={loading ? 'Loading…' : `${visible.length} ${visible.length === 1 ? 'brand' : 'brands'}`}\n actions={\n <FormControlLabel\n control={<CustomSwitch checked={showInactive}\n onChange={(e) => setShowInactive(e.target.checked)} />}\n label={<Typography variant=\"body2\" sx={{ fontWeight: 600 }}>Show inactive</Typography>}\n labelPlacement=\"start\"\n sx={{ mr: 0.5, ml: 0 }}\n />\n }\n >\n <PmTable>\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Manufacturer Code</TableCell>\n <TableCell>Contact</TableCell>\n <TableCell>Status</TableCell>\n <TableCell align=\"right\">Action</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {loading ? (\n Array.from({ length: 4 }).map((_, i) => (\n <TableRow key={i}>\n {Array.from({ length: 5 }).map((__, j) => (\n <TableCell key={j}><Skeleton height={22} /></TableCell>\n ))}\n </TableRow>\n ))\n ) : visible.length === 0 ? (\n <PmEmptyRow\n colSpan={5}\n icon={SellRoundedIcon}\n title={items.length === 0 ? 'No brands yet' : 'No active brands'}\n hint={items.length === 0\n ? 'Add manufacturers so you can link them to your products.'\n : 'Turn on “Show inactive” to see deactivated brands.'}\n action={items.length === 0 && canWrite ? (\n <Button variant=\"contained\" size=\"small\" startIcon={<AddRoundedIcon />} onClick={openCreate}>\n Create first brand\n </Button>\n ) : null}\n />\n ) : visible.map((b) => {\n const { phone, email } = parseContactInfo(b.contactInfo);\n return (\n <TableRow key={b.id} hover>\n <TableCell sx={{ maxWidth: 240 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 700, wordBreak: 'break-word' }}>{b.name}</Typography>\n </TableCell>\n <TableCell sx={{ maxWidth: 160 }}>\n <Box component=\"span\" sx={{\n display: 'inline-block', px: 0.85, py: 0.25, borderRadius: 1,\n bgcolor: 'grey.100', fontFamily: 'monospace', fontSize: '0.72rem', fontWeight: 800,\n maxWidth: '100%', wordBreak: 'break-all',\n }}>\n {b.manufacturerCode}\n </Box>\n </TableCell>\n <TableCell>\n {phone || email ? (\n <Stack spacing={0.25}>\n {phone ? <Typography variant=\"caption\" sx={{ fontWeight: 600 }}>{phone}</Typography> : null}\n {email ? <Typography variant=\"caption\" color=\"text.secondary\">{email}</Typography> : null}\n </Stack>\n ) : <Typography variant=\"caption\" color=\"text.disabled\">—</Typography>}\n </TableCell>\n <TableCell>\n <Chip\n size=\"small\"\n label={b.isActive ? 'Active' : 'Inactive'}\n color={b.isActive ? 'success' : 'default'}\n variant={b.isActive ? 'filled' : 'outlined'}\n sx={{ fontWeight: 700, borderRadius: 1.5, height: 22 }}\n />\n </TableCell>\n <TableCell align=\"right\">\n {canWrite ? (\n <Button size=\"small\" variant=\"outlined\" onClick={() => openEdit(b)}>Edit</Button>\n ) : null}\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </PmTable>\n </PmTableCard>\n </PmPageShell>\n\n <Dialog open={openDialog} onClose={() => setOpenDialog(false)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{editing ? 'Edit Brand' : 'New Brand'}</DialogTitle>\n <DialogContent dividers>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n required\n label=\"Name\" size=\"small\" fullWidth\n value={form.name}\n inputProps={{ maxLength: 255 }}\n onChange={(e) => {\n const nextName = e.target.value;\n // Auto-derive manufacturer code from initials of every word — but\n // only on create (when editing an existing brand we never overwrite\n // a code the user has already curated).\n const initialsFromName = nextName\n .split(/\\s+/)\n .filter(Boolean)\n .map((w) => w[0])\n .join('')\n .toUpperCase();\n setForm((f) => ({\n ...f,\n name: nextName,\n manufacturerCode: editing ? f.manufacturerCode : initialsFromName,\n }));\n }}\n onBlur={fieldErrors.onBlur('name')}\n error={fieldErrors.show('name') && !!formErrors.name}\n FormHelperTextProps={{ component: 'div' }}\n helperText={<PmFieldHelp message={fieldErrors.show('name') ? formErrors.name : ''} value={form.name} max={255} />}\n />\n <TextField\n required\n label=\"Manufacturer code\" size=\"small\" fullWidth\n value={form.manufacturerCode}\n inputProps={{ maxLength: 100 }}\n onChange={(e) => setForm({ ...form, manufacturerCode: e.target.value.toUpperCase() })}\n onBlur={fieldErrors.onBlur('manufacturerCode')}\n error={fieldErrors.show('manufacturerCode') && !!formErrors.manufacturerCode}\n FormHelperTextProps={{ component: 'div' }}\n helperText={\n <PmFieldHelp\n message={fieldErrors.show('manufacturerCode') && formErrors.manufacturerCode\n ? formErrors.manufacturerCode\n : 'Auto-generated from the name as initials. Edit if needed to make it unique.'}\n value={form.manufacturerCode}\n max={100}\n />\n }\n />\n <TextField\n label=\"Contact Number\"\n size=\"small\"\n fullWidth\n type=\"tel\"\n placeholder={country\n ? (country.phoneMin === country.phoneMax\n ? `${country.phoneMin}-digit local number`\n : `${country.phoneMin}–${country.phoneMax} digit local number`)\n : 'Local number'}\n value={form.contactPhone}\n // Keep only digits and spaces — the dial code lives in the\n // adornment, not in the value.\n onChange={(e) => setForm({ ...form, contactPhone: e.target.value.replace(/[^\\d\\s]/g, '') })}\n onBlur={fieldErrors.onBlur('contactPhone')}\n error={fieldErrors.show('contactPhone') && !!formErrors.contactPhone}\n helperText={\n fieldErrors.show('contactPhone') && formErrors.contactPhone\n ? formErrors.contactPhone\n : country\n ? `Format for ${country.name}: ${country.phoneCode} followed by ${country.phoneMin}${country.phoneMin === country.phoneMax ? '' : `–${country.phoneMax}`} digits.`\n : 'Local number, digits only.'\n }\n InputProps={country ? {\n startAdornment: (\n <InputAdornment position=\"start\">\n <Box component=\"span\" sx={{ fontWeight: 700, color: 'text.secondary' }}>{country.phoneCode}</Box>\n </InputAdornment>\n ),\n } : undefined}\n />\n <TextField\n label=\"Email\"\n size=\"small\"\n fullWidth\n type=\"email\"\n placeholder=\"e.g. contact@manufacturer.example\"\n value={form.contactEmail}\n onChange={(e) => setForm({ ...form, contactEmail: e.target.value })}\n onBlur={fieldErrors.onBlur('contactEmail')}\n error={fieldErrors.show('contactEmail') && !!formErrors.contactEmail}\n helperText={fieldErrors.show('contactEmail') ? formErrors.contactEmail : ''}\n />\n <FormControlLabel\n control={<Checkbox checked={form.isActive}\n onChange={(e) => setForm({ ...form, isActive: e.target.checked })} />}\n label=\"Active\" />\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setOpenDialog(false)}>Cancel</Button>\n <Button variant=\"contained\" disabled={!formIsValid} onClick={() => void save()}>Save</Button>\n </DialogActions>\n </Dialog>\n </PmGuard>\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,SAAS,EAAiB,GAAK;CAC7B,IAAI,CAAC,GAAK,OAAO;EAAE,OAAO;EAAI,OA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C,GAAD;KAAQ,eAAe,EAAc,EAAK;eAAG;IAAc,CAAA,GAC3D,kBAAC,GAAD;KAAQ,SAAQ;KAAY,UAAU,CAAC;KAAa,eAAe,KAAK,GAAK;eAAG;IAAY,CAAA,CAC/E,EAAA,CAAA;GACT;IACD;GACN,EAAA,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"BrandsPage-CjL0bBk0.js","names":[],"sources":["../src/views/BrandsPage.jsx"],"sourcesContent":["import { useState } from 'react';\nimport { v4 as uuidv4 } from 'uuid';\nimport {\n Alert,\n Box,\n Button,\n Checkbox,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n InputAdornment,\n Skeleton,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n TextField,\n Typography,\n} from '@mui/material';\nimport AddRoundedIcon from '@mui/icons-material/AddRounded';\nimport RefreshRoundedIcon from '@mui/icons-material/RefreshRounded';\nimport SellRoundedIcon from '@mui/icons-material/SellRounded';\nimport { showToast } from '@/common/toaster/toaster';\nimport CustomSwitch from '@/views/custom-components/CustomSwitch';\nimport PmPageShell from '@pm/components/PmPageShell';\nimport PmNav from '@pm/components/PmNav';\nimport PmGuard from '@pm/components/PmGuard';\nimport { usePermissionedEffect, usePmPermissions } from '@pm/utils/permissions';\nimport { PmEmptyRow, PmFieldHelp, PmTable, PmTableCard } from '@pm/components/PmTable';\nimport { getBrands, upsertBrand } from '@pm/services/pmApi';\nimport { isClean, validateEmail, validateRequired } from '@pm/utils/validation';\nimport { findCountry, validatePhoneForCountry } from '@/common/constants/countries';\nimport { usePmSettings } from '@pm/utils/settingsStore';\nimport { useFieldErrors } from '@pm/utils/useFieldErrors';\n\n// Backend stores contact_info as a JSON-encoded string. We keep the discrete\n// fields here so the UI is form-friendly, and only ever round-trip the JSON.\nfunction parseContactInfo(raw) {\n if (!raw) return { phone: '', email: '' };\n try {\n const obj = JSON.parse(raw);\n return {\n phone: typeof obj?.phone === 'string' ? obj.phone : '',\n email: typeof obj?.email === 'string' ? obj.email : '',\n };\n } catch {\n return { phone: '', email: '' };\n }\n}\n\nfunction serializeContactInfo({ phone, email }) {\n const out = {};\n if (phone?.trim()) out.phone = phone.trim();\n if (email?.trim()) out.email = email.trim();\n return Object.keys(out).length ? JSON.stringify(out) : null;\n}\n\nexport default function BrandsPage() {\n const perms = usePmPermissions();\n const canWrite = perms.has('update.manage.productManagement.brand');\n const settings = usePmSettings();\n const country = findCountry(settings?.countryCode);\n const [items, setItems] = useState([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState('');\n const [openDialog, setOpenDialog] = useState(false);\n const [editing, setEditing] = useState(null);\n // Default to active-only; the toggle above the table reveals inactive rows.\n const [showInactive, setShowInactive] = useState(false);\n const [form, setForm] = useState(emptyForm());\n const fieldErrors = useFieldErrors();\n\n function emptyForm() {\n return {\n id: '',\n name: '',\n manufacturerCode: '',\n contactPhone: '',\n contactEmail: '',\n isActive: true,\n };\n }\n\n async function load() {\n setLoading(true);\n setError('');\n try {\n const data = await getBrands(undefined, true);\n setItems(data);\n } catch (err) {\n const message = err?.response?.data?.message ?? err?.message ?? 'Failed to load brands';\n setError(message);\n showToast({ message, type: 'error' });\n } finally {\n setLoading(false);\n }\n }\n\n usePermissionedEffect('view.manage.productManagement.brand', () => {\n void load();\n }, []);\n\n function openCreate() {\n setEditing(null);\n setForm({ ...emptyForm(), id: uuidv4() });\n fieldErrors.reset();\n setError('');\n setOpenDialog(true);\n }\n\n function openEdit(item) {\n const { phone, email } = parseContactInfo(item.contactInfo);\n setEditing(item);\n fieldErrors.reset();\n setError('');\n setForm({\n id: item.id,\n name: item.name ?? '',\n manufacturerCode: item.manufacturerCode ?? '',\n contactPhone: phone,\n contactEmail: email,\n isActive: item.isActive !== false,\n });\n setOpenDialog(true);\n }\n\n const mfrCodeBase = validateRequired(form.manufacturerCode, 'Manufacturer code');\n const mfrNorm = form.manufacturerCode.trim().toUpperCase();\n const mfrClash = !mfrCodeBase\n && mfrNorm\n && items.some((b) => b.id !== form.id && (b.manufacturerCode || '').toUpperCase() === mfrNorm);\n const formErrors = {\n name: validateRequired(form.name, 'Name'),\n manufacturerCode: mfrCodeBase || (mfrClash ? 'Code is already in use — edit it manually to make it unique.' : ''),\n contactPhone: validatePhoneForCountry(form.contactPhone, country),\n contactEmail: validateEmail(form.contactEmail),\n };\n const formIsValid = isClean(formErrors);\n\n async function save() {\n if (!formIsValid) {\n fieldErrors.markAllTouched();\n setError('Please fix the highlighted fields.');\n return;\n }\n try {\n await upsertBrand({\n id: form.id,\n name: form.name.trim(),\n manufacturerCode: form.manufacturerCode.trim().toUpperCase(),\n contactInfo: serializeContactInfo({\n phone: form.contactPhone,\n email: form.contactEmail,\n }),\n isActive: form.isActive,\n });\n showToast({ message: 'Brand saved.', type: 'success' });\n setOpenDialog(false);\n await load();\n } catch (err) {\n const message = err?.response?.data?.message ?? err?.message ?? 'Failed to save brand';\n setError(message);\n showToast({ message, type: 'error' });\n }\n }\n\n const visible = showInactive ? items : items.filter((b) => b.isActive !== false);\n\n return (\n <Box>\n <PmNav />\n <PmGuard perm={'view.manage.productManagement.brand'}>\n <PmPageShell\n title=\"Brands\"\n subtitle=\"The manufacturer or supplier of each product.\"\n chips={['Catalog']}\n actions={\n <Stack direction=\"row\" spacing={1}>\n <Button variant=\"outlined\" startIcon={<RefreshRoundedIcon />} onClick={() => void load()}>Refresh</Button>\n {canWrite ? (\n <Button variant=\"contained\" startIcon={<AddRoundedIcon />} onClick={openCreate}>New Brand</Button>\n ) : null}\n </Stack>\n }\n >\n {error ? <Alert severity=\"error\" sx={{ mb: 2 }}>{error}</Alert> : null}\n\n <PmTableCard\n eyebrow=\"Master data\"\n title=\"Brands\"\n subtitle={loading ? 'Loading…' : `${visible.length} ${visible.length === 1 ? 'brand' : 'brands'}`}\n actions={\n <FormControlLabel\n control={<CustomSwitch checked={showInactive}\n onChange={(e) => setShowInactive(e.target.checked)} />}\n label={<Typography variant=\"body2\" sx={{ fontWeight: 600 }}>Show inactive</Typography>}\n labelPlacement=\"start\"\n sx={{ mr: 0.5, ml: 0 }}\n />\n }\n >\n <PmTable>\n <TableHead>\n <TableRow>\n <TableCell>Name</TableCell>\n <TableCell>Manufacturer Code</TableCell>\n <TableCell>Contact</TableCell>\n <TableCell>Status</TableCell>\n <TableCell align=\"right\">Action</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {loading ? (\n Array.from({ length: 4 }).map((_, i) => (\n <TableRow key={i}>\n {Array.from({ length: 5 }).map((__, j) => (\n <TableCell key={j}><Skeleton height={22} /></TableCell>\n ))}\n </TableRow>\n ))\n ) : visible.length === 0 ? (\n <PmEmptyRow\n colSpan={5}\n icon={SellRoundedIcon}\n title={items.length === 0 ? 'No brands yet' : 'No active brands'}\n hint={items.length === 0\n ? 'Add manufacturers so you can link them to your products.'\n : 'Turn on “Show inactive” to see deactivated brands.'}\n action={items.length === 0 && canWrite ? (\n <Button variant=\"contained\" size=\"small\" startIcon={<AddRoundedIcon />} onClick={openCreate}>\n Create first brand\n </Button>\n ) : null}\n />\n ) : visible.map((b) => {\n const { phone, email } = parseContactInfo(b.contactInfo);\n return (\n <TableRow key={b.id} hover>\n <TableCell sx={{ maxWidth: 240 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 700, wordBreak: 'break-word' }}>{b.name}</Typography>\n </TableCell>\n <TableCell sx={{ maxWidth: 160 }}>\n <Box component=\"span\" sx={{\n display: 'inline-block', px: 0.85, py: 0.25, borderRadius: 1,\n bgcolor: 'grey.100', fontFamily: 'monospace', fontSize: '0.72rem', fontWeight: 800,\n maxWidth: '100%', wordBreak: 'break-all',\n }}>\n {b.manufacturerCode}\n </Box>\n </TableCell>\n <TableCell>\n {phone || email ? (\n <Stack spacing={0.25}>\n {phone ? <Typography variant=\"caption\" sx={{ fontWeight: 600 }}>{phone}</Typography> : null}\n {email ? <Typography variant=\"caption\" color=\"text.secondary\">{email}</Typography> : null}\n </Stack>\n ) : <Typography variant=\"caption\" color=\"text.disabled\">—</Typography>}\n </TableCell>\n <TableCell>\n <Chip\n size=\"small\"\n label={b.isActive ? 'Active' : 'Inactive'}\n color={b.isActive ? 'success' : 'default'}\n variant={b.isActive ? 'filled' : 'outlined'}\n sx={{ fontWeight: 700, borderRadius: 1.5, height: 22 }}\n />\n </TableCell>\n <TableCell align=\"right\">\n {canWrite ? (\n <Button size=\"small\" variant=\"outlined\" onClick={() => openEdit(b)}>Edit</Button>\n ) : null}\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </PmTable>\n </PmTableCard>\n </PmPageShell>\n\n <Dialog open={openDialog} onClose={() => setOpenDialog(false)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{editing ? 'Edit Brand' : 'New Brand'}</DialogTitle>\n <DialogContent dividers>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n required\n label=\"Name\" size=\"small\" fullWidth\n value={form.name}\n inputProps={{ maxLength: 255 }}\n onChange={(e) => {\n const nextName = e.target.value;\n // Auto-derive manufacturer code from initials of every word — but\n // only on create (when editing an existing brand we never overwrite\n // a code the user has already curated).\n const initialsFromName = nextName\n .split(/\\s+/)\n .filter(Boolean)\n .map((w) => w[0])\n .join('')\n .toUpperCase();\n setForm((f) => ({\n ...f,\n name: nextName,\n manufacturerCode: editing ? f.manufacturerCode : initialsFromName,\n }));\n }}\n onBlur={fieldErrors.onBlur('name')}\n error={fieldErrors.show('name') && !!formErrors.name}\n FormHelperTextProps={{ component: 'div' }}\n helperText={<PmFieldHelp message={fieldErrors.show('name') ? formErrors.name : ''} value={form.name} max={255} />}\n />\n <TextField\n required\n label=\"Manufacturer code\" size=\"small\" fullWidth\n value={form.manufacturerCode}\n inputProps={{ maxLength: 100 }}\n onChange={(e) => setForm({ ...form, manufacturerCode: e.target.value.toUpperCase() })}\n onBlur={fieldErrors.onBlur('manufacturerCode')}\n error={fieldErrors.show('manufacturerCode') && !!formErrors.manufacturerCode}\n FormHelperTextProps={{ component: 'div' }}\n helperText={\n <PmFieldHelp\n message={fieldErrors.show('manufacturerCode') && formErrors.manufacturerCode\n ? formErrors.manufacturerCode\n : 'Auto-generated from the name as initials. Edit if needed to make it unique.'}\n value={form.manufacturerCode}\n max={100}\n />\n }\n />\n <TextField\n label=\"Contact Number\"\n size=\"small\"\n fullWidth\n type=\"tel\"\n placeholder={country\n ? (country.phoneMin === country.phoneMax\n ? `${country.phoneMin}-digit local number`\n : `${country.phoneMin}–${country.phoneMax} digit local number`)\n : 'Local number'}\n value={form.contactPhone}\n // Keep only digits and spaces — the dial code lives in the\n // adornment, not in the value.\n onChange={(e) => setForm({ ...form, contactPhone: e.target.value.replace(/[^\\d\\s]/g, '') })}\n onBlur={fieldErrors.onBlur('contactPhone')}\n error={fieldErrors.show('contactPhone') && !!formErrors.contactPhone}\n helperText={\n fieldErrors.show('contactPhone') && formErrors.contactPhone\n ? formErrors.contactPhone\n : country\n ? `Format for ${country.name}: ${country.phoneCode} followed by ${country.phoneMin}${country.phoneMin === country.phoneMax ? '' : `–${country.phoneMax}`} digits.`\n : 'Local number, digits only.'\n }\n InputProps={country ? {\n startAdornment: (\n <InputAdornment position=\"start\">\n <Box component=\"span\" sx={{ fontWeight: 700, color: 'text.secondary' }}>{country.phoneCode}</Box>\n </InputAdornment>\n ),\n } : undefined}\n />\n <TextField\n label=\"Email\"\n size=\"small\"\n fullWidth\n type=\"email\"\n placeholder=\"e.g. contact@manufacturer.example\"\n value={form.contactEmail}\n onChange={(e) => setForm({ ...form, contactEmail: e.target.value })}\n onBlur={fieldErrors.onBlur('contactEmail')}\n error={fieldErrors.show('contactEmail') && !!formErrors.contactEmail}\n helperText={fieldErrors.show('contactEmail') ? formErrors.contactEmail : ''}\n />\n <FormControlLabel\n control={<Checkbox checked={form.isActive}\n onChange={(e) => setForm({ ...form, isActive: e.target.checked })} />}\n label=\"Active\" />\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setOpenDialog(false)}>Cancel</Button>\n <Button variant=\"contained\" disabled={!formIsValid}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