warqadui 0.0.92 → 0.0.93
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/index.d.mts +225 -1
- package/dist/index.d.ts +225 -1
- package/dist/index.js +1444 -55
- package/dist/index.mjs +1426 -55
- package/dist/styles.js +99 -0
- package/dist/styles.mjs +99 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,7 +35,10 @@ __export(index_exports, {
|
|
|
35
35
|
Accounts: () => Accounts_default,
|
|
36
36
|
AdminProtectedRoute: () => AdminProtectedRoute,
|
|
37
37
|
Badge: () => Badge,
|
|
38
|
+
BrandField: () => Feilds_default3,
|
|
39
|
+
BrandForm: () => BrandForm_default,
|
|
38
40
|
Branding: () => Branding,
|
|
41
|
+
Brands: () => Brands_default,
|
|
39
42
|
Breadcrumbs: () => Breadcrumbs,
|
|
40
43
|
Button: () => Button,
|
|
41
44
|
Card: () => Card,
|
|
@@ -44,7 +47,10 @@ __export(index_exports, {
|
|
|
44
47
|
CardFooter: () => CardFooter,
|
|
45
48
|
CardHeader: () => CardHeader,
|
|
46
49
|
CardTitle: () => CardTitle,
|
|
50
|
+
Categories: () => Categories_default,
|
|
47
51
|
CategoryCard: () => CategoryCard,
|
|
52
|
+
CategoryField: () => Feilds_default4,
|
|
53
|
+
CategoryForm: () => CategoryForm_default,
|
|
48
54
|
ClassicSpin: () => ClassicSpin,
|
|
49
55
|
CodeBlock: () => CodeBlock,
|
|
50
56
|
ConfirmModal: () => ConfirmModal,
|
|
@@ -62,10 +68,16 @@ __export(index_exports, {
|
|
|
62
68
|
LoadingSpin: () => LoadingSpin,
|
|
63
69
|
Modal: () => Modal,
|
|
64
70
|
OverlaySpin: () => OverlaySpin,
|
|
71
|
+
PackField: () => Pack_default,
|
|
72
|
+
PackForm: () => PackForm_default,
|
|
73
|
+
Packs: () => Packs_default,
|
|
65
74
|
PageA4: () => PageA4,
|
|
66
75
|
PageHeader: () => PageHeader,
|
|
67
76
|
PhoneInput: () => PhoneInput,
|
|
68
77
|
PostTable: () => PostTable,
|
|
78
|
+
ProductField: () => Feilds_default5,
|
|
79
|
+
ProductForm: () => ProductForm_default,
|
|
80
|
+
Products: () => Products_default,
|
|
69
81
|
ProfileCard: () => ProfileCard,
|
|
70
82
|
ProfileDropdown: () => ProfileDropdown,
|
|
71
83
|
ProfilePage: () => ProfilePage_default,
|
|
@@ -96,10 +108,16 @@ __export(index_exports, {
|
|
|
96
108
|
Wallets: () => Wallets_default,
|
|
97
109
|
WarqadProvider: () => WarqadProvider,
|
|
98
110
|
createAccountSchema: () => createAccountSchema,
|
|
111
|
+
createBrandSchema: () => createBrandSchema,
|
|
112
|
+
createCategorySchema: () => createCategorySchema,
|
|
113
|
+
createPackSchema: () => createPackSchema,
|
|
114
|
+
createProductSchema: () => createProductSchema,
|
|
99
115
|
createUserSchema: () => createUserSchema,
|
|
100
116
|
createWalletSchema: () => createWalletSchema,
|
|
101
117
|
generatePdf: () => generatePdf,
|
|
102
118
|
linkUserSchema: () => linkUserSchema,
|
|
119
|
+
packProductItemSchema: () => packProductItemSchema,
|
|
120
|
+
packTypes: () => packTypes,
|
|
103
121
|
resetPasswordSchema: () => resetPasswordSchema,
|
|
104
122
|
storage: () => storage,
|
|
105
123
|
updateUserEmailSchema: () => updateUserEmailSchema,
|
|
@@ -421,7 +439,8 @@ var Enums = {
|
|
|
421
439
|
verificationTypes: ["email_verification", "password_reset"],
|
|
422
440
|
auditActions: ["create", "update", "delete", "login", "logout"],
|
|
423
441
|
walletTypes: ["bank", "cash", "mobile"],
|
|
424
|
-
currencies: ["USD", "TZS", "KES", "CNY"]
|
|
442
|
+
currencies: ["USD", "TZS", "KES", "CNY"],
|
|
443
|
+
packTypes: ["pressure", "bag", "boxes"]
|
|
425
444
|
};
|
|
426
445
|
var Enums_default = Enums;
|
|
427
446
|
|
|
@@ -1446,13 +1465,13 @@ var Input = (0, import_react10.forwardRef)(
|
|
|
1446
1465
|
}
|
|
1447
1466
|
}
|
|
1448
1467
|
}, [props.value, name, form]);
|
|
1449
|
-
let
|
|
1468
|
+
let message24 = error;
|
|
1450
1469
|
if (form && name) {
|
|
1451
1470
|
const {
|
|
1452
1471
|
formState: { errors }
|
|
1453
1472
|
} = form;
|
|
1454
1473
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
1455
|
-
|
|
1474
|
+
message24 = errorObj?.message;
|
|
1456
1475
|
}
|
|
1457
1476
|
const watchedValue = form?.watch(name);
|
|
1458
1477
|
(0, import_react10.useEffect)(() => {
|
|
@@ -1521,7 +1540,7 @@ var Input = (0, import_react10.forwardRef)(
|
|
|
1521
1540
|
}
|
|
1522
1541
|
)
|
|
1523
1542
|
] }),
|
|
1524
|
-
|
|
1543
|
+
message24 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
1525
1544
|
]
|
|
1526
1545
|
}
|
|
1527
1546
|
);
|
|
@@ -1844,7 +1863,7 @@ var PhoneInput = (0, import_react13.forwardRef)(
|
|
|
1844
1863
|
const [isFocused, setIsFocused] = (0, import_react13.useState)(false);
|
|
1845
1864
|
const { theme } = useWarqadConfig();
|
|
1846
1865
|
const primaryColor = theme?.primaryColor;
|
|
1847
|
-
let
|
|
1866
|
+
let message24 = error;
|
|
1848
1867
|
if (form && name) {
|
|
1849
1868
|
const {
|
|
1850
1869
|
formState: { errors }
|
|
@@ -1854,7 +1873,7 @@ var PhoneInput = (0, import_react13.forwardRef)(
|
|
|
1854
1873
|
for (const part of nameParts) {
|
|
1855
1874
|
currentError = currentError?.[part];
|
|
1856
1875
|
}
|
|
1857
|
-
|
|
1876
|
+
message24 = currentError?.message || message24;
|
|
1858
1877
|
}
|
|
1859
1878
|
const renderInput = (onChangeHandler, currentValue) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `space-y-2 group relative ${containerClassName}`, children: [
|
|
1860
1879
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
@@ -1905,7 +1924,7 @@ var PhoneInput = (0, import_react13.forwardRef)(
|
|
|
1905
1924
|
}
|
|
1906
1925
|
)
|
|
1907
1926
|
] }),
|
|
1908
|
-
|
|
1927
|
+
message24 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
1909
1928
|
] });
|
|
1910
1929
|
if (form && name) {
|
|
1911
1930
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
@@ -2075,7 +2094,7 @@ var SelectRoot = ({
|
|
|
2075
2094
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2076
2095
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2077
2096
|
}, [fieldInternalProps]);
|
|
2078
|
-
let
|
|
2097
|
+
let message24 = error;
|
|
2079
2098
|
if (form && name) {
|
|
2080
2099
|
const {
|
|
2081
2100
|
formState: { errors }
|
|
@@ -2085,7 +2104,7 @@ var SelectRoot = ({
|
|
|
2085
2104
|
for (const part of nameParts) {
|
|
2086
2105
|
currentError = currentError?.[part];
|
|
2087
2106
|
}
|
|
2088
|
-
|
|
2107
|
+
message24 = currentError?.message || message24;
|
|
2089
2108
|
}
|
|
2090
2109
|
const allOptions = initialOptions?.length ? initialOptions : registeredOptions;
|
|
2091
2110
|
const valueCtx = {
|
|
@@ -2146,7 +2165,7 @@ var SelectRoot = ({
|
|
|
2146
2165
|
String(opt.value) || index
|
|
2147
2166
|
)) })
|
|
2148
2167
|
] }),
|
|
2149
|
-
|
|
2168
|
+
message24 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
2150
2169
|
]
|
|
2151
2170
|
}
|
|
2152
2171
|
) });
|
|
@@ -2382,13 +2401,13 @@ var Textarea = (0, import_react15.forwardRef)(
|
|
|
2382
2401
|
const [isFocused, setIsFocused] = (0, import_react15.useState)(false);
|
|
2383
2402
|
const { theme } = useWarqadConfig();
|
|
2384
2403
|
const primaryColor = theme?.primaryColor;
|
|
2385
|
-
let
|
|
2404
|
+
let message24 = error;
|
|
2386
2405
|
if (form && name) {
|
|
2387
2406
|
const {
|
|
2388
2407
|
formState: { errors }
|
|
2389
2408
|
} = form;
|
|
2390
2409
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
2391
|
-
|
|
2410
|
+
message24 = errorObj?.message;
|
|
2392
2411
|
}
|
|
2393
2412
|
const renderInput = (inputProps, ref2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `space-y-2 group w-full! relative ${containerClassName}`, children: [
|
|
2394
2413
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
@@ -2426,7 +2445,7 @@ var Textarea = (0, import_react15.forwardRef)(
|
|
|
2426
2445
|
}
|
|
2427
2446
|
}
|
|
2428
2447
|
) }),
|
|
2429
|
-
|
|
2448
|
+
message24 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
2430
2449
|
] });
|
|
2431
2450
|
(0, import_react15.useEffect)(() => {
|
|
2432
2451
|
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
@@ -2745,7 +2764,7 @@ var SearchApiRoot = ({
|
|
|
2745
2764
|
const filteredOptions = options.filter(
|
|
2746
2765
|
(option) => !filter.includes(getOptionValue(option))
|
|
2747
2766
|
);
|
|
2748
|
-
let
|
|
2767
|
+
let message24 = error || errorMessage;
|
|
2749
2768
|
if (form && name) {
|
|
2750
2769
|
const {
|
|
2751
2770
|
formState: { errors }
|
|
@@ -2755,7 +2774,7 @@ var SearchApiRoot = ({
|
|
|
2755
2774
|
for (const part of nameParts) {
|
|
2756
2775
|
currentError = currentError?.[part];
|
|
2757
2776
|
}
|
|
2758
|
-
|
|
2777
|
+
message24 = currentError?.message || message24;
|
|
2759
2778
|
}
|
|
2760
2779
|
const valueCtx = {
|
|
2761
2780
|
isOpen,
|
|
@@ -2789,7 +2808,7 @@ var SearchApiRoot = ({
|
|
|
2789
2808
|
form,
|
|
2790
2809
|
name,
|
|
2791
2810
|
obj,
|
|
2792
|
-
error:
|
|
2811
|
+
error: message24,
|
|
2793
2812
|
onSelect,
|
|
2794
2813
|
onClear
|
|
2795
2814
|
};
|
|
@@ -3156,19 +3175,19 @@ var DateInput = (0, import_react17.forwardRef)(
|
|
|
3156
3175
|
const { theme } = useWarqadConfig();
|
|
3157
3176
|
const primaryColor = theme?.primaryColor;
|
|
3158
3177
|
const [isFocused, setIsFocused] = (0, import_react17.useState)(false);
|
|
3159
|
-
let
|
|
3178
|
+
let message24 = error;
|
|
3160
3179
|
if (form && name) {
|
|
3161
3180
|
const {
|
|
3162
3181
|
formState: { errors }
|
|
3163
3182
|
} = form;
|
|
3164
3183
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
3165
|
-
|
|
3184
|
+
message24 = errorObj?.message;
|
|
3166
3185
|
}
|
|
3167
3186
|
const inputStyles = `w-full px-2.5 py-1 rounded-md border! shadow-none transition-all! duration-200! outline-none!
|
|
3168
3187
|
bg-white! dark:bg-zinc-900!
|
|
3169
3188
|
text-gray-900! dark:text-zinc-100!
|
|
3170
3189
|
hover:bg-white! dark:hover:bg-zinc-900!
|
|
3171
|
-
${
|
|
3190
|
+
${message24 ? "border-red-500 hover:border-red-500 [&.ant-picker-focused]:border-red-500 [&.ant-picker-focused]:ring-red-500/20" : "border-gray-200 dark:border-zinc-700 hover:border-gray-200 dark:hover:border-zinc-700 [&.ant-picker-focused]:ring-2"}
|
|
3172
3191
|
[&.ant-picker-focused]:bg-white dark:[&.ant-picker-focused]:bg-zinc-900
|
|
3173
3192
|
${className}`;
|
|
3174
3193
|
const renderDatePicker = (val, changeHandler, blurHandler, refProps) => {
|
|
@@ -3191,8 +3210,8 @@ var DateInput = (0, import_react17.forwardRef)(
|
|
|
3191
3210
|
needConfirm: false,
|
|
3192
3211
|
style: {
|
|
3193
3212
|
height: "var(--input-height, 40px)",
|
|
3194
|
-
borderColor: isFocused && !
|
|
3195
|
-
boxShadow: isFocused && !
|
|
3213
|
+
borderColor: isFocused && !message24 ? primaryColor : void 0,
|
|
3214
|
+
boxShadow: isFocused && !message24 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
|
|
3196
3215
|
},
|
|
3197
3216
|
classNames: { popup: { root: "z-50" } },
|
|
3198
3217
|
suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
@@ -3222,7 +3241,7 @@ var DateInput = (0, import_react17.forwardRef)(
|
|
|
3222
3241
|
{
|
|
3223
3242
|
className: "block text-xs font-medium transition-colors duration-200",
|
|
3224
3243
|
style: {
|
|
3225
|
-
color:
|
|
3244
|
+
color: message24 ? "#ef4444" : isFocused ? primaryColor : void 0
|
|
3226
3245
|
},
|
|
3227
3246
|
children: [
|
|
3228
3247
|
label,
|
|
@@ -3243,7 +3262,7 @@ var DateInput = (0, import_react17.forwardRef)(
|
|
|
3243
3262
|
)
|
|
3244
3263
|
}
|
|
3245
3264
|
) : renderDatePicker(value, onChange, onBlur, ref),
|
|
3246
|
-
|
|
3265
|
+
message24 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
3247
3266
|
] });
|
|
3248
3267
|
}
|
|
3249
3268
|
);
|
|
@@ -7512,17 +7531,17 @@ var preWarningFns = [];
|
|
|
7512
7531
|
var preMessage = (fn) => {
|
|
7513
7532
|
preWarningFns.push(fn);
|
|
7514
7533
|
};
|
|
7515
|
-
function warning(valid,
|
|
7534
|
+
function warning(valid, message24) {
|
|
7516
7535
|
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
|
|
7517
|
-
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"),
|
|
7536
|
+
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message24);
|
|
7518
7537
|
if (finalMessage) {
|
|
7519
7538
|
console.error(`Warning: ${finalMessage}`);
|
|
7520
7539
|
}
|
|
7521
7540
|
}
|
|
7522
7541
|
}
|
|
7523
|
-
function note(valid,
|
|
7542
|
+
function note(valid, message24) {
|
|
7524
7543
|
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
|
|
7525
|
-
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"),
|
|
7544
|
+
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message24);
|
|
7526
7545
|
if (finalMessage) {
|
|
7527
7546
|
console.warn(`Note: ${finalMessage}`);
|
|
7528
7547
|
}
|
|
@@ -7531,17 +7550,17 @@ function note(valid, message16) {
|
|
|
7531
7550
|
function resetWarned() {
|
|
7532
7551
|
warned = {};
|
|
7533
7552
|
}
|
|
7534
|
-
function call(method, valid,
|
|
7535
|
-
if (!valid && !warned[
|
|
7536
|
-
method(false,
|
|
7537
|
-
warned[
|
|
7553
|
+
function call(method, valid, message24) {
|
|
7554
|
+
if (!valid && !warned[message24]) {
|
|
7555
|
+
method(false, message24);
|
|
7556
|
+
warned[message24] = true;
|
|
7538
7557
|
}
|
|
7539
7558
|
}
|
|
7540
|
-
function warningOnce(valid,
|
|
7541
|
-
call(warning, valid,
|
|
7559
|
+
function warningOnce(valid, message24) {
|
|
7560
|
+
call(warning, valid, message24);
|
|
7542
7561
|
}
|
|
7543
|
-
function noteOnce(valid,
|
|
7544
|
-
call(note, valid,
|
|
7562
|
+
function noteOnce(valid, message24) {
|
|
7563
|
+
call(note, valid, message24);
|
|
7545
7564
|
}
|
|
7546
7565
|
warningOnce.preMessage = preMessage;
|
|
7547
7566
|
warningOnce.resetWarned = resetWarned;
|
|
@@ -7552,8 +7571,8 @@ var import_react31 = __toESM(require("react"));
|
|
|
7552
7571
|
function camelCase(input) {
|
|
7553
7572
|
return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
|
|
7554
7573
|
}
|
|
7555
|
-
function warning2(valid,
|
|
7556
|
-
warningOnce(valid, `[@ant-design/icons] ${
|
|
7574
|
+
function warning2(valid, message24) {
|
|
7575
|
+
warningOnce(valid, `[@ant-design/icons] ${message24}`);
|
|
7557
7576
|
}
|
|
7558
7577
|
function isIconDefinition(target) {
|
|
7559
7578
|
return typeof target === "object" && typeof target.name === "string" && typeof target.theme === "string" && (typeof target.icon === "object" || typeof target.icon === "function");
|
|
@@ -10129,29 +10148,1381 @@ var WalletField = {
|
|
|
10129
10148
|
};
|
|
10130
10149
|
var Feilds_default2 = WalletField;
|
|
10131
10150
|
|
|
10151
|
+
// src/components/brands/Brands.tsx
|
|
10152
|
+
var import_react_router_dom17 = require("react-router-dom");
|
|
10153
|
+
var import_lucide_react26 = require("lucide-react");
|
|
10154
|
+
var import_react45 = require("react");
|
|
10155
|
+
var import_antd18 = require("antd");
|
|
10156
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
10157
|
+
function Brands({ v, url }) {
|
|
10158
|
+
const { branchId } = (0, import_react_router_dom17.useParams)();
|
|
10159
|
+
const [deleteBrand, setDeleteBrand] = (0, import_react45.useState)(null);
|
|
10160
|
+
const { isLoading, remove } = useApis_default();
|
|
10161
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10162
|
+
url: url || `/brands/get${branchId ? `?branch=${branchId}` : ""}`,
|
|
10163
|
+
v,
|
|
10164
|
+
dateFilter: false
|
|
10165
|
+
});
|
|
10166
|
+
const { Modal: Modal2 } = useModal();
|
|
10167
|
+
const navigate = (0, import_react_router_dom17.useNavigate)();
|
|
10168
|
+
const items = (data2) => [
|
|
10169
|
+
{
|
|
10170
|
+
label: `Edit Brand`,
|
|
10171
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react26.FilePenLine, { size: 16 }),
|
|
10172
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10173
|
+
},
|
|
10174
|
+
{
|
|
10175
|
+
label: `Delete Brand`,
|
|
10176
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react26.Trash2, { className: "text-red-500", size: 16 }),
|
|
10177
|
+
onClick: () => setDeleteBrand(data2)
|
|
10178
|
+
}
|
|
10179
|
+
].filter(Boolean);
|
|
10180
|
+
const columns = [
|
|
10181
|
+
{
|
|
10182
|
+
accessorKey: "name",
|
|
10183
|
+
header: "Name",
|
|
10184
|
+
cell: ({ row }) => {
|
|
10185
|
+
const brand = row.original;
|
|
10186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { children: brand?.name });
|
|
10187
|
+
}
|
|
10188
|
+
},
|
|
10189
|
+
{
|
|
10190
|
+
accessorKey: "actions",
|
|
10191
|
+
header: "Actions",
|
|
10192
|
+
cell: ({ row }) => {
|
|
10193
|
+
const data2 = row.original;
|
|
10194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10195
|
+
Dropdown,
|
|
10196
|
+
{
|
|
10197
|
+
className: "cursor-pointer w-[150px]",
|
|
10198
|
+
items: items(data2),
|
|
10199
|
+
triggerMode: "hover",
|
|
10200
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react26.EllipsisVertical, {})
|
|
10201
|
+
}
|
|
10202
|
+
);
|
|
10203
|
+
}
|
|
10204
|
+
}
|
|
10205
|
+
].filter(Boolean);
|
|
10206
|
+
const brands = data?.data || [];
|
|
10207
|
+
const onDelete = async (id) => {
|
|
10208
|
+
try {
|
|
10209
|
+
await remove({ url: `/brands/delete/${id}` });
|
|
10210
|
+
import_antd18.message.success("Brand deleted successfully");
|
|
10211
|
+
reload();
|
|
10212
|
+
setDeleteBrand(null);
|
|
10213
|
+
} catch (error) {
|
|
10214
|
+
import_antd18.message.error(error.message || "Something went wrong");
|
|
10215
|
+
return error;
|
|
10216
|
+
}
|
|
10217
|
+
};
|
|
10218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
|
|
10219
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Modal2, {}),
|
|
10220
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10221
|
+
ConfirmModal,
|
|
10222
|
+
{
|
|
10223
|
+
isOpen: !!deleteBrand,
|
|
10224
|
+
isLoading,
|
|
10225
|
+
onClose: () => setDeleteBrand(null),
|
|
10226
|
+
title: `Delete Brand`,
|
|
10227
|
+
description: `Are you sure you want to delete "${deleteBrand?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
10228
|
+
confirmationWord: "delete",
|
|
10229
|
+
onSubmit: () => onDelete(deleteBrand?._id),
|
|
10230
|
+
children: null
|
|
10231
|
+
}
|
|
10232
|
+
),
|
|
10233
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
10234
|
+
TransactionViewComponent,
|
|
10235
|
+
{
|
|
10236
|
+
columns,
|
|
10237
|
+
data: brands,
|
|
10238
|
+
title: `Brands`,
|
|
10239
|
+
description: `Add or update brands`,
|
|
10240
|
+
index: true,
|
|
10241
|
+
createTitle: `Add Brand`,
|
|
10242
|
+
onCreate: () => {
|
|
10243
|
+
navigate("create");
|
|
10244
|
+
}
|
|
10245
|
+
}
|
|
10246
|
+
)
|
|
10247
|
+
] });
|
|
10248
|
+
}
|
|
10249
|
+
var Brands_default = Brands;
|
|
10250
|
+
|
|
10251
|
+
// src/components/brands/schema.ts
|
|
10252
|
+
var import_zod12 = require("zod");
|
|
10253
|
+
var createBrandSchema = import_zod12.z.object({
|
|
10254
|
+
name: import_zod12.z.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
10255
|
+
branch: import_zod12.z.string().optional()
|
|
10256
|
+
});
|
|
10257
|
+
|
|
10258
|
+
// src/components/brands/BrandForm.tsx
|
|
10259
|
+
var import_react_hook_form16 = require("react-hook-form");
|
|
10260
|
+
var import_zod13 = require("@hookform/resolvers/zod");
|
|
10261
|
+
var import_antd19 = require("antd");
|
|
10262
|
+
var import_react46 = require("react");
|
|
10263
|
+
var import_react_router_dom18 = require("react-router-dom");
|
|
10264
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
10265
|
+
function BrandForm() {
|
|
10266
|
+
const { branchId } = (0, import_react_router_dom18.useParams)();
|
|
10267
|
+
const { getQuery, navigate } = useApp_default();
|
|
10268
|
+
const id = getQuery("id");
|
|
10269
|
+
const isEdit = !!id;
|
|
10270
|
+
const { post, put, isLoading } = useApis_default();
|
|
10271
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10272
|
+
const methods = (0, import_react_hook_form16.useForm)({
|
|
10273
|
+
resolver: (0, import_zod13.zodResolver)(createBrandSchema),
|
|
10274
|
+
defaultValues: {
|
|
10275
|
+
name: ""
|
|
10276
|
+
},
|
|
10277
|
+
shouldUnregister: false
|
|
10278
|
+
});
|
|
10279
|
+
const { handleSubmit } = methods;
|
|
10280
|
+
const onSubmit = async (data) => {
|
|
10281
|
+
try {
|
|
10282
|
+
if (isEdit) {
|
|
10283
|
+
await put({
|
|
10284
|
+
url: `/brands/update/${id}`,
|
|
10285
|
+
body: {
|
|
10286
|
+
...data,
|
|
10287
|
+
branch: branchId ? branchId : data.branch
|
|
10288
|
+
}
|
|
10289
|
+
});
|
|
10290
|
+
} else {
|
|
10291
|
+
await post({
|
|
10292
|
+
url: "/brands/create",
|
|
10293
|
+
body: {
|
|
10294
|
+
...data,
|
|
10295
|
+
branch: branchId ? branchId : data.branch
|
|
10296
|
+
}
|
|
10297
|
+
});
|
|
10298
|
+
}
|
|
10299
|
+
import_antd19.message.success(`Brand ${isEdit ? "updated" : "created"} successfully`);
|
|
10300
|
+
navigate(-1);
|
|
10301
|
+
} catch (error) {
|
|
10302
|
+
import_antd19.message.error(error?.message || "Something went wrong");
|
|
10303
|
+
}
|
|
10304
|
+
};
|
|
10305
|
+
const fetches = async () => {
|
|
10306
|
+
try {
|
|
10307
|
+
const res = await get({
|
|
10308
|
+
url: `/brands/get?id=${id}${branchId ? `&branch=${branchId}` : ""}`
|
|
10309
|
+
});
|
|
10310
|
+
const data = res.data;
|
|
10311
|
+
methods.reset(data);
|
|
10312
|
+
} catch (error) {
|
|
10313
|
+
import_antd19.message.error(error?.message || "Something went wrong");
|
|
10314
|
+
}
|
|
10315
|
+
};
|
|
10316
|
+
(0, import_react46.useEffect)(() => {
|
|
10317
|
+
if (isEdit) {
|
|
10318
|
+
fetches();
|
|
10319
|
+
}
|
|
10320
|
+
}, [id]);
|
|
10321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
10322
|
+
Card,
|
|
10323
|
+
{
|
|
10324
|
+
className: "max-w-4xl mx-auto mt-10 relative",
|
|
10325
|
+
isLoading: isLoadingGet,
|
|
10326
|
+
loadingText: "Processing...",
|
|
10327
|
+
children: [
|
|
10328
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Card.Header, { children: [
|
|
10329
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Brand` }),
|
|
10330
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Card.Description, { children: isEdit ? `Update the details for this brand` : `Create a new brand and add it to your list` })
|
|
10331
|
+
] }),
|
|
10332
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
10333
|
+
"form",
|
|
10334
|
+
{
|
|
10335
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
10336
|
+
children: [
|
|
10337
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
|
|
10338
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10339
|
+
Fields_default.Input,
|
|
10340
|
+
{
|
|
10341
|
+
label: "Name",
|
|
10342
|
+
form: methods,
|
|
10343
|
+
name: "name",
|
|
10344
|
+
type: "text",
|
|
10345
|
+
placeholder: "Enter Brand Name",
|
|
10346
|
+
required: true
|
|
10347
|
+
}
|
|
10348
|
+
),
|
|
10349
|
+
!branchId && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10350
|
+
Feilds_default.Branches,
|
|
10351
|
+
{
|
|
10352
|
+
label: "Branch",
|
|
10353
|
+
form: methods,
|
|
10354
|
+
name: "branch",
|
|
10355
|
+
placeholder: "Select Branch",
|
|
10356
|
+
api: "/branches/get?noStore=true"
|
|
10357
|
+
}
|
|
10358
|
+
)
|
|
10359
|
+
] }),
|
|
10360
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
|
|
10361
|
+
Button,
|
|
10362
|
+
{
|
|
10363
|
+
isLoading,
|
|
10364
|
+
disabled: isLoading,
|
|
10365
|
+
type: "submit",
|
|
10366
|
+
className: "min-w-[100px]",
|
|
10367
|
+
variant: !isEdit ? "primary" : "warning",
|
|
10368
|
+
children: isEdit ? "Update" : "Add"
|
|
10369
|
+
}
|
|
10370
|
+
) })
|
|
10371
|
+
]
|
|
10372
|
+
}
|
|
10373
|
+
) })
|
|
10374
|
+
]
|
|
10375
|
+
}
|
|
10376
|
+
);
|
|
10377
|
+
}
|
|
10378
|
+
var BrandForm_default = BrandForm;
|
|
10379
|
+
|
|
10380
|
+
// src/components/brands/Feilds/Brand.tsx
|
|
10381
|
+
var import_react_router_dom19 = require("react-router-dom");
|
|
10382
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
10383
|
+
function Brand({
|
|
10384
|
+
name,
|
|
10385
|
+
label,
|
|
10386
|
+
placeholder,
|
|
10387
|
+
api,
|
|
10388
|
+
form,
|
|
10389
|
+
filter,
|
|
10390
|
+
v = 1,
|
|
10391
|
+
required,
|
|
10392
|
+
disabled
|
|
10393
|
+
}) {
|
|
10394
|
+
const { branchId } = (0, import_react_router_dom19.useParams)();
|
|
10395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
10396
|
+
Fields_default.SearchApi,
|
|
10397
|
+
{
|
|
10398
|
+
name,
|
|
10399
|
+
form,
|
|
10400
|
+
label,
|
|
10401
|
+
placeholder: placeholder || `Select ${name}`,
|
|
10402
|
+
api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
|
|
10403
|
+
queryKey: "search",
|
|
10404
|
+
filter,
|
|
10405
|
+
v,
|
|
10406
|
+
labelKey: "name",
|
|
10407
|
+
valueKey: "_id",
|
|
10408
|
+
required,
|
|
10409
|
+
disabled
|
|
10410
|
+
}
|
|
10411
|
+
) });
|
|
10412
|
+
}
|
|
10413
|
+
var Brand_default = Brand;
|
|
10414
|
+
|
|
10415
|
+
// src/components/brands/Feilds/index.tsx
|
|
10416
|
+
var BrandField = {
|
|
10417
|
+
Brand: Brand_default
|
|
10418
|
+
};
|
|
10419
|
+
var Feilds_default3 = BrandField;
|
|
10420
|
+
|
|
10421
|
+
// src/components/categories/Categories.tsx
|
|
10422
|
+
var import_react_router_dom20 = require("react-router-dom");
|
|
10423
|
+
var import_lucide_react27 = require("lucide-react");
|
|
10424
|
+
var import_react47 = require("react");
|
|
10425
|
+
var import_antd20 = require("antd");
|
|
10426
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
10427
|
+
function Categories({ v, url }) {
|
|
10428
|
+
const { branchId } = (0, import_react_router_dom20.useParams)();
|
|
10429
|
+
const [deleteCategory, setDeleteCategory] = (0, import_react47.useState)(null);
|
|
10430
|
+
const { isLoading, remove } = useApis_default();
|
|
10431
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10432
|
+
url: url || `/categories/get${branchId ? `?branch=${branchId}` : ""}`,
|
|
10433
|
+
v,
|
|
10434
|
+
dateFilter: false
|
|
10435
|
+
});
|
|
10436
|
+
const { Modal: Modal2 } = useModal();
|
|
10437
|
+
const navigate = (0, import_react_router_dom20.useNavigate)();
|
|
10438
|
+
const items = (data2) => [
|
|
10439
|
+
{
|
|
10440
|
+
label: `Edit Category`,
|
|
10441
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react27.FilePenLine, { size: 16 }),
|
|
10442
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10443
|
+
},
|
|
10444
|
+
{
|
|
10445
|
+
label: `Delete Category`,
|
|
10446
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react27.Trash2, { className: "text-red-500", size: 16 }),
|
|
10447
|
+
onClick: () => setDeleteCategory(data2)
|
|
10448
|
+
}
|
|
10449
|
+
].filter(Boolean);
|
|
10450
|
+
const columns = [
|
|
10451
|
+
{
|
|
10452
|
+
accessorKey: "name",
|
|
10453
|
+
header: "Name",
|
|
10454
|
+
cell: ({ row }) => {
|
|
10455
|
+
const category = row.original;
|
|
10456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { children: category?.name });
|
|
10457
|
+
}
|
|
10458
|
+
},
|
|
10459
|
+
{
|
|
10460
|
+
accessorKey: "actions",
|
|
10461
|
+
header: "Actions",
|
|
10462
|
+
cell: ({ row }) => {
|
|
10463
|
+
const data2 = row.original;
|
|
10464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10465
|
+
Dropdown,
|
|
10466
|
+
{
|
|
10467
|
+
className: "cursor-pointer w-[150px]",
|
|
10468
|
+
items: items(data2),
|
|
10469
|
+
triggerMode: "hover",
|
|
10470
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react27.EllipsisVertical, {})
|
|
10471
|
+
}
|
|
10472
|
+
);
|
|
10473
|
+
}
|
|
10474
|
+
}
|
|
10475
|
+
].filter(Boolean);
|
|
10476
|
+
const categories = data?.data || [];
|
|
10477
|
+
const onDelete = async (id) => {
|
|
10478
|
+
try {
|
|
10479
|
+
await remove({ url: `/categories/delete/${id}` });
|
|
10480
|
+
import_antd20.message.success("Category deleted successfully");
|
|
10481
|
+
reload();
|
|
10482
|
+
setDeleteCategory(null);
|
|
10483
|
+
} catch (error) {
|
|
10484
|
+
import_antd20.message.error(error.message || "Something went wrong");
|
|
10485
|
+
return error;
|
|
10486
|
+
}
|
|
10487
|
+
};
|
|
10488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
|
|
10489
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Modal2, {}),
|
|
10490
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10491
|
+
ConfirmModal,
|
|
10492
|
+
{
|
|
10493
|
+
isOpen: !!deleteCategory,
|
|
10494
|
+
isLoading,
|
|
10495
|
+
onClose: () => setDeleteCategory(null),
|
|
10496
|
+
title: `Delete Category`,
|
|
10497
|
+
description: `Are you sure you want to delete "${deleteCategory?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
10498
|
+
confirmationWord: "delete",
|
|
10499
|
+
onSubmit: () => onDelete(deleteCategory?._id),
|
|
10500
|
+
children: null
|
|
10501
|
+
}
|
|
10502
|
+
),
|
|
10503
|
+
/* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
10504
|
+
TransactionViewComponent,
|
|
10505
|
+
{
|
|
10506
|
+
columns,
|
|
10507
|
+
data: categories,
|
|
10508
|
+
title: `Categories`,
|
|
10509
|
+
description: `Add or update categories`,
|
|
10510
|
+
index: true,
|
|
10511
|
+
createTitle: `Add Category`,
|
|
10512
|
+
onCreate: () => {
|
|
10513
|
+
navigate("create");
|
|
10514
|
+
}
|
|
10515
|
+
}
|
|
10516
|
+
)
|
|
10517
|
+
] });
|
|
10518
|
+
}
|
|
10519
|
+
var Categories_default = Categories;
|
|
10520
|
+
|
|
10521
|
+
// src/components/categories/schema.ts
|
|
10522
|
+
var import_zod14 = require("zod");
|
|
10523
|
+
var createCategorySchema = import_zod14.z.object({
|
|
10524
|
+
name: import_zod14.z.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
10525
|
+
branch: import_zod14.z.string().optional()
|
|
10526
|
+
});
|
|
10527
|
+
|
|
10528
|
+
// src/components/categories/CategoryForm.tsx
|
|
10529
|
+
var import_react_hook_form17 = require("react-hook-form");
|
|
10530
|
+
var import_zod15 = require("@hookform/resolvers/zod");
|
|
10531
|
+
var import_antd21 = require("antd");
|
|
10532
|
+
var import_react48 = require("react");
|
|
10533
|
+
var import_react_router_dom21 = require("react-router-dom");
|
|
10534
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
10535
|
+
function CategoryForm() {
|
|
10536
|
+
const { branchId } = (0, import_react_router_dom21.useParams)();
|
|
10537
|
+
const { getQuery, navigate } = useApp_default();
|
|
10538
|
+
const id = getQuery("id");
|
|
10539
|
+
const isEdit = !!id;
|
|
10540
|
+
const { post, put, isLoading } = useApis_default();
|
|
10541
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10542
|
+
const methods = (0, import_react_hook_form17.useForm)({
|
|
10543
|
+
resolver: (0, import_zod15.zodResolver)(createCategorySchema),
|
|
10544
|
+
defaultValues: {
|
|
10545
|
+
name: ""
|
|
10546
|
+
},
|
|
10547
|
+
shouldUnregister: false
|
|
10548
|
+
});
|
|
10549
|
+
const { handleSubmit } = methods;
|
|
10550
|
+
const onSubmit = async (data) => {
|
|
10551
|
+
try {
|
|
10552
|
+
if (isEdit) {
|
|
10553
|
+
await put({
|
|
10554
|
+
url: `/categories/update/${id}`,
|
|
10555
|
+
body: {
|
|
10556
|
+
...data,
|
|
10557
|
+
branch: branchId ? branchId : data.branch
|
|
10558
|
+
}
|
|
10559
|
+
});
|
|
10560
|
+
} else {
|
|
10561
|
+
await post({
|
|
10562
|
+
url: "/categories/create",
|
|
10563
|
+
body: {
|
|
10564
|
+
...data,
|
|
10565
|
+
branch: branchId ? branchId : data.branch
|
|
10566
|
+
}
|
|
10567
|
+
});
|
|
10568
|
+
}
|
|
10569
|
+
import_antd21.message.success(`Category ${isEdit ? "updated" : "created"} successfully`);
|
|
10570
|
+
navigate(-1);
|
|
10571
|
+
} catch (error) {
|
|
10572
|
+
import_antd21.message.error(error?.message || "Something went wrong");
|
|
10573
|
+
}
|
|
10574
|
+
};
|
|
10575
|
+
const fetches = async () => {
|
|
10576
|
+
try {
|
|
10577
|
+
const res = await get({
|
|
10578
|
+
url: `/categories/get?id=${id}${branchId ? `&branch=${branchId}` : ""}`
|
|
10579
|
+
});
|
|
10580
|
+
const data = res.data;
|
|
10581
|
+
methods.reset(data);
|
|
10582
|
+
} catch (error) {
|
|
10583
|
+
import_antd21.message.error(error?.message || "Something went wrong");
|
|
10584
|
+
}
|
|
10585
|
+
};
|
|
10586
|
+
(0, import_react48.useEffect)(() => {
|
|
10587
|
+
if (isEdit) {
|
|
10588
|
+
fetches();
|
|
10589
|
+
}
|
|
10590
|
+
}, [id]);
|
|
10591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
10592
|
+
Card,
|
|
10593
|
+
{
|
|
10594
|
+
className: "max-w-4xl mx-auto mt-10 relative",
|
|
10595
|
+
isLoading: isLoadingGet,
|
|
10596
|
+
loadingText: "Processing...",
|
|
10597
|
+
children: [
|
|
10598
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Card.Header, { children: [
|
|
10599
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Category` }),
|
|
10600
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Card.Description, { children: isEdit ? `Update the details for this category` : `Create a new category and add it to your list` })
|
|
10601
|
+
] }),
|
|
10602
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
|
|
10603
|
+
"form",
|
|
10604
|
+
{
|
|
10605
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
10606
|
+
children: [
|
|
10607
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
|
|
10608
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10609
|
+
Fields_default.Input,
|
|
10610
|
+
{
|
|
10611
|
+
label: "Name",
|
|
10612
|
+
form: methods,
|
|
10613
|
+
name: "name",
|
|
10614
|
+
type: "text",
|
|
10615
|
+
placeholder: "Enter Category Name",
|
|
10616
|
+
required: true
|
|
10617
|
+
}
|
|
10618
|
+
),
|
|
10619
|
+
!branchId && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10620
|
+
Feilds_default.Branches,
|
|
10621
|
+
{
|
|
10622
|
+
label: "Branch",
|
|
10623
|
+
form: methods,
|
|
10624
|
+
name: "branch",
|
|
10625
|
+
placeholder: "Select Branch",
|
|
10626
|
+
api: "/branches/get?noStore=true"
|
|
10627
|
+
}
|
|
10628
|
+
)
|
|
10629
|
+
] }),
|
|
10630
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
10631
|
+
Button,
|
|
10632
|
+
{
|
|
10633
|
+
isLoading,
|
|
10634
|
+
disabled: isLoading,
|
|
10635
|
+
type: "submit",
|
|
10636
|
+
className: "min-w-[100px]",
|
|
10637
|
+
variant: !isEdit ? "primary" : "warning",
|
|
10638
|
+
children: isEdit ? "Update" : "Add"
|
|
10639
|
+
}
|
|
10640
|
+
) })
|
|
10641
|
+
]
|
|
10642
|
+
}
|
|
10643
|
+
) })
|
|
10644
|
+
]
|
|
10645
|
+
}
|
|
10646
|
+
);
|
|
10647
|
+
}
|
|
10648
|
+
var CategoryForm_default = CategoryForm;
|
|
10649
|
+
|
|
10650
|
+
// src/components/categories/Feilds/Category.tsx
|
|
10651
|
+
var import_react_router_dom22 = require("react-router-dom");
|
|
10652
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
10653
|
+
function Category({
|
|
10654
|
+
name,
|
|
10655
|
+
label,
|
|
10656
|
+
placeholder,
|
|
10657
|
+
api,
|
|
10658
|
+
form,
|
|
10659
|
+
filter,
|
|
10660
|
+
v = 1,
|
|
10661
|
+
required,
|
|
10662
|
+
disabled
|
|
10663
|
+
}) {
|
|
10664
|
+
const { branchId } = (0, import_react_router_dom22.useParams)();
|
|
10665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
10666
|
+
Fields_default.SearchApi,
|
|
10667
|
+
{
|
|
10668
|
+
name,
|
|
10669
|
+
form,
|
|
10670
|
+
label,
|
|
10671
|
+
placeholder: placeholder || `Select ${name}`,
|
|
10672
|
+
api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
|
|
10673
|
+
queryKey: "search",
|
|
10674
|
+
filter,
|
|
10675
|
+
v,
|
|
10676
|
+
labelKey: "name",
|
|
10677
|
+
valueKey: "_id",
|
|
10678
|
+
required,
|
|
10679
|
+
disabled
|
|
10680
|
+
}
|
|
10681
|
+
) });
|
|
10682
|
+
}
|
|
10683
|
+
var Category_default = Category;
|
|
10684
|
+
|
|
10685
|
+
// src/components/categories/Feilds/index.tsx
|
|
10686
|
+
var CategoryField = {
|
|
10687
|
+
Category: Category_default
|
|
10688
|
+
};
|
|
10689
|
+
var Feilds_default4 = CategoryField;
|
|
10690
|
+
|
|
10691
|
+
// src/components/products/Products.tsx
|
|
10692
|
+
var import_react_router_dom23 = require("react-router-dom");
|
|
10693
|
+
var import_lucide_react28 = require("lucide-react");
|
|
10694
|
+
var import_react49 = require("react");
|
|
10695
|
+
var import_antd22 = require("antd");
|
|
10696
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
10697
|
+
function Products({ v, url }) {
|
|
10698
|
+
const { branchId } = (0, import_react_router_dom23.useParams)();
|
|
10699
|
+
const [deleteProduct, setDeleteProduct] = (0, import_react49.useState)(null);
|
|
10700
|
+
const { isLoading, remove } = useApis_default();
|
|
10701
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10702
|
+
url: url || `/products/get${branchId ? `?branch=${branchId}` : ""}`,
|
|
10703
|
+
v,
|
|
10704
|
+
dateFilter: false
|
|
10705
|
+
});
|
|
10706
|
+
const { Modal: Modal2 } = useModal();
|
|
10707
|
+
const navigate = (0, import_react_router_dom23.useNavigate)();
|
|
10708
|
+
const items = (data2) => [
|
|
10709
|
+
{
|
|
10710
|
+
label: `Edit Product`,
|
|
10711
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_lucide_react28.FilePenLine, { size: 16 }),
|
|
10712
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10713
|
+
},
|
|
10714
|
+
{
|
|
10715
|
+
label: `Delete Product`,
|
|
10716
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_lucide_react28.Trash2, { className: "text-red-500", size: 16 }),
|
|
10717
|
+
onClick: () => setDeleteProduct(data2)
|
|
10718
|
+
}
|
|
10719
|
+
].filter(Boolean);
|
|
10720
|
+
const columns = [
|
|
10721
|
+
{
|
|
10722
|
+
accessorKey: "name",
|
|
10723
|
+
header: "Name",
|
|
10724
|
+
cell: ({ row }) => {
|
|
10725
|
+
const product = row.original;
|
|
10726
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: product?.name });
|
|
10727
|
+
}
|
|
10728
|
+
},
|
|
10729
|
+
{
|
|
10730
|
+
accessorKey: "category",
|
|
10731
|
+
header: "Category",
|
|
10732
|
+
cell: ({ row }) => {
|
|
10733
|
+
const product = row.original;
|
|
10734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: product?.categoryData?.name || "N/A" });
|
|
10735
|
+
}
|
|
10736
|
+
},
|
|
10737
|
+
{
|
|
10738
|
+
accessorKey: "brand",
|
|
10739
|
+
header: "Brand",
|
|
10740
|
+
cell: ({ row }) => {
|
|
10741
|
+
const product = row.original;
|
|
10742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: product?.brandData?.name || "N/A" });
|
|
10743
|
+
}
|
|
10744
|
+
},
|
|
10745
|
+
{
|
|
10746
|
+
accessorKey: "cost",
|
|
10747
|
+
header: "Cost",
|
|
10748
|
+
cell: ({ row }) => {
|
|
10749
|
+
const product = row.original;
|
|
10750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { children: [
|
|
10751
|
+
" ",
|
|
10752
|
+
product?.cost?.toLocaleString()
|
|
10753
|
+
] });
|
|
10754
|
+
}
|
|
10755
|
+
},
|
|
10756
|
+
{
|
|
10757
|
+
accessorKey: "actions",
|
|
10758
|
+
header: "Actions",
|
|
10759
|
+
cell: ({ row }) => {
|
|
10760
|
+
const data2 = row.original;
|
|
10761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
10762
|
+
Dropdown,
|
|
10763
|
+
{
|
|
10764
|
+
className: "cursor-pointer w-[150px]",
|
|
10765
|
+
items: items(data2),
|
|
10766
|
+
triggerMode: "hover",
|
|
10767
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_lucide_react28.EllipsisVertical, {})
|
|
10768
|
+
}
|
|
10769
|
+
);
|
|
10770
|
+
}
|
|
10771
|
+
}
|
|
10772
|
+
].filter(Boolean);
|
|
10773
|
+
const products = data?.data || [];
|
|
10774
|
+
const onDelete = async (id) => {
|
|
10775
|
+
try {
|
|
10776
|
+
await remove({ url: `/products/delete/${id}` });
|
|
10777
|
+
import_antd22.message.success("Product deleted successfully");
|
|
10778
|
+
reload();
|
|
10779
|
+
setDeleteProduct(null);
|
|
10780
|
+
} catch (error) {
|
|
10781
|
+
import_antd22.message.error(error.message || "Something went wrong");
|
|
10782
|
+
return error;
|
|
10783
|
+
}
|
|
10784
|
+
};
|
|
10785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
10786
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Modal2, {}),
|
|
10787
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
10788
|
+
ConfirmModal,
|
|
10789
|
+
{
|
|
10790
|
+
isOpen: !!deleteProduct,
|
|
10791
|
+
isLoading,
|
|
10792
|
+
onClose: () => setDeleteProduct(null),
|
|
10793
|
+
title: `Delete Product`,
|
|
10794
|
+
description: `Are you sure you want to delete "${deleteProduct?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
10795
|
+
confirmationWord: "delete",
|
|
10796
|
+
onSubmit: () => onDelete(deleteProduct?._id),
|
|
10797
|
+
children: null
|
|
10798
|
+
}
|
|
10799
|
+
),
|
|
10800
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
10801
|
+
TransactionViewComponent,
|
|
10802
|
+
{
|
|
10803
|
+
columns,
|
|
10804
|
+
data: products,
|
|
10805
|
+
title: `Products`,
|
|
10806
|
+
description: `Add or update products`,
|
|
10807
|
+
index: true,
|
|
10808
|
+
createTitle: `Add Product`,
|
|
10809
|
+
onCreate: () => {
|
|
10810
|
+
navigate("create");
|
|
10811
|
+
}
|
|
10812
|
+
}
|
|
10813
|
+
)
|
|
10814
|
+
] });
|
|
10815
|
+
}
|
|
10816
|
+
var Products_default = Products;
|
|
10817
|
+
|
|
10818
|
+
// src/components/products/schema.ts
|
|
10819
|
+
var import_zod16 = require("zod");
|
|
10820
|
+
var createProductSchema = import_zod16.z.object({
|
|
10821
|
+
name: import_zod16.z.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
10822
|
+
category: import_zod16.z.string().optional(),
|
|
10823
|
+
brand: import_zod16.z.string().optional(),
|
|
10824
|
+
cost: import_zod16.z.number({ message: "Cost is required" }).min(0),
|
|
10825
|
+
branch: import_zod16.z.string().optional()
|
|
10826
|
+
});
|
|
10827
|
+
|
|
10828
|
+
// src/components/products/ProductForm.tsx
|
|
10829
|
+
var import_react_hook_form18 = require("react-hook-form");
|
|
10830
|
+
var import_zod17 = require("@hookform/resolvers/zod");
|
|
10831
|
+
var import_antd23 = require("antd");
|
|
10832
|
+
var import_react50 = require("react");
|
|
10833
|
+
var import_react_router_dom24 = require("react-router-dom");
|
|
10834
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
10835
|
+
function ProductForm() {
|
|
10836
|
+
const { branchId } = (0, import_react_router_dom24.useParams)();
|
|
10837
|
+
const { getQuery, navigate } = useApp_default();
|
|
10838
|
+
const id = getQuery("id");
|
|
10839
|
+
const isEdit = !!id;
|
|
10840
|
+
const { post, put, isLoading } = useApis_default();
|
|
10841
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10842
|
+
const methods = (0, import_react_hook_form18.useForm)({
|
|
10843
|
+
resolver: (0, import_zod17.zodResolver)(createProductSchema),
|
|
10844
|
+
defaultValues: {
|
|
10845
|
+
name: "",
|
|
10846
|
+
category: void 0,
|
|
10847
|
+
brand: void 0,
|
|
10848
|
+
cost: 0
|
|
10849
|
+
},
|
|
10850
|
+
shouldUnregister: false
|
|
10851
|
+
});
|
|
10852
|
+
const { handleSubmit } = methods;
|
|
10853
|
+
const onSubmit = async (data) => {
|
|
10854
|
+
try {
|
|
10855
|
+
if (isEdit) {
|
|
10856
|
+
await put({
|
|
10857
|
+
url: `/products/update/${id}`,
|
|
10858
|
+
body: {
|
|
10859
|
+
...data,
|
|
10860
|
+
branch: branchId ? branchId : data.branch
|
|
10861
|
+
}
|
|
10862
|
+
});
|
|
10863
|
+
} else {
|
|
10864
|
+
await post({
|
|
10865
|
+
url: "/products/create",
|
|
10866
|
+
body: {
|
|
10867
|
+
...data,
|
|
10868
|
+
branch: branchId ? branchId : data.branch
|
|
10869
|
+
}
|
|
10870
|
+
});
|
|
10871
|
+
}
|
|
10872
|
+
import_antd23.message.success(`Product ${isEdit ? "updated" : "created"} successfully`);
|
|
10873
|
+
navigate(-1);
|
|
10874
|
+
} catch (error) {
|
|
10875
|
+
import_antd23.message.error(error?.message || "Something went wrong");
|
|
10876
|
+
}
|
|
10877
|
+
};
|
|
10878
|
+
const fetches = async () => {
|
|
10879
|
+
try {
|
|
10880
|
+
const res = await get({
|
|
10881
|
+
url: `/products/get?id=${id}${branchId ? `&branch=${branchId}` : ""}`
|
|
10882
|
+
});
|
|
10883
|
+
const data = res.data;
|
|
10884
|
+
methods.reset(data);
|
|
10885
|
+
} catch (error) {
|
|
10886
|
+
import_antd23.message.error(error?.message || "Something went wrong");
|
|
10887
|
+
}
|
|
10888
|
+
};
|
|
10889
|
+
(0, import_react50.useEffect)(() => {
|
|
10890
|
+
if (isEdit) {
|
|
10891
|
+
fetches();
|
|
10892
|
+
}
|
|
10893
|
+
}, [id]);
|
|
10894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
10895
|
+
Card,
|
|
10896
|
+
{
|
|
10897
|
+
className: "max-w-4xl mx-auto mt-10 relative",
|
|
10898
|
+
isLoading: isLoadingGet,
|
|
10899
|
+
loadingText: "Processing...",
|
|
10900
|
+
children: [
|
|
10901
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Card.Header, { children: [
|
|
10902
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Product` }),
|
|
10903
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Card.Description, { children: isEdit ? `Update the details for this product` : `Create a new product and add it to your list` })
|
|
10904
|
+
] }),
|
|
10905
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
10906
|
+
"form",
|
|
10907
|
+
{
|
|
10908
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
10909
|
+
children: [
|
|
10910
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
|
|
10911
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10912
|
+
Fields_default.Input,
|
|
10913
|
+
{
|
|
10914
|
+
label: "Name",
|
|
10915
|
+
form: methods,
|
|
10916
|
+
name: "name",
|
|
10917
|
+
type: "text",
|
|
10918
|
+
placeholder: "Enter Product Name",
|
|
10919
|
+
required: true
|
|
10920
|
+
}
|
|
10921
|
+
),
|
|
10922
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10923
|
+
Fields_default.Input,
|
|
10924
|
+
{
|
|
10925
|
+
label: "Cost",
|
|
10926
|
+
form: methods,
|
|
10927
|
+
name: "cost",
|
|
10928
|
+
type: "number",
|
|
10929
|
+
placeholder: "0.00",
|
|
10930
|
+
required: true
|
|
10931
|
+
}
|
|
10932
|
+
),
|
|
10933
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10934
|
+
Feilds_default4.Category,
|
|
10935
|
+
{
|
|
10936
|
+
label: "Category",
|
|
10937
|
+
form: methods,
|
|
10938
|
+
name: "category",
|
|
10939
|
+
api: "/categories/get"
|
|
10940
|
+
}
|
|
10941
|
+
),
|
|
10942
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10943
|
+
Feilds_default3.Brand,
|
|
10944
|
+
{
|
|
10945
|
+
label: "Brand",
|
|
10946
|
+
form: methods,
|
|
10947
|
+
name: "brand",
|
|
10948
|
+
api: "/brands/get"
|
|
10949
|
+
}
|
|
10950
|
+
),
|
|
10951
|
+
!branchId && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10952
|
+
Feilds_default.Branches,
|
|
10953
|
+
{
|
|
10954
|
+
label: "Branch",
|
|
10955
|
+
form: methods,
|
|
10956
|
+
name: "branch",
|
|
10957
|
+
placeholder: "Select Branch",
|
|
10958
|
+
api: "/branches/get?noStore=true"
|
|
10959
|
+
}
|
|
10960
|
+
)
|
|
10961
|
+
] }),
|
|
10962
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
10963
|
+
Button,
|
|
10964
|
+
{
|
|
10965
|
+
isLoading,
|
|
10966
|
+
disabled: isLoading,
|
|
10967
|
+
type: "submit",
|
|
10968
|
+
className: "min-w-[100px]",
|
|
10969
|
+
variant: !isEdit ? "primary" : "warning",
|
|
10970
|
+
children: isEdit ? "Update" : "Add"
|
|
10971
|
+
}
|
|
10972
|
+
) })
|
|
10973
|
+
]
|
|
10974
|
+
}
|
|
10975
|
+
) })
|
|
10976
|
+
]
|
|
10977
|
+
}
|
|
10978
|
+
);
|
|
10979
|
+
}
|
|
10980
|
+
var ProductForm_default = ProductForm;
|
|
10981
|
+
|
|
10982
|
+
// src/components/products/Feilds/Product.tsx
|
|
10983
|
+
var import_react_router_dom25 = require("react-router-dom");
|
|
10984
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
10985
|
+
function Product({
|
|
10986
|
+
name,
|
|
10987
|
+
label,
|
|
10988
|
+
placeholder,
|
|
10989
|
+
api,
|
|
10990
|
+
form,
|
|
10991
|
+
filter,
|
|
10992
|
+
v = 1,
|
|
10993
|
+
required,
|
|
10994
|
+
disabled,
|
|
10995
|
+
onChange,
|
|
10996
|
+
obj
|
|
10997
|
+
}) {
|
|
10998
|
+
const { branchId } = (0, import_react_router_dom25.useParams)();
|
|
10999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
11000
|
+
Fields_default.SearchApi,
|
|
11001
|
+
{
|
|
11002
|
+
name,
|
|
11003
|
+
form,
|
|
11004
|
+
label,
|
|
11005
|
+
onChange,
|
|
11006
|
+
placeholder: placeholder || `Select ${name}`,
|
|
11007
|
+
api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
|
|
11008
|
+
queryKey: "search",
|
|
11009
|
+
filter,
|
|
11010
|
+
v,
|
|
11011
|
+
labelKey: "name",
|
|
11012
|
+
valueKey: "_id",
|
|
11013
|
+
required,
|
|
11014
|
+
disabled,
|
|
11015
|
+
obj
|
|
11016
|
+
}
|
|
11017
|
+
) });
|
|
11018
|
+
}
|
|
11019
|
+
var Product_default = Product;
|
|
11020
|
+
|
|
11021
|
+
// src/components/products/Feilds/index.tsx
|
|
11022
|
+
var ProductField = {
|
|
11023
|
+
Product: Product_default
|
|
11024
|
+
};
|
|
11025
|
+
var Feilds_default5 = ProductField;
|
|
11026
|
+
|
|
11027
|
+
// src/components/packs/Packs.tsx
|
|
11028
|
+
var import_react_router_dom26 = require("react-router-dom");
|
|
11029
|
+
var import_lucide_react29 = require("lucide-react");
|
|
11030
|
+
var import_react51 = require("react");
|
|
11031
|
+
var import_antd24 = require("antd");
|
|
11032
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
11033
|
+
function Packs({ v, url }) {
|
|
11034
|
+
const { branchId } = (0, import_react_router_dom26.useParams)();
|
|
11035
|
+
const [deletePack, setDeletePack] = (0, import_react51.useState)(null);
|
|
11036
|
+
const { isLoading, remove } = useApis_default();
|
|
11037
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
11038
|
+
url: url || `/packs/get${branchId ? `?branch=${branchId}` : ""}`,
|
|
11039
|
+
v,
|
|
11040
|
+
dateFilter: false
|
|
11041
|
+
});
|
|
11042
|
+
const { Modal: Modal2 } = useModal();
|
|
11043
|
+
const navigate = (0, import_react_router_dom26.useNavigate)();
|
|
11044
|
+
const items = (data2) => [
|
|
11045
|
+
{
|
|
11046
|
+
label: `Edit Pack`,
|
|
11047
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_lucide_react29.FilePenLine, { size: 16 }),
|
|
11048
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
11049
|
+
},
|
|
11050
|
+
{
|
|
11051
|
+
label: `Delete Pack`,
|
|
11052
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_lucide_react29.Trash2, { className: "text-red-500", size: 16 }),
|
|
11053
|
+
onClick: () => setDeletePack(data2)
|
|
11054
|
+
}
|
|
11055
|
+
].filter(Boolean);
|
|
11056
|
+
const columns = [
|
|
11057
|
+
{
|
|
11058
|
+
accessorKey: "name",
|
|
11059
|
+
header: "Name",
|
|
11060
|
+
cell: ({ row }) => {
|
|
11061
|
+
const pack = row.original;
|
|
11062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { children: pack?.name });
|
|
11063
|
+
}
|
|
11064
|
+
},
|
|
11065
|
+
{
|
|
11066
|
+
accessorKey: "type",
|
|
11067
|
+
header: "Type",
|
|
11068
|
+
cell: ({ row }) => {
|
|
11069
|
+
const pack = row.original;
|
|
11070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "capitalize", children: pack?.type });
|
|
11071
|
+
}
|
|
11072
|
+
},
|
|
11073
|
+
{
|
|
11074
|
+
accessorKey: "products",
|
|
11075
|
+
header: "Products Count",
|
|
11076
|
+
cell: ({ row }) => {
|
|
11077
|
+
const pack = row.original;
|
|
11078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { children: [
|
|
11079
|
+
pack?.products?.length || 0,
|
|
11080
|
+
" Products"
|
|
11081
|
+
] });
|
|
11082
|
+
}
|
|
11083
|
+
},
|
|
11084
|
+
{
|
|
11085
|
+
accessorKey: "actions",
|
|
11086
|
+
header: "Actions",
|
|
11087
|
+
cell: ({ row }) => {
|
|
11088
|
+
const data2 = row.original;
|
|
11089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
11090
|
+
Dropdown,
|
|
11091
|
+
{
|
|
11092
|
+
className: "cursor-pointer w-[150px]",
|
|
11093
|
+
items: items(data2),
|
|
11094
|
+
triggerMode: "hover",
|
|
11095
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_lucide_react29.EllipsisVertical, {})
|
|
11096
|
+
}
|
|
11097
|
+
);
|
|
11098
|
+
}
|
|
11099
|
+
}
|
|
11100
|
+
].filter(Boolean);
|
|
11101
|
+
const packs = data?.data || [];
|
|
11102
|
+
const onDelete = async (id) => {
|
|
11103
|
+
try {
|
|
11104
|
+
await remove({ url: `/packs/delete/${id}` });
|
|
11105
|
+
import_antd24.message.success("Pack deleted successfully");
|
|
11106
|
+
reload();
|
|
11107
|
+
setDeletePack(null);
|
|
11108
|
+
} catch (error) {
|
|
11109
|
+
import_antd24.message.error(error.message || "Something went wrong");
|
|
11110
|
+
return error;
|
|
11111
|
+
}
|
|
11112
|
+
};
|
|
11113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
11114
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Modal2, {}),
|
|
11115
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
11116
|
+
ConfirmModal,
|
|
11117
|
+
{
|
|
11118
|
+
isOpen: !!deletePack,
|
|
11119
|
+
isLoading,
|
|
11120
|
+
onClose: () => setDeletePack(null),
|
|
11121
|
+
title: `Delete Pack`,
|
|
11122
|
+
description: `Are you sure you want to delete "${deletePack?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
11123
|
+
confirmationWord: "delete",
|
|
11124
|
+
onSubmit: () => onDelete(deletePack?._id),
|
|
11125
|
+
children: null
|
|
11126
|
+
}
|
|
11127
|
+
),
|
|
11128
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
11129
|
+
TransactionViewComponent,
|
|
11130
|
+
{
|
|
11131
|
+
columns,
|
|
11132
|
+
data: packs,
|
|
11133
|
+
title: `Packs`,
|
|
11134
|
+
description: `Add or update product packs`,
|
|
11135
|
+
index: true,
|
|
11136
|
+
createTitle: `Add Pack`,
|
|
11137
|
+
onCreate: () => {
|
|
11138
|
+
navigate("create");
|
|
11139
|
+
}
|
|
11140
|
+
}
|
|
11141
|
+
)
|
|
11142
|
+
] });
|
|
11143
|
+
}
|
|
11144
|
+
var Packs_default = Packs;
|
|
11145
|
+
|
|
11146
|
+
// src/components/packs/schema.ts
|
|
11147
|
+
var import_zod18 = require("zod");
|
|
11148
|
+
var packProductItemSchema = import_zod18.z.object({
|
|
11149
|
+
product: import_zod18.z.string({ message: "Product ID is required" }),
|
|
11150
|
+
cost: import_zod18.z.number().min(0, "Cost must be a positive number"),
|
|
11151
|
+
quantity: import_zod18.z.number().min(1, "Quantity must be at least 1"),
|
|
11152
|
+
index: import_zod18.z.number({ message: "Index is required" }),
|
|
11153
|
+
productData: import_zod18.z.any().optional()
|
|
11154
|
+
});
|
|
11155
|
+
var packTypes = import_zod18.z.enum(Enums_default.packTypes);
|
|
11156
|
+
var createPackSchema = import_zod18.z.object({
|
|
11157
|
+
type: packTypes,
|
|
11158
|
+
name: import_zod18.z.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
11159
|
+
products: import_zod18.z.array(packProductItemSchema).min(1, "At least one product is required"),
|
|
11160
|
+
branch: import_zod18.z.string().optional(),
|
|
11161
|
+
tempProduct: import_zod18.z.string().optional(),
|
|
11162
|
+
tempQty: import_zod18.z.number().optional(),
|
|
11163
|
+
tempCost: import_zod18.z.number().optional(),
|
|
11164
|
+
tempData: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.any()).optional()
|
|
11165
|
+
});
|
|
11166
|
+
|
|
11167
|
+
// src/components/packs/PackForm.tsx
|
|
11168
|
+
var import_react_hook_form19 = require("react-hook-form");
|
|
11169
|
+
var import_zod19 = require("@hookform/resolvers/zod");
|
|
11170
|
+
var import_antd25 = require("antd");
|
|
11171
|
+
var import_react52 = require("react");
|
|
11172
|
+
var import_react_router_dom27 = require("react-router-dom");
|
|
11173
|
+
var import_lucide_react30 = require("lucide-react");
|
|
11174
|
+
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
11175
|
+
function PackForm() {
|
|
11176
|
+
const { branchId } = (0, import_react_router_dom27.useParams)();
|
|
11177
|
+
const { getQuery, navigate } = useApp_default();
|
|
11178
|
+
const id = getQuery("id");
|
|
11179
|
+
const isEdit = !!id;
|
|
11180
|
+
const { post, put, isLoading } = useApis_default();
|
|
11181
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
11182
|
+
const methods = (0, import_react_hook_form19.useForm)({
|
|
11183
|
+
resolver: (0, import_zod19.zodResolver)(createPackSchema),
|
|
11184
|
+
defaultValues: {
|
|
11185
|
+
name: "",
|
|
11186
|
+
type: "boxes",
|
|
11187
|
+
products: [],
|
|
11188
|
+
tempQty: 1,
|
|
11189
|
+
tempCost: 0
|
|
11190
|
+
},
|
|
11191
|
+
shouldUnregister: false
|
|
11192
|
+
});
|
|
11193
|
+
const currentProduct = methods.watch("tempData");
|
|
11194
|
+
const { handleSubmit, control, watch, setValue, getValues } = methods;
|
|
11195
|
+
const { fields, append, remove } = (0, import_react_hook_form19.useFieldArray)({
|
|
11196
|
+
control,
|
|
11197
|
+
name: "products"
|
|
11198
|
+
});
|
|
11199
|
+
const onAddProduct = () => {
|
|
11200
|
+
const val = getValues("tempProduct");
|
|
11201
|
+
const qty = getValues("tempQty") || 1;
|
|
11202
|
+
const cost = getValues("tempCost") || 0;
|
|
11203
|
+
if (val && currentProduct) {
|
|
11204
|
+
append({
|
|
11205
|
+
product: val,
|
|
11206
|
+
cost: Number(cost),
|
|
11207
|
+
quantity: Number(qty),
|
|
11208
|
+
index: fields.length,
|
|
11209
|
+
productData: currentProduct
|
|
11210
|
+
});
|
|
11211
|
+
setValue("tempProduct", "");
|
|
11212
|
+
setValue("tempQty", 1);
|
|
11213
|
+
setValue("tempCost", 0);
|
|
11214
|
+
} else {
|
|
11215
|
+
import_antd25.message.warning("Please select a product first");
|
|
11216
|
+
}
|
|
11217
|
+
};
|
|
11218
|
+
const onSubmit = async (data) => {
|
|
11219
|
+
try {
|
|
11220
|
+
const formattedData = {
|
|
11221
|
+
...data,
|
|
11222
|
+
products: data.products.map((p, i) => ({ ...p, index: i }))
|
|
11223
|
+
};
|
|
11224
|
+
if (isEdit) {
|
|
11225
|
+
await put({
|
|
11226
|
+
url: `/packs/update/${id}`,
|
|
11227
|
+
body: formattedData
|
|
11228
|
+
});
|
|
11229
|
+
} else {
|
|
11230
|
+
await post({
|
|
11231
|
+
url: "/packs/create",
|
|
11232
|
+
body: {
|
|
11233
|
+
...formattedData,
|
|
11234
|
+
branch: branchId ? branchId : data.branch
|
|
11235
|
+
}
|
|
11236
|
+
});
|
|
11237
|
+
}
|
|
11238
|
+
import_antd25.message.success(`Pack ${isEdit ? "updated" : "created"} successfully`);
|
|
11239
|
+
navigate(-1);
|
|
11240
|
+
} catch (error) {
|
|
11241
|
+
import_antd25.message.error(error?.message || "Something went wrong");
|
|
11242
|
+
}
|
|
11243
|
+
};
|
|
11244
|
+
const fetches = async () => {
|
|
11245
|
+
try {
|
|
11246
|
+
const res = await get({
|
|
11247
|
+
url: `/packs/get?id=${id}${branchId ? `&branch=${branchId}` : ""}`
|
|
11248
|
+
});
|
|
11249
|
+
const data = res.data;
|
|
11250
|
+
data.products = data.products.map((p, index) => ({
|
|
11251
|
+
...p,
|
|
11252
|
+
tempData: p?.productData,
|
|
11253
|
+
index
|
|
11254
|
+
}));
|
|
11255
|
+
methods.reset(data);
|
|
11256
|
+
} catch (error) {
|
|
11257
|
+
import_antd25.message.error(error?.message || "Something went wrong");
|
|
11258
|
+
}
|
|
11259
|
+
};
|
|
11260
|
+
(0, import_react52.useEffect)(() => {
|
|
11261
|
+
if (isEdit) {
|
|
11262
|
+
fetches();
|
|
11263
|
+
}
|
|
11264
|
+
}, [id]);
|
|
11265
|
+
(0, import_react52.useEffect)(() => {
|
|
11266
|
+
if (currentProduct) {
|
|
11267
|
+
setValue("tempCost", currentProduct.cost || 0);
|
|
11268
|
+
}
|
|
11269
|
+
}, [currentProduct]);
|
|
11270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
11271
|
+
Card,
|
|
11272
|
+
{
|
|
11273
|
+
className: "max-w-5xl mx-auto mt-10 relative",
|
|
11274
|
+
isLoading: isLoadingGet,
|
|
11275
|
+
loadingText: "Processing...",
|
|
11276
|
+
children: [
|
|
11277
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(Card.Header, { children: [
|
|
11278
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Pack` }),
|
|
11279
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Card.Description, { children: isEdit ? `Update the details for this product pack` : `Create a new product pack and define its components` })
|
|
11280
|
+
] }),
|
|
11281
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
11282
|
+
"form",
|
|
11283
|
+
{
|
|
11284
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
11285
|
+
children: [
|
|
11286
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4 mb-8", children: [
|
|
11287
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11288
|
+
Fields_default.Input,
|
|
11289
|
+
{
|
|
11290
|
+
label: "Pack Name",
|
|
11291
|
+
form: methods,
|
|
11292
|
+
name: "name",
|
|
11293
|
+
type: "text",
|
|
11294
|
+
placeholder: "e.g. Family Box A",
|
|
11295
|
+
required: true
|
|
11296
|
+
}
|
|
11297
|
+
),
|
|
11298
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11299
|
+
Fields_default.Select,
|
|
11300
|
+
{
|
|
11301
|
+
label: "Pack Type",
|
|
11302
|
+
form: methods,
|
|
11303
|
+
name: "type",
|
|
11304
|
+
enumName: "packTypes",
|
|
11305
|
+
required: true
|
|
11306
|
+
}
|
|
11307
|
+
),
|
|
11308
|
+
!branchId && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11309
|
+
Feilds_default.Branches,
|
|
11310
|
+
{
|
|
11311
|
+
label: "Branch",
|
|
11312
|
+
form: methods,
|
|
11313
|
+
name: "branch",
|
|
11314
|
+
placeholder: "Select Branch",
|
|
11315
|
+
api: "/branches/get?noStore=true"
|
|
11316
|
+
}
|
|
11317
|
+
)
|
|
11318
|
+
] }),
|
|
11319
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "border rounded-lg p-4 bg-gray-50/50 dark:bg-gray-800/20", children: [
|
|
11320
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("h3", { className: "text-lg font-semibold mb-4", children: "Products in Pack" }),
|
|
11321
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "mb-6 bg-white dark:bg-gray-900 p-4 rounded-lg border shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "grid grid-cols-12 gap-3 items-end", children: [
|
|
11322
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-12 sm:col-span-5", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11323
|
+
Feilds_default5.Product,
|
|
11324
|
+
{
|
|
11325
|
+
label: "Find Product",
|
|
11326
|
+
form: methods,
|
|
11327
|
+
name: "tempProduct",
|
|
11328
|
+
api: "/products/get",
|
|
11329
|
+
obj: "tempData"
|
|
11330
|
+
}
|
|
11331
|
+
) }),
|
|
11332
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-4 sm:col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11333
|
+
Fields_default.Input,
|
|
11334
|
+
{
|
|
11335
|
+
label: "Qty",
|
|
11336
|
+
form: methods,
|
|
11337
|
+
name: "tempQty",
|
|
11338
|
+
type: "number",
|
|
11339
|
+
placeholder: "1"
|
|
11340
|
+
}
|
|
11341
|
+
) }),
|
|
11342
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-5 sm:col-span-3", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11343
|
+
Fields_default.Input,
|
|
11344
|
+
{
|
|
11345
|
+
label: "Cost",
|
|
11346
|
+
form: methods,
|
|
11347
|
+
name: "tempCost",
|
|
11348
|
+
type: "number",
|
|
11349
|
+
placeholder: "0.00"
|
|
11350
|
+
}
|
|
11351
|
+
) }),
|
|
11352
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-3 sm:col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11353
|
+
Button,
|
|
11354
|
+
{
|
|
11355
|
+
type: "button",
|
|
11356
|
+
onClick: onAddProduct,
|
|
11357
|
+
className: "w-full h-[40px]",
|
|
11358
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_lucide_react30.Plus, { size: 16 }),
|
|
11359
|
+
children: "Add"
|
|
11360
|
+
}
|
|
11361
|
+
) })
|
|
11362
|
+
] }) }),
|
|
11363
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("table", { className: "w-full text-left border-collapse", children: [
|
|
11364
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("thead", { className: "bg-gray-100 dark:bg-gray-800/50", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("tr", { children: [
|
|
11365
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500", children: "Product" }),
|
|
11366
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-24", children: "Qty" }),
|
|
11367
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-32", children: "Cost" }),
|
|
11368
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-32", children: "Line Total" }),
|
|
11369
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-16 text-center", children: "Action" })
|
|
11370
|
+
] }) }),
|
|
11371
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("tbody", { className: "divide-y divide-gray-100 dark:divide-gray-800 bg-white dark:bg-gray-900", children: [
|
|
11372
|
+
fields.map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
11373
|
+
"tr",
|
|
11374
|
+
{
|
|
11375
|
+
className: "hover:bg-gray-50/50 dark:hover:bg-gray-800/50 transition-colors",
|
|
11376
|
+
children: [
|
|
11377
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("td", { className: "px-3 py-2", children: [
|
|
11378
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: field.productData?.name || "Product" }),
|
|
11379
|
+
field.productData?.sku && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("p", { className: "text-[10px] text-gray-500", children: [
|
|
11380
|
+
"SKU: ",
|
|
11381
|
+
field.productData?.sku
|
|
11382
|
+
] })
|
|
11383
|
+
] }),
|
|
11384
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11385
|
+
Fields_default.Input,
|
|
11386
|
+
{
|
|
11387
|
+
form: methods,
|
|
11388
|
+
name: `products.${index}.quantity`,
|
|
11389
|
+
type: "number",
|
|
11390
|
+
placeholder: "1",
|
|
11391
|
+
required: true,
|
|
11392
|
+
className: "h-8 py-1!"
|
|
11393
|
+
}
|
|
11394
|
+
) }),
|
|
11395
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11396
|
+
Fields_default.Input,
|
|
11397
|
+
{
|
|
11398
|
+
form: methods,
|
|
11399
|
+
name: `products.${index}.cost`,
|
|
11400
|
+
type: "number",
|
|
11401
|
+
placeholder: "0.00",
|
|
11402
|
+
required: true,
|
|
11403
|
+
className: "h-8 py-1!"
|
|
11404
|
+
}
|
|
11405
|
+
) }),
|
|
11406
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "text-sm font-semibold", children: ((Number(watch(`products.${index}.quantity`)) || 0) * (Number(watch(`products.${index}.cost`)) || 0)).toLocaleString() }) }),
|
|
11407
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11408
|
+
Button,
|
|
11409
|
+
{
|
|
11410
|
+
type: "button",
|
|
11411
|
+
variant: "ghost",
|
|
11412
|
+
size: "sm",
|
|
11413
|
+
className: "text-red-500 hover:text-red-700 hover:bg-red-50 p-1 h-8 w-8",
|
|
11414
|
+
onClick: () => remove(index),
|
|
11415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_lucide_react30.Trash2, { size: 16 })
|
|
11416
|
+
}
|
|
11417
|
+
) })
|
|
11418
|
+
]
|
|
11419
|
+
},
|
|
11420
|
+
field.id
|
|
11421
|
+
)),
|
|
11422
|
+
fields.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { colSpan: 5, className: "text-center py-10", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-sm text-gray-500", children: "No products added yet. Use the search above to add products." }) }) })
|
|
11423
|
+
] })
|
|
11424
|
+
] }) }),
|
|
11425
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "mt-6 pt-6 border-t grid grid-cols-1 sm:grid-cols-3 gap-3", children: [
|
|
11426
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
|
|
11427
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Lines" }),
|
|
11428
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-lg font-bold text-blue-600", children: watch("products")?.length || 0 })
|
|
11429
|
+
] }),
|
|
11430
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
|
|
11431
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Quantity" }),
|
|
11432
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-lg font-bold text-indigo-600", children: watch("products")?.reduce(
|
|
11433
|
+
(acc, curr) => acc + (Number(curr.quantity) || 0),
|
|
11434
|
+
0
|
|
11435
|
+
) })
|
|
11436
|
+
] }),
|
|
11437
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
|
|
11438
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Cost" }),
|
|
11439
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("p", { className: "text-lg font-bold text-emerald-600", children: [
|
|
11440
|
+
watch("products")?.reduce(
|
|
11441
|
+
(acc, curr) => acc + (Number(curr.quantity) || 0) * (Number(curr.cost) || 0),
|
|
11442
|
+
0
|
|
11443
|
+
).toLocaleString(),
|
|
11444
|
+
" ",
|
|
11445
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "text-[10px] font-normal text-gray-400", children: "USD" })
|
|
11446
|
+
] })
|
|
11447
|
+
] })
|
|
11448
|
+
] })
|
|
11449
|
+
] }),
|
|
11450
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("footer", { className: "flex justify-end mt-8", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
11451
|
+
Button,
|
|
11452
|
+
{
|
|
11453
|
+
isLoading,
|
|
11454
|
+
disabled: isLoading,
|
|
11455
|
+
type: "submit",
|
|
11456
|
+
className: "min-w-[120px]",
|
|
11457
|
+
variant: !isEdit ? "primary" : "warning",
|
|
11458
|
+
children: isEdit ? "Update Pack" : "Create Pack"
|
|
11459
|
+
}
|
|
11460
|
+
) })
|
|
11461
|
+
]
|
|
11462
|
+
}
|
|
11463
|
+
) })
|
|
11464
|
+
]
|
|
11465
|
+
}
|
|
11466
|
+
);
|
|
11467
|
+
}
|
|
11468
|
+
var PackForm_default = PackForm;
|
|
11469
|
+
|
|
11470
|
+
// src/components/packs/Feilds/Pack.tsx
|
|
11471
|
+
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
11472
|
+
function Pack({
|
|
11473
|
+
name,
|
|
11474
|
+
label,
|
|
11475
|
+
placeholder = "Select Pack",
|
|
11476
|
+
api,
|
|
11477
|
+
form,
|
|
11478
|
+
filter,
|
|
11479
|
+
v,
|
|
11480
|
+
required,
|
|
11481
|
+
disabled
|
|
11482
|
+
}) {
|
|
11483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
|
|
11484
|
+
Fields_default.SearchApi,
|
|
11485
|
+
{
|
|
11486
|
+
label,
|
|
11487
|
+
form,
|
|
11488
|
+
name,
|
|
11489
|
+
api,
|
|
11490
|
+
placeholder,
|
|
11491
|
+
queryKey: "name",
|
|
11492
|
+
labelKey: "name",
|
|
11493
|
+
valueKey: "_id",
|
|
11494
|
+
filter,
|
|
11495
|
+
v,
|
|
11496
|
+
required,
|
|
11497
|
+
disabled
|
|
11498
|
+
}
|
|
11499
|
+
);
|
|
11500
|
+
}
|
|
11501
|
+
var Pack_default = { Pack };
|
|
11502
|
+
|
|
10132
11503
|
// src/components/ErrorPage/ErrorPage.tsx
|
|
10133
|
-
var
|
|
11504
|
+
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
10134
11505
|
var ErrorPageBase = ({
|
|
10135
11506
|
title,
|
|
10136
|
-
message:
|
|
11507
|
+
message: message24,
|
|
10137
11508
|
statusCode,
|
|
10138
11509
|
action,
|
|
10139
11510
|
className = ""
|
|
10140
11511
|
}) => {
|
|
10141
|
-
return /* @__PURE__ */ (0,
|
|
11512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
10142
11513
|
"div",
|
|
10143
11514
|
{
|
|
10144
11515
|
className: `flex-1 m-auto h-full w-full min-h-[50vh] flex flex-col items-center justify-center p-6 text-zinc-900 dark:text-zinc-100 ${className}`,
|
|
10145
|
-
children: /* @__PURE__ */ (0,
|
|
10146
|
-
statusCode && /* @__PURE__ */ (0,
|
|
10147
|
-
/* @__PURE__ */ (0,
|
|
10148
|
-
statusCode && /* @__PURE__ */ (0,
|
|
11516
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "relative flex flex-col items-center justify-center w-full max-w-2xl text-center", children: [
|
|
11517
|
+
statusCode && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "absolute inset-0 flex items-center justify-center z-0 select-none pointer-events-none opacity-[0.03] dark:opacity-5", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "text-[12rem] sm:text-[16rem] md:text-[20rem] font-bold leading-none tracking-tighter", children: statusCode }) }),
|
|
11518
|
+
/* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "relative z-10 space-y-6", children: [
|
|
11519
|
+
statusCode && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("h2", { className: "text-xl md:text-2xl font-semibold text-zinc-500 dark:text-zinc-400", children: [
|
|
10149
11520
|
"Error ",
|
|
10150
11521
|
statusCode
|
|
10151
11522
|
] }),
|
|
10152
|
-
title && /* @__PURE__ */ (0,
|
|
10153
|
-
|
|
10154
|
-
action && /* @__PURE__ */ (0,
|
|
11523
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
|
|
11524
|
+
message24 && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { className: "text-lg md:text-xl text-zinc-600 dark:text-zinc-400 max-w-md mx-auto", children: message24 }),
|
|
11525
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "pt-8", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
10155
11526
|
"button",
|
|
10156
11527
|
{
|
|
10157
11528
|
onClick: action.onClick,
|
|
@@ -10167,9 +11538,9 @@ var ErrorPageBase = ({
|
|
|
10167
11538
|
};
|
|
10168
11539
|
|
|
10169
11540
|
// src/components/ErrorPage/ErrorPage.500.tsx
|
|
10170
|
-
var
|
|
11541
|
+
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
10171
11542
|
var ErrorPage500 = (props) => {
|
|
10172
|
-
return /* @__PURE__ */ (0,
|
|
11543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
10173
11544
|
ErrorPageBase,
|
|
10174
11545
|
{
|
|
10175
11546
|
statusCode: 500,
|
|
@@ -10182,9 +11553,9 @@ var ErrorPage500 = (props) => {
|
|
|
10182
11553
|
};
|
|
10183
11554
|
|
|
10184
11555
|
// src/components/ErrorPage/ErrorPage.404.tsx
|
|
10185
|
-
var
|
|
11556
|
+
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
10186
11557
|
var ErrorPage404 = (props) => {
|
|
10187
|
-
return /* @__PURE__ */ (0,
|
|
11558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
|
|
10188
11559
|
ErrorPageBase,
|
|
10189
11560
|
{
|
|
10190
11561
|
statusCode: 404,
|
|
@@ -10197,9 +11568,9 @@ var ErrorPage404 = (props) => {
|
|
|
10197
11568
|
};
|
|
10198
11569
|
|
|
10199
11570
|
// src/components/ErrorPage/ErrorPage.401.tsx
|
|
10200
|
-
var
|
|
11571
|
+
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
10201
11572
|
var ErrorPage401 = (props) => {
|
|
10202
|
-
return /* @__PURE__ */ (0,
|
|
11573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
10203
11574
|
ErrorPageBase,
|
|
10204
11575
|
{
|
|
10205
11576
|
statusCode: 401,
|
|
@@ -10212,9 +11583,9 @@ var ErrorPage401 = (props) => {
|
|
|
10212
11583
|
};
|
|
10213
11584
|
|
|
10214
11585
|
// src/components/ErrorPage/ErrorPage.400.tsx
|
|
10215
|
-
var
|
|
11586
|
+
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
10216
11587
|
var ErrorPage400 = (props) => {
|
|
10217
|
-
return /* @__PURE__ */ (0,
|
|
11588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
10218
11589
|
ErrorPageBase,
|
|
10219
11590
|
{
|
|
10220
11591
|
statusCode: 400,
|
|
@@ -10240,7 +11611,10 @@ var ErrorPage = Object.assign(ErrorPageBase, {
|
|
|
10240
11611
|
Accounts,
|
|
10241
11612
|
AdminProtectedRoute,
|
|
10242
11613
|
Badge,
|
|
11614
|
+
BrandField,
|
|
11615
|
+
BrandForm,
|
|
10243
11616
|
Branding,
|
|
11617
|
+
Brands,
|
|
10244
11618
|
Breadcrumbs,
|
|
10245
11619
|
Button,
|
|
10246
11620
|
Card,
|
|
@@ -10249,7 +11623,10 @@ var ErrorPage = Object.assign(ErrorPageBase, {
|
|
|
10249
11623
|
CardFooter,
|
|
10250
11624
|
CardHeader,
|
|
10251
11625
|
CardTitle,
|
|
11626
|
+
Categories,
|
|
10252
11627
|
CategoryCard,
|
|
11628
|
+
CategoryField,
|
|
11629
|
+
CategoryForm,
|
|
10253
11630
|
ClassicSpin,
|
|
10254
11631
|
CodeBlock,
|
|
10255
11632
|
ConfirmModal,
|
|
@@ -10267,10 +11644,16 @@ var ErrorPage = Object.assign(ErrorPageBase, {
|
|
|
10267
11644
|
LoadingSpin,
|
|
10268
11645
|
Modal,
|
|
10269
11646
|
OverlaySpin,
|
|
11647
|
+
PackField,
|
|
11648
|
+
PackForm,
|
|
11649
|
+
Packs,
|
|
10270
11650
|
PageA4,
|
|
10271
11651
|
PageHeader,
|
|
10272
11652
|
PhoneInput,
|
|
10273
11653
|
PostTable,
|
|
11654
|
+
ProductField,
|
|
11655
|
+
ProductForm,
|
|
11656
|
+
Products,
|
|
10274
11657
|
ProfileCard,
|
|
10275
11658
|
ProfileDropdown,
|
|
10276
11659
|
ProfilePage,
|
|
@@ -10301,10 +11684,16 @@ var ErrorPage = Object.assign(ErrorPageBase, {
|
|
|
10301
11684
|
Wallets,
|
|
10302
11685
|
WarqadProvider,
|
|
10303
11686
|
createAccountSchema,
|
|
11687
|
+
createBrandSchema,
|
|
11688
|
+
createCategorySchema,
|
|
11689
|
+
createPackSchema,
|
|
11690
|
+
createProductSchema,
|
|
10304
11691
|
createUserSchema,
|
|
10305
11692
|
createWalletSchema,
|
|
10306
11693
|
generatePdf,
|
|
10307
11694
|
linkUserSchema,
|
|
11695
|
+
packProductItemSchema,
|
|
11696
|
+
packTypes,
|
|
10308
11697
|
resetPasswordSchema,
|
|
10309
11698
|
storage,
|
|
10310
11699
|
updateUserEmailSchema,
|