warqadui 0.0.92 → 0.0.94
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 +213 -1
- package/dist/index.d.ts +213 -1
- package/dist/index.js +1363 -55
- package/dist/index.mjs +1345 -55
- package/dist/styles.js +99 -0
- package/dist/styles.mjs +99 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -303,7 +303,8 @@ var Enums = {
|
|
|
303
303
|
verificationTypes: ["email_verification", "password_reset"],
|
|
304
304
|
auditActions: ["create", "update", "delete", "login", "logout"],
|
|
305
305
|
walletTypes: ["bank", "cash", "mobile"],
|
|
306
|
-
currencies: ["USD", "TZS", "KES", "CNY"]
|
|
306
|
+
currencies: ["USD", "TZS", "KES", "CNY"],
|
|
307
|
+
packTypes: ["pressure", "bag", "boxes"]
|
|
307
308
|
};
|
|
308
309
|
var Enums_default = Enums;
|
|
309
310
|
|
|
@@ -1330,13 +1331,13 @@ var Input = forwardRef(
|
|
|
1330
1331
|
}
|
|
1331
1332
|
}
|
|
1332
1333
|
}, [props.value, name, form]);
|
|
1333
|
-
let
|
|
1334
|
+
let message24 = error;
|
|
1334
1335
|
if (form && name) {
|
|
1335
1336
|
const {
|
|
1336
1337
|
formState: { errors }
|
|
1337
1338
|
} = form;
|
|
1338
1339
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
1339
|
-
|
|
1340
|
+
message24 = errorObj?.message;
|
|
1340
1341
|
}
|
|
1341
1342
|
const watchedValue = form?.watch(name);
|
|
1342
1343
|
useEffect7(() => {
|
|
@@ -1405,7 +1406,7 @@ var Input = forwardRef(
|
|
|
1405
1406
|
}
|
|
1406
1407
|
)
|
|
1407
1408
|
] }),
|
|
1408
|
-
|
|
1409
|
+
message24 && /* @__PURE__ */ jsx16("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
1409
1410
|
]
|
|
1410
1411
|
}
|
|
1411
1412
|
);
|
|
@@ -1730,7 +1731,7 @@ var PhoneInput = forwardRef2(
|
|
|
1730
1731
|
const [isFocused, setIsFocused] = useState12(false);
|
|
1731
1732
|
const { theme } = useWarqadConfig();
|
|
1732
1733
|
const primaryColor = theme?.primaryColor;
|
|
1733
|
-
let
|
|
1734
|
+
let message24 = error;
|
|
1734
1735
|
if (form && name) {
|
|
1735
1736
|
const {
|
|
1736
1737
|
formState: { errors }
|
|
@@ -1740,7 +1741,7 @@ var PhoneInput = forwardRef2(
|
|
|
1740
1741
|
for (const part of nameParts) {
|
|
1741
1742
|
currentError = currentError?.[part];
|
|
1742
1743
|
}
|
|
1743
|
-
|
|
1744
|
+
message24 = currentError?.message || message24;
|
|
1744
1745
|
}
|
|
1745
1746
|
const renderInput = (onChangeHandler, currentValue) => /* @__PURE__ */ jsxs15("div", { className: `space-y-2 group relative ${containerClassName}`, children: [
|
|
1746
1747
|
/* @__PURE__ */ jsxs15(
|
|
@@ -1791,7 +1792,7 @@ var PhoneInput = forwardRef2(
|
|
|
1791
1792
|
}
|
|
1792
1793
|
)
|
|
1793
1794
|
] }),
|
|
1794
|
-
|
|
1795
|
+
message24 && /* @__PURE__ */ jsx20("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
1795
1796
|
] });
|
|
1796
1797
|
if (form && name) {
|
|
1797
1798
|
return /* @__PURE__ */ jsx20(
|
|
@@ -1969,7 +1970,7 @@ var SelectRoot = ({
|
|
|
1969
1970
|
document.addEventListener("mousedown", handleClickOutside);
|
|
1970
1971
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1971
1972
|
}, [fieldInternalProps]);
|
|
1972
|
-
let
|
|
1973
|
+
let message24 = error;
|
|
1973
1974
|
if (form && name) {
|
|
1974
1975
|
const {
|
|
1975
1976
|
formState: { errors }
|
|
@@ -1979,7 +1980,7 @@ var SelectRoot = ({
|
|
|
1979
1980
|
for (const part of nameParts) {
|
|
1980
1981
|
currentError = currentError?.[part];
|
|
1981
1982
|
}
|
|
1982
|
-
|
|
1983
|
+
message24 = currentError?.message || message24;
|
|
1983
1984
|
}
|
|
1984
1985
|
const allOptions = initialOptions?.length ? initialOptions : registeredOptions;
|
|
1985
1986
|
const valueCtx = {
|
|
@@ -2040,7 +2041,7 @@ var SelectRoot = ({
|
|
|
2040
2041
|
String(opt.value) || index
|
|
2041
2042
|
)) })
|
|
2042
2043
|
] }),
|
|
2043
|
-
|
|
2044
|
+
message24 && /* @__PURE__ */ jsx21("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
2044
2045
|
]
|
|
2045
2046
|
}
|
|
2046
2047
|
) });
|
|
@@ -2278,13 +2279,13 @@ var Textarea = forwardRef4(
|
|
|
2278
2279
|
const [isFocused, setIsFocused] = useState14(false);
|
|
2279
2280
|
const { theme } = useWarqadConfig();
|
|
2280
2281
|
const primaryColor = theme?.primaryColor;
|
|
2281
|
-
let
|
|
2282
|
+
let message24 = error;
|
|
2282
2283
|
if (form && name) {
|
|
2283
2284
|
const {
|
|
2284
2285
|
formState: { errors }
|
|
2285
2286
|
} = form;
|
|
2286
2287
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
2287
|
-
|
|
2288
|
+
message24 = errorObj?.message;
|
|
2288
2289
|
}
|
|
2289
2290
|
const renderInput = (inputProps, ref2) => /* @__PURE__ */ jsxs17("div", { className: `space-y-2 group w-full! relative ${containerClassName}`, children: [
|
|
2290
2291
|
/* @__PURE__ */ jsxs17(
|
|
@@ -2322,7 +2323,7 @@ var Textarea = forwardRef4(
|
|
|
2322
2323
|
}
|
|
2323
2324
|
}
|
|
2324
2325
|
) }),
|
|
2325
|
-
|
|
2326
|
+
message24 && /* @__PURE__ */ jsx22("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
2326
2327
|
] });
|
|
2327
2328
|
useEffect9(() => {
|
|
2328
2329
|
if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
|
|
@@ -2648,7 +2649,7 @@ var SearchApiRoot = ({
|
|
|
2648
2649
|
const filteredOptions = options.filter(
|
|
2649
2650
|
(option) => !filter.includes(getOptionValue(option))
|
|
2650
2651
|
);
|
|
2651
|
-
let
|
|
2652
|
+
let message24 = error || errorMessage;
|
|
2652
2653
|
if (form && name) {
|
|
2653
2654
|
const {
|
|
2654
2655
|
formState: { errors }
|
|
@@ -2658,7 +2659,7 @@ var SearchApiRoot = ({
|
|
|
2658
2659
|
for (const part of nameParts) {
|
|
2659
2660
|
currentError = currentError?.[part];
|
|
2660
2661
|
}
|
|
2661
|
-
|
|
2662
|
+
message24 = currentError?.message || message24;
|
|
2662
2663
|
}
|
|
2663
2664
|
const valueCtx = {
|
|
2664
2665
|
isOpen,
|
|
@@ -2692,7 +2693,7 @@ var SearchApiRoot = ({
|
|
|
2692
2693
|
form,
|
|
2693
2694
|
name,
|
|
2694
2695
|
obj,
|
|
2695
|
-
error:
|
|
2696
|
+
error: message24,
|
|
2696
2697
|
onSelect,
|
|
2697
2698
|
onClear
|
|
2698
2699
|
};
|
|
@@ -3061,19 +3062,19 @@ var DateInput = forwardRef6(
|
|
|
3061
3062
|
const { theme } = useWarqadConfig();
|
|
3062
3063
|
const primaryColor = theme?.primaryColor;
|
|
3063
3064
|
const [isFocused, setIsFocused] = useState16(false);
|
|
3064
|
-
let
|
|
3065
|
+
let message24 = error;
|
|
3065
3066
|
if (form && name) {
|
|
3066
3067
|
const {
|
|
3067
3068
|
formState: { errors }
|
|
3068
3069
|
} = form;
|
|
3069
3070
|
const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
|
|
3070
|
-
|
|
3071
|
+
message24 = errorObj?.message;
|
|
3071
3072
|
}
|
|
3072
3073
|
const inputStyles = `w-full px-2.5 py-1 rounded-md border! shadow-none transition-all! duration-200! outline-none!
|
|
3073
3074
|
bg-white! dark:bg-zinc-900!
|
|
3074
3075
|
text-gray-900! dark:text-zinc-100!
|
|
3075
3076
|
hover:bg-white! dark:hover:bg-zinc-900!
|
|
3076
|
-
${
|
|
3077
|
+
${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"}
|
|
3077
3078
|
[&.ant-picker-focused]:bg-white dark:[&.ant-picker-focused]:bg-zinc-900
|
|
3078
3079
|
${className}`;
|
|
3079
3080
|
const renderDatePicker = (val, changeHandler, blurHandler, refProps) => {
|
|
@@ -3096,8 +3097,8 @@ var DateInput = forwardRef6(
|
|
|
3096
3097
|
needConfirm: false,
|
|
3097
3098
|
style: {
|
|
3098
3099
|
height: "var(--input-height, 40px)",
|
|
3099
|
-
borderColor: isFocused && !
|
|
3100
|
-
boxShadow: isFocused && !
|
|
3100
|
+
borderColor: isFocused && !message24 ? primaryColor : void 0,
|
|
3101
|
+
boxShadow: isFocused && !message24 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
|
|
3101
3102
|
},
|
|
3102
3103
|
classNames: { popup: { root: "z-50" } },
|
|
3103
3104
|
suffixIcon: /* @__PURE__ */ jsx24(
|
|
@@ -3127,7 +3128,7 @@ var DateInput = forwardRef6(
|
|
|
3127
3128
|
{
|
|
3128
3129
|
className: "block text-xs font-medium transition-colors duration-200",
|
|
3129
3130
|
style: {
|
|
3130
|
-
color:
|
|
3131
|
+
color: message24 ? "#ef4444" : isFocused ? primaryColor : void 0
|
|
3131
3132
|
},
|
|
3132
3133
|
children: [
|
|
3133
3134
|
label,
|
|
@@ -3148,7 +3149,7 @@ var DateInput = forwardRef6(
|
|
|
3148
3149
|
)
|
|
3149
3150
|
}
|
|
3150
3151
|
) : renderDatePicker(value, onChange, onBlur, ref),
|
|
3151
|
-
|
|
3152
|
+
message24 && /* @__PURE__ */ jsx24("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
|
|
3152
3153
|
] });
|
|
3153
3154
|
}
|
|
3154
3155
|
);
|
|
@@ -7473,17 +7474,17 @@ var preWarningFns = [];
|
|
|
7473
7474
|
var preMessage = (fn) => {
|
|
7474
7475
|
preWarningFns.push(fn);
|
|
7475
7476
|
};
|
|
7476
|
-
function warning(valid,
|
|
7477
|
+
function warning(valid, message24) {
|
|
7477
7478
|
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
|
|
7478
|
-
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"),
|
|
7479
|
+
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message24);
|
|
7479
7480
|
if (finalMessage) {
|
|
7480
7481
|
console.error(`Warning: ${finalMessage}`);
|
|
7481
7482
|
}
|
|
7482
7483
|
}
|
|
7483
7484
|
}
|
|
7484
|
-
function note(valid,
|
|
7485
|
+
function note(valid, message24) {
|
|
7485
7486
|
if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
|
|
7486
|
-
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"),
|
|
7487
|
+
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message24);
|
|
7487
7488
|
if (finalMessage) {
|
|
7488
7489
|
console.warn(`Note: ${finalMessage}`);
|
|
7489
7490
|
}
|
|
@@ -7492,17 +7493,17 @@ function note(valid, message16) {
|
|
|
7492
7493
|
function resetWarned() {
|
|
7493
7494
|
warned = {};
|
|
7494
7495
|
}
|
|
7495
|
-
function call(method, valid,
|
|
7496
|
-
if (!valid && !warned[
|
|
7497
|
-
method(false,
|
|
7498
|
-
warned[
|
|
7496
|
+
function call(method, valid, message24) {
|
|
7497
|
+
if (!valid && !warned[message24]) {
|
|
7498
|
+
method(false, message24);
|
|
7499
|
+
warned[message24] = true;
|
|
7499
7500
|
}
|
|
7500
7501
|
}
|
|
7501
|
-
function warningOnce(valid,
|
|
7502
|
-
call(warning, valid,
|
|
7502
|
+
function warningOnce(valid, message24) {
|
|
7503
|
+
call(warning, valid, message24);
|
|
7503
7504
|
}
|
|
7504
|
-
function noteOnce(valid,
|
|
7505
|
-
call(note, valid,
|
|
7505
|
+
function noteOnce(valid, message24) {
|
|
7506
|
+
call(note, valid, message24);
|
|
7506
7507
|
}
|
|
7507
7508
|
warningOnce.preMessage = preMessage;
|
|
7508
7509
|
warningOnce.resetWarned = resetWarned;
|
|
@@ -7513,8 +7514,8 @@ import React19, { useContext as useContext5, useEffect as useEffect17 } from "re
|
|
|
7513
7514
|
function camelCase(input) {
|
|
7514
7515
|
return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
|
|
7515
7516
|
}
|
|
7516
|
-
function warning2(valid,
|
|
7517
|
-
warningOnce(valid, `[@ant-design/icons] ${
|
|
7517
|
+
function warning2(valid, message24) {
|
|
7518
|
+
warningOnce(valid, `[@ant-design/icons] ${message24}`);
|
|
7518
7519
|
}
|
|
7519
7520
|
function isIconDefinition(target) {
|
|
7520
7521
|
return typeof target === "object" && typeof target.name === "string" && typeof target.theme === "string" && (typeof target.icon === "object" || typeof target.icon === "function");
|
|
@@ -10090,29 +10091,1300 @@ var WalletField = {
|
|
|
10090
10091
|
};
|
|
10091
10092
|
var Feilds_default2 = WalletField;
|
|
10092
10093
|
|
|
10094
|
+
// src/components/brands/Brands.tsx
|
|
10095
|
+
import { useNavigate as useNavigate11 } from "react-router-dom";
|
|
10096
|
+
import { EllipsisVertical as EllipsisVertical4, FilePenLine as FilePenLine3, Trash2 as Trash24 } from "lucide-react";
|
|
10097
|
+
import { useState as useState33 } from "react";
|
|
10098
|
+
import { message as message16 } from "antd";
|
|
10099
|
+
import { Fragment as Fragment14, jsx as jsx63, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
10100
|
+
function Brands({ v, url }) {
|
|
10101
|
+
const [deleteBrand, setDeleteBrand] = useState33(null);
|
|
10102
|
+
const { isLoading, remove } = useApis_default();
|
|
10103
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10104
|
+
url: url || `/brands/get`,
|
|
10105
|
+
v,
|
|
10106
|
+
dateFilter: false
|
|
10107
|
+
});
|
|
10108
|
+
const { Modal: Modal2 } = useModal();
|
|
10109
|
+
const navigate = useNavigate11();
|
|
10110
|
+
const items = (data2) => [
|
|
10111
|
+
{
|
|
10112
|
+
label: `Edit Brand`,
|
|
10113
|
+
icon: /* @__PURE__ */ jsx63(FilePenLine3, { size: 16 }),
|
|
10114
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10115
|
+
},
|
|
10116
|
+
{
|
|
10117
|
+
label: `Delete Brand`,
|
|
10118
|
+
icon: /* @__PURE__ */ jsx63(Trash24, { className: "text-red-500", size: 16 }),
|
|
10119
|
+
onClick: () => setDeleteBrand(data2)
|
|
10120
|
+
}
|
|
10121
|
+
].filter(Boolean);
|
|
10122
|
+
const columns = [
|
|
10123
|
+
{
|
|
10124
|
+
accessorKey: "name",
|
|
10125
|
+
header: "Name",
|
|
10126
|
+
cell: ({ row }) => {
|
|
10127
|
+
const brand = row.original;
|
|
10128
|
+
return /* @__PURE__ */ jsx63("span", { children: brand?.name });
|
|
10129
|
+
}
|
|
10130
|
+
},
|
|
10131
|
+
{
|
|
10132
|
+
accessorKey: "actions",
|
|
10133
|
+
header: "Actions",
|
|
10134
|
+
cell: ({ row }) => {
|
|
10135
|
+
const data2 = row.original;
|
|
10136
|
+
return /* @__PURE__ */ jsx63(
|
|
10137
|
+
Dropdown,
|
|
10138
|
+
{
|
|
10139
|
+
className: "cursor-pointer w-[150px]",
|
|
10140
|
+
items: items(data2),
|
|
10141
|
+
triggerMode: "hover",
|
|
10142
|
+
children: /* @__PURE__ */ jsx63(EllipsisVertical4, {})
|
|
10143
|
+
}
|
|
10144
|
+
);
|
|
10145
|
+
}
|
|
10146
|
+
}
|
|
10147
|
+
].filter(Boolean);
|
|
10148
|
+
const brands = data?.data || [];
|
|
10149
|
+
const onDelete = async (id) => {
|
|
10150
|
+
try {
|
|
10151
|
+
await remove({ url: `/brands/delete/${id}` });
|
|
10152
|
+
message16.success("Brand deleted successfully");
|
|
10153
|
+
reload();
|
|
10154
|
+
setDeleteBrand(null);
|
|
10155
|
+
} catch (error) {
|
|
10156
|
+
message16.error(error.message || "Something went wrong");
|
|
10157
|
+
return error;
|
|
10158
|
+
}
|
|
10159
|
+
};
|
|
10160
|
+
return /* @__PURE__ */ jsxs49(Fragment14, { children: [
|
|
10161
|
+
/* @__PURE__ */ jsx63(Modal2, {}),
|
|
10162
|
+
/* @__PURE__ */ jsx63(
|
|
10163
|
+
ConfirmModal,
|
|
10164
|
+
{
|
|
10165
|
+
isOpen: !!deleteBrand,
|
|
10166
|
+
isLoading,
|
|
10167
|
+
onClose: () => setDeleteBrand(null),
|
|
10168
|
+
title: `Delete Brand`,
|
|
10169
|
+
description: `Are you sure you want to delete "${deleteBrand?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
10170
|
+
confirmationWord: "delete",
|
|
10171
|
+
onSubmit: () => onDelete(deleteBrand?._id),
|
|
10172
|
+
children: null
|
|
10173
|
+
}
|
|
10174
|
+
),
|
|
10175
|
+
/* @__PURE__ */ jsx63(
|
|
10176
|
+
TransactionViewComponent,
|
|
10177
|
+
{
|
|
10178
|
+
columns,
|
|
10179
|
+
data: brands,
|
|
10180
|
+
title: `Brands`,
|
|
10181
|
+
description: `Add or update brands`,
|
|
10182
|
+
index: true,
|
|
10183
|
+
createTitle: `Add Brand`,
|
|
10184
|
+
onCreate: () => {
|
|
10185
|
+
navigate("create");
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
)
|
|
10189
|
+
] });
|
|
10190
|
+
}
|
|
10191
|
+
var Brands_default = Brands;
|
|
10192
|
+
|
|
10193
|
+
// src/components/brands/schema.ts
|
|
10194
|
+
import { z as z6 } from "zod";
|
|
10195
|
+
var createBrandSchema = z6.object({
|
|
10196
|
+
name: z6.string().min(2, { message: "Name must be at least 2 characters" })
|
|
10197
|
+
});
|
|
10198
|
+
|
|
10199
|
+
// src/components/brands/BrandForm.tsx
|
|
10200
|
+
import { useForm as useForm10 } from "react-hook-form";
|
|
10201
|
+
import { zodResolver as zodResolver9 } from "@hookform/resolvers/zod";
|
|
10202
|
+
import { message as message17 } from "antd";
|
|
10203
|
+
import { useEffect as useEffect26 } from "react";
|
|
10204
|
+
import { jsx as jsx64, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
10205
|
+
function BrandForm() {
|
|
10206
|
+
const { getQuery, navigate } = useApp_default();
|
|
10207
|
+
const id = getQuery("id");
|
|
10208
|
+
const isEdit = !!id;
|
|
10209
|
+
const { post, put, isLoading } = useApis_default();
|
|
10210
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10211
|
+
const methods = useForm10({
|
|
10212
|
+
resolver: zodResolver9(createBrandSchema),
|
|
10213
|
+
defaultValues: {
|
|
10214
|
+
name: ""
|
|
10215
|
+
},
|
|
10216
|
+
shouldUnregister: false
|
|
10217
|
+
});
|
|
10218
|
+
const { handleSubmit } = methods;
|
|
10219
|
+
const onSubmit = async (data) => {
|
|
10220
|
+
try {
|
|
10221
|
+
if (isEdit) {
|
|
10222
|
+
await put({
|
|
10223
|
+
url: `/brands/update/${id}`,
|
|
10224
|
+
body: data
|
|
10225
|
+
});
|
|
10226
|
+
} else {
|
|
10227
|
+
await post({
|
|
10228
|
+
url: "/brands/create",
|
|
10229
|
+
body: data
|
|
10230
|
+
});
|
|
10231
|
+
}
|
|
10232
|
+
message17.success(`Brand ${isEdit ? "updated" : "created"} successfully`);
|
|
10233
|
+
navigate(-1);
|
|
10234
|
+
} catch (error) {
|
|
10235
|
+
message17.error(error?.message || "Something went wrong");
|
|
10236
|
+
}
|
|
10237
|
+
};
|
|
10238
|
+
const fetches = async () => {
|
|
10239
|
+
try {
|
|
10240
|
+
const res = await get({
|
|
10241
|
+
url: `/brands/get?id=${id}`
|
|
10242
|
+
});
|
|
10243
|
+
const data = res.data;
|
|
10244
|
+
methods.reset(data);
|
|
10245
|
+
} catch (error) {
|
|
10246
|
+
message17.error(error?.message || "Something went wrong");
|
|
10247
|
+
}
|
|
10248
|
+
};
|
|
10249
|
+
useEffect26(() => {
|
|
10250
|
+
if (isEdit) {
|
|
10251
|
+
fetches();
|
|
10252
|
+
}
|
|
10253
|
+
}, [id]);
|
|
10254
|
+
return /* @__PURE__ */ jsxs50(
|
|
10255
|
+
Card,
|
|
10256
|
+
{
|
|
10257
|
+
className: "max-w-4xl mx-auto mt-10 relative",
|
|
10258
|
+
isLoading: isLoadingGet,
|
|
10259
|
+
loadingText: "Processing...",
|
|
10260
|
+
children: [
|
|
10261
|
+
/* @__PURE__ */ jsxs50(Card.Header, { children: [
|
|
10262
|
+
/* @__PURE__ */ jsx64(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Brand` }),
|
|
10263
|
+
/* @__PURE__ */ jsx64(Card.Description, { children: isEdit ? `Update the details for this brand` : `Create a new brand and add it to your list` })
|
|
10264
|
+
] }),
|
|
10265
|
+
/* @__PURE__ */ jsx64(Card.Content, { children: /* @__PURE__ */ jsxs50(
|
|
10266
|
+
"form",
|
|
10267
|
+
{
|
|
10268
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
10269
|
+
children: [
|
|
10270
|
+
/* @__PURE__ */ jsx64("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: /* @__PURE__ */ jsx64(
|
|
10271
|
+
Fields_default.Input,
|
|
10272
|
+
{
|
|
10273
|
+
label: "Name",
|
|
10274
|
+
form: methods,
|
|
10275
|
+
name: "name",
|
|
10276
|
+
type: "text",
|
|
10277
|
+
placeholder: "Enter Brand Name",
|
|
10278
|
+
required: true
|
|
10279
|
+
}
|
|
10280
|
+
) }),
|
|
10281
|
+
/* @__PURE__ */ jsx64("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ jsx64(
|
|
10282
|
+
Button,
|
|
10283
|
+
{
|
|
10284
|
+
isLoading,
|
|
10285
|
+
disabled: isLoading,
|
|
10286
|
+
type: "submit",
|
|
10287
|
+
className: "min-w-[100px]",
|
|
10288
|
+
variant: !isEdit ? "primary" : "warning",
|
|
10289
|
+
children: isEdit ? "Update" : "Add"
|
|
10290
|
+
}
|
|
10291
|
+
) })
|
|
10292
|
+
]
|
|
10293
|
+
}
|
|
10294
|
+
) })
|
|
10295
|
+
]
|
|
10296
|
+
}
|
|
10297
|
+
);
|
|
10298
|
+
}
|
|
10299
|
+
var BrandForm_default = BrandForm;
|
|
10300
|
+
|
|
10301
|
+
// src/components/brands/Feilds/Brand.tsx
|
|
10302
|
+
import { useParams as useParams10 } from "react-router-dom";
|
|
10303
|
+
import { jsx as jsx65 } from "react/jsx-runtime";
|
|
10304
|
+
function Brand({
|
|
10305
|
+
name,
|
|
10306
|
+
label,
|
|
10307
|
+
placeholder,
|
|
10308
|
+
api,
|
|
10309
|
+
form,
|
|
10310
|
+
filter,
|
|
10311
|
+
v = 1,
|
|
10312
|
+
required,
|
|
10313
|
+
disabled
|
|
10314
|
+
}) {
|
|
10315
|
+
const { branchId } = useParams10();
|
|
10316
|
+
return /* @__PURE__ */ jsx65("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx65(
|
|
10317
|
+
Fields_default.SearchApi,
|
|
10318
|
+
{
|
|
10319
|
+
name,
|
|
10320
|
+
form,
|
|
10321
|
+
label,
|
|
10322
|
+
placeholder: placeholder || `Select ${name}`,
|
|
10323
|
+
api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
|
|
10324
|
+
queryKey: "search",
|
|
10325
|
+
filter,
|
|
10326
|
+
v,
|
|
10327
|
+
labelKey: "name",
|
|
10328
|
+
valueKey: "_id",
|
|
10329
|
+
required,
|
|
10330
|
+
disabled
|
|
10331
|
+
}
|
|
10332
|
+
) });
|
|
10333
|
+
}
|
|
10334
|
+
var Brand_default = Brand;
|
|
10335
|
+
|
|
10336
|
+
// src/components/brands/Feilds/index.tsx
|
|
10337
|
+
var BrandField = {
|
|
10338
|
+
Brand: Brand_default
|
|
10339
|
+
};
|
|
10340
|
+
var Feilds_default3 = BrandField;
|
|
10341
|
+
|
|
10342
|
+
// src/components/categories/Categories.tsx
|
|
10343
|
+
import { useNavigate as useNavigate12 } from "react-router-dom";
|
|
10344
|
+
import { EllipsisVertical as EllipsisVertical5, FilePenLine as FilePenLine4, Trash2 as Trash25 } from "lucide-react";
|
|
10345
|
+
import { useState as useState34 } from "react";
|
|
10346
|
+
import { message as message18 } from "antd";
|
|
10347
|
+
import { Fragment as Fragment15, jsx as jsx66, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
10348
|
+
function Categories({ v, url }) {
|
|
10349
|
+
const [deleteCategory, setDeleteCategory] = useState34(null);
|
|
10350
|
+
const { isLoading, remove } = useApis_default();
|
|
10351
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10352
|
+
url: url || `/categories/get`,
|
|
10353
|
+
v,
|
|
10354
|
+
dateFilter: false
|
|
10355
|
+
});
|
|
10356
|
+
const { Modal: Modal2 } = useModal();
|
|
10357
|
+
const navigate = useNavigate12();
|
|
10358
|
+
const items = (data2) => [
|
|
10359
|
+
{
|
|
10360
|
+
label: `Edit Category`,
|
|
10361
|
+
icon: /* @__PURE__ */ jsx66(FilePenLine4, { size: 16 }),
|
|
10362
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10363
|
+
},
|
|
10364
|
+
{
|
|
10365
|
+
label: `Delete Category`,
|
|
10366
|
+
icon: /* @__PURE__ */ jsx66(Trash25, { className: "text-red-500", size: 16 }),
|
|
10367
|
+
onClick: () => setDeleteCategory(data2)
|
|
10368
|
+
}
|
|
10369
|
+
].filter(Boolean);
|
|
10370
|
+
const columns = [
|
|
10371
|
+
{
|
|
10372
|
+
accessorKey: "name",
|
|
10373
|
+
header: "Name",
|
|
10374
|
+
cell: ({ row }) => {
|
|
10375
|
+
const category = row.original;
|
|
10376
|
+
return /* @__PURE__ */ jsx66("span", { children: category?.name });
|
|
10377
|
+
}
|
|
10378
|
+
},
|
|
10379
|
+
{
|
|
10380
|
+
accessorKey: "actions",
|
|
10381
|
+
header: "Actions",
|
|
10382
|
+
cell: ({ row }) => {
|
|
10383
|
+
const data2 = row.original;
|
|
10384
|
+
return /* @__PURE__ */ jsx66(
|
|
10385
|
+
Dropdown,
|
|
10386
|
+
{
|
|
10387
|
+
className: "cursor-pointer w-[150px]",
|
|
10388
|
+
items: items(data2),
|
|
10389
|
+
triggerMode: "hover",
|
|
10390
|
+
children: /* @__PURE__ */ jsx66(EllipsisVertical5, {})
|
|
10391
|
+
}
|
|
10392
|
+
);
|
|
10393
|
+
}
|
|
10394
|
+
}
|
|
10395
|
+
].filter(Boolean);
|
|
10396
|
+
const categories = data?.data || [];
|
|
10397
|
+
const onDelete = async (id) => {
|
|
10398
|
+
try {
|
|
10399
|
+
await remove({ url: `/categories/delete/${id}` });
|
|
10400
|
+
message18.success("Category deleted successfully");
|
|
10401
|
+
reload();
|
|
10402
|
+
setDeleteCategory(null);
|
|
10403
|
+
} catch (error) {
|
|
10404
|
+
message18.error(error.message || "Something went wrong");
|
|
10405
|
+
return error;
|
|
10406
|
+
}
|
|
10407
|
+
};
|
|
10408
|
+
return /* @__PURE__ */ jsxs51(Fragment15, { children: [
|
|
10409
|
+
/* @__PURE__ */ jsx66(Modal2, {}),
|
|
10410
|
+
/* @__PURE__ */ jsx66(
|
|
10411
|
+
ConfirmModal,
|
|
10412
|
+
{
|
|
10413
|
+
isOpen: !!deleteCategory,
|
|
10414
|
+
isLoading,
|
|
10415
|
+
onClose: () => setDeleteCategory(null),
|
|
10416
|
+
title: `Delete Category`,
|
|
10417
|
+
description: `Are you sure you want to delete "${deleteCategory?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
10418
|
+
confirmationWord: "delete",
|
|
10419
|
+
onSubmit: () => onDelete(deleteCategory?._id),
|
|
10420
|
+
children: null
|
|
10421
|
+
}
|
|
10422
|
+
),
|
|
10423
|
+
/* @__PURE__ */ jsx66(
|
|
10424
|
+
TransactionViewComponent,
|
|
10425
|
+
{
|
|
10426
|
+
columns,
|
|
10427
|
+
data: categories,
|
|
10428
|
+
title: `Categories`,
|
|
10429
|
+
description: `Add or update categories`,
|
|
10430
|
+
index: true,
|
|
10431
|
+
createTitle: `Add Category`,
|
|
10432
|
+
onCreate: () => {
|
|
10433
|
+
navigate("create");
|
|
10434
|
+
}
|
|
10435
|
+
}
|
|
10436
|
+
)
|
|
10437
|
+
] });
|
|
10438
|
+
}
|
|
10439
|
+
var Categories_default = Categories;
|
|
10440
|
+
|
|
10441
|
+
// src/components/categories/schema.ts
|
|
10442
|
+
import { z as z7 } from "zod";
|
|
10443
|
+
var createCategorySchema = z7.object({
|
|
10444
|
+
name: z7.string().min(2, { message: "Name must be at least 2 characters" })
|
|
10445
|
+
});
|
|
10446
|
+
|
|
10447
|
+
// src/components/categories/CategoryForm.tsx
|
|
10448
|
+
import { useForm as useForm11 } from "react-hook-form";
|
|
10449
|
+
import { zodResolver as zodResolver10 } from "@hookform/resolvers/zod";
|
|
10450
|
+
import { message as message19 } from "antd";
|
|
10451
|
+
import { useEffect as useEffect27 } from "react";
|
|
10452
|
+
import { jsx as jsx67, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
10453
|
+
function CategoryForm() {
|
|
10454
|
+
const { getQuery, navigate } = useApp_default();
|
|
10455
|
+
const id = getQuery("id");
|
|
10456
|
+
const isEdit = !!id;
|
|
10457
|
+
const { post, put, isLoading } = useApis_default();
|
|
10458
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10459
|
+
const methods = useForm11({
|
|
10460
|
+
resolver: zodResolver10(createCategorySchema),
|
|
10461
|
+
defaultValues: {
|
|
10462
|
+
name: ""
|
|
10463
|
+
},
|
|
10464
|
+
shouldUnregister: false
|
|
10465
|
+
});
|
|
10466
|
+
const { handleSubmit } = methods;
|
|
10467
|
+
const onSubmit = async (data) => {
|
|
10468
|
+
try {
|
|
10469
|
+
if (isEdit) {
|
|
10470
|
+
await put({
|
|
10471
|
+
url: `/categories/update/${id}`,
|
|
10472
|
+
body: data
|
|
10473
|
+
});
|
|
10474
|
+
} else {
|
|
10475
|
+
await post({
|
|
10476
|
+
url: "/categories/create",
|
|
10477
|
+
body: data
|
|
10478
|
+
});
|
|
10479
|
+
}
|
|
10480
|
+
message19.success(`Category ${isEdit ? "updated" : "created"} successfully`);
|
|
10481
|
+
navigate(-1);
|
|
10482
|
+
} catch (error) {
|
|
10483
|
+
message19.error(error?.message || "Something went wrong");
|
|
10484
|
+
}
|
|
10485
|
+
};
|
|
10486
|
+
const fetches = async () => {
|
|
10487
|
+
try {
|
|
10488
|
+
const res = await get({
|
|
10489
|
+
url: `/categories/get?id=${id}`
|
|
10490
|
+
});
|
|
10491
|
+
const data = res.data;
|
|
10492
|
+
methods.reset(data);
|
|
10493
|
+
} catch (error) {
|
|
10494
|
+
message19.error(error?.message || "Something went wrong");
|
|
10495
|
+
}
|
|
10496
|
+
};
|
|
10497
|
+
useEffect27(() => {
|
|
10498
|
+
if (isEdit) {
|
|
10499
|
+
fetches();
|
|
10500
|
+
}
|
|
10501
|
+
}, [id]);
|
|
10502
|
+
return /* @__PURE__ */ jsxs52(
|
|
10503
|
+
Card,
|
|
10504
|
+
{
|
|
10505
|
+
className: "max-w-4xl mx-auto mt-10 relative",
|
|
10506
|
+
isLoading: isLoadingGet,
|
|
10507
|
+
loadingText: "Processing...",
|
|
10508
|
+
children: [
|
|
10509
|
+
/* @__PURE__ */ jsxs52(Card.Header, { children: [
|
|
10510
|
+
/* @__PURE__ */ jsx67(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Category` }),
|
|
10511
|
+
/* @__PURE__ */ jsx67(Card.Description, { children: isEdit ? `Update the details for this category` : `Create a new category and add it to your list` })
|
|
10512
|
+
] }),
|
|
10513
|
+
/* @__PURE__ */ jsx67(Card.Content, { children: /* @__PURE__ */ jsxs52(
|
|
10514
|
+
"form",
|
|
10515
|
+
{
|
|
10516
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
10517
|
+
children: [
|
|
10518
|
+
/* @__PURE__ */ jsx67("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: /* @__PURE__ */ jsx67(
|
|
10519
|
+
Fields_default.Input,
|
|
10520
|
+
{
|
|
10521
|
+
label: "Name",
|
|
10522
|
+
form: methods,
|
|
10523
|
+
name: "name",
|
|
10524
|
+
type: "text",
|
|
10525
|
+
placeholder: "Enter Category Name",
|
|
10526
|
+
required: true
|
|
10527
|
+
}
|
|
10528
|
+
) }),
|
|
10529
|
+
/* @__PURE__ */ jsx67("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ jsx67(
|
|
10530
|
+
Button,
|
|
10531
|
+
{
|
|
10532
|
+
isLoading,
|
|
10533
|
+
disabled: isLoading,
|
|
10534
|
+
type: "submit",
|
|
10535
|
+
className: "min-w-[100px]",
|
|
10536
|
+
variant: !isEdit ? "primary" : "warning",
|
|
10537
|
+
children: isEdit ? "Update" : "Add"
|
|
10538
|
+
}
|
|
10539
|
+
) })
|
|
10540
|
+
]
|
|
10541
|
+
}
|
|
10542
|
+
) })
|
|
10543
|
+
]
|
|
10544
|
+
}
|
|
10545
|
+
);
|
|
10546
|
+
}
|
|
10547
|
+
var CategoryForm_default = CategoryForm;
|
|
10548
|
+
|
|
10549
|
+
// src/components/categories/Feilds/Category.tsx
|
|
10550
|
+
import { useParams as useParams12 } from "react-router-dom";
|
|
10551
|
+
import { jsx as jsx68 } from "react/jsx-runtime";
|
|
10552
|
+
function Category({
|
|
10553
|
+
name,
|
|
10554
|
+
label,
|
|
10555
|
+
placeholder,
|
|
10556
|
+
api,
|
|
10557
|
+
form,
|
|
10558
|
+
filter,
|
|
10559
|
+
v = 1,
|
|
10560
|
+
required,
|
|
10561
|
+
disabled
|
|
10562
|
+
}) {
|
|
10563
|
+
const { branchId } = useParams12();
|
|
10564
|
+
return /* @__PURE__ */ jsx68("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx68(
|
|
10565
|
+
Fields_default.SearchApi,
|
|
10566
|
+
{
|
|
10567
|
+
name,
|
|
10568
|
+
form,
|
|
10569
|
+
label,
|
|
10570
|
+
placeholder: placeholder || `Select ${name}`,
|
|
10571
|
+
api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
|
|
10572
|
+
queryKey: "search",
|
|
10573
|
+
filter,
|
|
10574
|
+
v,
|
|
10575
|
+
labelKey: "name",
|
|
10576
|
+
valueKey: "_id",
|
|
10577
|
+
required,
|
|
10578
|
+
disabled
|
|
10579
|
+
}
|
|
10580
|
+
) });
|
|
10581
|
+
}
|
|
10582
|
+
var Category_default = Category;
|
|
10583
|
+
|
|
10584
|
+
// src/components/categories/Feilds/index.tsx
|
|
10585
|
+
var CategoryField = {
|
|
10586
|
+
Category: Category_default
|
|
10587
|
+
};
|
|
10588
|
+
var Feilds_default4 = CategoryField;
|
|
10589
|
+
|
|
10590
|
+
// src/components/products/Products.tsx
|
|
10591
|
+
import { useNavigate as useNavigate13 } from "react-router-dom";
|
|
10592
|
+
import { EllipsisVertical as EllipsisVertical6, FilePenLine as FilePenLine5, Trash2 as Trash26 } from "lucide-react";
|
|
10593
|
+
import { useState as useState35 } from "react";
|
|
10594
|
+
import { message as message20 } from "antd";
|
|
10595
|
+
import { Fragment as Fragment16, jsx as jsx69, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
10596
|
+
function Products({ v, url }) {
|
|
10597
|
+
const [deleteProduct, setDeleteProduct] = useState35(null);
|
|
10598
|
+
const { isLoading, remove } = useApis_default();
|
|
10599
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10600
|
+
url: url || `/products/get`,
|
|
10601
|
+
v,
|
|
10602
|
+
dateFilter: false
|
|
10603
|
+
});
|
|
10604
|
+
const { Modal: Modal2 } = useModal();
|
|
10605
|
+
const navigate = useNavigate13();
|
|
10606
|
+
const items = (data2) => [
|
|
10607
|
+
{
|
|
10608
|
+
label: `Edit Product`,
|
|
10609
|
+
icon: /* @__PURE__ */ jsx69(FilePenLine5, { size: 16 }),
|
|
10610
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10611
|
+
},
|
|
10612
|
+
{
|
|
10613
|
+
label: `Delete Product`,
|
|
10614
|
+
icon: /* @__PURE__ */ jsx69(Trash26, { className: "text-red-500", size: 16 }),
|
|
10615
|
+
onClick: () => setDeleteProduct(data2)
|
|
10616
|
+
}
|
|
10617
|
+
].filter(Boolean);
|
|
10618
|
+
const columns = [
|
|
10619
|
+
{
|
|
10620
|
+
accessorKey: "name",
|
|
10621
|
+
header: "Name",
|
|
10622
|
+
cell: ({ row }) => {
|
|
10623
|
+
const product = row.original;
|
|
10624
|
+
return /* @__PURE__ */ jsx69("span", { children: product?.name });
|
|
10625
|
+
}
|
|
10626
|
+
},
|
|
10627
|
+
{
|
|
10628
|
+
accessorKey: "category",
|
|
10629
|
+
header: "Category",
|
|
10630
|
+
cell: ({ row }) => {
|
|
10631
|
+
const product = row.original;
|
|
10632
|
+
return /* @__PURE__ */ jsx69("span", { children: product?.categoryData?.name || "N/A" });
|
|
10633
|
+
}
|
|
10634
|
+
},
|
|
10635
|
+
{
|
|
10636
|
+
accessorKey: "brand",
|
|
10637
|
+
header: "Brand",
|
|
10638
|
+
cell: ({ row }) => {
|
|
10639
|
+
const product = row.original;
|
|
10640
|
+
return /* @__PURE__ */ jsx69("span", { children: product?.brandData?.name || "N/A" });
|
|
10641
|
+
}
|
|
10642
|
+
},
|
|
10643
|
+
{
|
|
10644
|
+
accessorKey: "cost",
|
|
10645
|
+
header: "Cost",
|
|
10646
|
+
cell: ({ row }) => {
|
|
10647
|
+
const product = row.original;
|
|
10648
|
+
return /* @__PURE__ */ jsxs53("span", { children: [
|
|
10649
|
+
" ",
|
|
10650
|
+
product?.cost?.toLocaleString()
|
|
10651
|
+
] });
|
|
10652
|
+
}
|
|
10653
|
+
},
|
|
10654
|
+
{
|
|
10655
|
+
accessorKey: "actions",
|
|
10656
|
+
header: "Actions",
|
|
10657
|
+
cell: ({ row }) => {
|
|
10658
|
+
const data2 = row.original;
|
|
10659
|
+
return /* @__PURE__ */ jsx69(
|
|
10660
|
+
Dropdown,
|
|
10661
|
+
{
|
|
10662
|
+
className: "cursor-pointer w-[150px]",
|
|
10663
|
+
items: items(data2),
|
|
10664
|
+
triggerMode: "hover",
|
|
10665
|
+
children: /* @__PURE__ */ jsx69(EllipsisVertical6, {})
|
|
10666
|
+
}
|
|
10667
|
+
);
|
|
10668
|
+
}
|
|
10669
|
+
}
|
|
10670
|
+
].filter(Boolean);
|
|
10671
|
+
const products = data?.data || [];
|
|
10672
|
+
const onDelete = async (id) => {
|
|
10673
|
+
try {
|
|
10674
|
+
await remove({ url: `/products/delete/${id}` });
|
|
10675
|
+
message20.success("Product deleted successfully");
|
|
10676
|
+
reload();
|
|
10677
|
+
setDeleteProduct(null);
|
|
10678
|
+
} catch (error) {
|
|
10679
|
+
message20.error(error.message || "Something went wrong");
|
|
10680
|
+
return error;
|
|
10681
|
+
}
|
|
10682
|
+
};
|
|
10683
|
+
return /* @__PURE__ */ jsxs53(Fragment16, { children: [
|
|
10684
|
+
/* @__PURE__ */ jsx69(Modal2, {}),
|
|
10685
|
+
/* @__PURE__ */ jsx69(
|
|
10686
|
+
ConfirmModal,
|
|
10687
|
+
{
|
|
10688
|
+
isOpen: !!deleteProduct,
|
|
10689
|
+
isLoading,
|
|
10690
|
+
onClose: () => setDeleteProduct(null),
|
|
10691
|
+
title: `Delete Product`,
|
|
10692
|
+
description: `Are you sure you want to delete "${deleteProduct?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
10693
|
+
confirmationWord: "delete",
|
|
10694
|
+
onSubmit: () => onDelete(deleteProduct?._id),
|
|
10695
|
+
children: null
|
|
10696
|
+
}
|
|
10697
|
+
),
|
|
10698
|
+
/* @__PURE__ */ jsx69(
|
|
10699
|
+
TransactionViewComponent,
|
|
10700
|
+
{
|
|
10701
|
+
columns,
|
|
10702
|
+
data: products,
|
|
10703
|
+
title: `Products`,
|
|
10704
|
+
description: `Add or update products`,
|
|
10705
|
+
index: true,
|
|
10706
|
+
createTitle: `Add Product`,
|
|
10707
|
+
onCreate: () => {
|
|
10708
|
+
navigate("create");
|
|
10709
|
+
}
|
|
10710
|
+
}
|
|
10711
|
+
)
|
|
10712
|
+
] });
|
|
10713
|
+
}
|
|
10714
|
+
var Products_default = Products;
|
|
10715
|
+
|
|
10716
|
+
// src/components/products/schema.ts
|
|
10717
|
+
import { z as z8 } from "zod";
|
|
10718
|
+
var createProductSchema = z8.object({
|
|
10719
|
+
name: z8.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
10720
|
+
category: z8.string().optional(),
|
|
10721
|
+
brand: z8.string().optional(),
|
|
10722
|
+
cost: z8.number({ message: "Cost is required" }).min(0)
|
|
10723
|
+
});
|
|
10724
|
+
|
|
10725
|
+
// src/components/products/ProductForm.tsx
|
|
10726
|
+
import { useForm as useForm12 } from "react-hook-form";
|
|
10727
|
+
import { zodResolver as zodResolver11 } from "@hookform/resolvers/zod";
|
|
10728
|
+
import { message as message21 } from "antd";
|
|
10729
|
+
import { useEffect as useEffect28 } from "react";
|
|
10730
|
+
import { jsx as jsx70, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
10731
|
+
function ProductForm() {
|
|
10732
|
+
const { getQuery, navigate } = useApp_default();
|
|
10733
|
+
const id = getQuery("id");
|
|
10734
|
+
const isEdit = !!id;
|
|
10735
|
+
const { post, put, isLoading } = useApis_default();
|
|
10736
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
10737
|
+
const methods = useForm12({
|
|
10738
|
+
resolver: zodResolver11(createProductSchema),
|
|
10739
|
+
defaultValues: {
|
|
10740
|
+
name: "",
|
|
10741
|
+
category: void 0,
|
|
10742
|
+
brand: void 0,
|
|
10743
|
+
cost: 0
|
|
10744
|
+
},
|
|
10745
|
+
shouldUnregister: false
|
|
10746
|
+
});
|
|
10747
|
+
const { handleSubmit } = methods;
|
|
10748
|
+
const onSubmit = async (data) => {
|
|
10749
|
+
try {
|
|
10750
|
+
if (isEdit) {
|
|
10751
|
+
await put({
|
|
10752
|
+
url: `/products/update/${id}`,
|
|
10753
|
+
body: data
|
|
10754
|
+
});
|
|
10755
|
+
} else {
|
|
10756
|
+
await post({
|
|
10757
|
+
url: "/products/create",
|
|
10758
|
+
body: data
|
|
10759
|
+
});
|
|
10760
|
+
}
|
|
10761
|
+
message21.success(`Product ${isEdit ? "updated" : "created"} successfully`);
|
|
10762
|
+
navigate(-1);
|
|
10763
|
+
} catch (error) {
|
|
10764
|
+
message21.error(error?.message || "Something went wrong");
|
|
10765
|
+
}
|
|
10766
|
+
};
|
|
10767
|
+
const fetches = async () => {
|
|
10768
|
+
try {
|
|
10769
|
+
const res = await get({
|
|
10770
|
+
url: `/products/get?id=${id}`
|
|
10771
|
+
});
|
|
10772
|
+
const data = res.data;
|
|
10773
|
+
methods.reset(data);
|
|
10774
|
+
} catch (error) {
|
|
10775
|
+
message21.error(error?.message || "Something went wrong");
|
|
10776
|
+
}
|
|
10777
|
+
};
|
|
10778
|
+
useEffect28(() => {
|
|
10779
|
+
if (isEdit) {
|
|
10780
|
+
fetches();
|
|
10781
|
+
}
|
|
10782
|
+
}, [id]);
|
|
10783
|
+
return /* @__PURE__ */ jsxs54(
|
|
10784
|
+
Card,
|
|
10785
|
+
{
|
|
10786
|
+
className: "max-w-4xl mx-auto mt-10 relative",
|
|
10787
|
+
isLoading: isLoadingGet,
|
|
10788
|
+
loadingText: "Processing...",
|
|
10789
|
+
children: [
|
|
10790
|
+
/* @__PURE__ */ jsxs54(Card.Header, { children: [
|
|
10791
|
+
/* @__PURE__ */ jsx70(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Product` }),
|
|
10792
|
+
/* @__PURE__ */ jsx70(Card.Description, { children: isEdit ? `Update the details for this product` : `Create a new product and add it to your list` })
|
|
10793
|
+
] }),
|
|
10794
|
+
/* @__PURE__ */ jsx70(Card.Content, { children: /* @__PURE__ */ jsxs54(
|
|
10795
|
+
"form",
|
|
10796
|
+
{
|
|
10797
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
10798
|
+
children: [
|
|
10799
|
+
/* @__PURE__ */ jsxs54("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
|
|
10800
|
+
/* @__PURE__ */ jsx70(
|
|
10801
|
+
Fields_default.Input,
|
|
10802
|
+
{
|
|
10803
|
+
label: "Name",
|
|
10804
|
+
form: methods,
|
|
10805
|
+
name: "name",
|
|
10806
|
+
type: "text",
|
|
10807
|
+
placeholder: "Enter Product Name",
|
|
10808
|
+
required: true
|
|
10809
|
+
}
|
|
10810
|
+
),
|
|
10811
|
+
/* @__PURE__ */ jsx70(
|
|
10812
|
+
Fields_default.Input,
|
|
10813
|
+
{
|
|
10814
|
+
label: "Cost",
|
|
10815
|
+
form: methods,
|
|
10816
|
+
name: "cost",
|
|
10817
|
+
type: "number",
|
|
10818
|
+
placeholder: "0.00",
|
|
10819
|
+
required: true
|
|
10820
|
+
}
|
|
10821
|
+
),
|
|
10822
|
+
/* @__PURE__ */ jsx70(
|
|
10823
|
+
Feilds_default4.Category,
|
|
10824
|
+
{
|
|
10825
|
+
label: "Category",
|
|
10826
|
+
form: methods,
|
|
10827
|
+
name: "category",
|
|
10828
|
+
api: "/categories/get"
|
|
10829
|
+
}
|
|
10830
|
+
),
|
|
10831
|
+
/* @__PURE__ */ jsx70(
|
|
10832
|
+
Feilds_default3.Brand,
|
|
10833
|
+
{
|
|
10834
|
+
label: "Brand",
|
|
10835
|
+
form: methods,
|
|
10836
|
+
name: "brand",
|
|
10837
|
+
api: "/brands/get"
|
|
10838
|
+
}
|
|
10839
|
+
)
|
|
10840
|
+
] }),
|
|
10841
|
+
/* @__PURE__ */ jsx70("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ jsx70(
|
|
10842
|
+
Button,
|
|
10843
|
+
{
|
|
10844
|
+
isLoading,
|
|
10845
|
+
disabled: isLoading,
|
|
10846
|
+
type: "submit",
|
|
10847
|
+
className: "min-w-[100px]",
|
|
10848
|
+
variant: !isEdit ? "primary" : "warning",
|
|
10849
|
+
children: isEdit ? "Update" : "Add"
|
|
10850
|
+
}
|
|
10851
|
+
) })
|
|
10852
|
+
]
|
|
10853
|
+
}
|
|
10854
|
+
) })
|
|
10855
|
+
]
|
|
10856
|
+
}
|
|
10857
|
+
);
|
|
10858
|
+
}
|
|
10859
|
+
var ProductForm_default = ProductForm;
|
|
10860
|
+
|
|
10861
|
+
// src/components/products/Feilds/Product.tsx
|
|
10862
|
+
import { useParams as useParams14 } from "react-router-dom";
|
|
10863
|
+
import { jsx as jsx71 } from "react/jsx-runtime";
|
|
10864
|
+
function Product({
|
|
10865
|
+
name,
|
|
10866
|
+
label,
|
|
10867
|
+
placeholder,
|
|
10868
|
+
api,
|
|
10869
|
+
form,
|
|
10870
|
+
filter,
|
|
10871
|
+
v = 1,
|
|
10872
|
+
required,
|
|
10873
|
+
disabled,
|
|
10874
|
+
onChange,
|
|
10875
|
+
obj
|
|
10876
|
+
}) {
|
|
10877
|
+
const { branchId } = useParams14();
|
|
10878
|
+
return /* @__PURE__ */ jsx71("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ jsx71(
|
|
10879
|
+
Fields_default.SearchApi,
|
|
10880
|
+
{
|
|
10881
|
+
name,
|
|
10882
|
+
form,
|
|
10883
|
+
label,
|
|
10884
|
+
onChange,
|
|
10885
|
+
placeholder: placeholder || `Select ${name}`,
|
|
10886
|
+
api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
|
|
10887
|
+
queryKey: "search",
|
|
10888
|
+
filter,
|
|
10889
|
+
v,
|
|
10890
|
+
labelKey: "name",
|
|
10891
|
+
valueKey: "_id",
|
|
10892
|
+
required,
|
|
10893
|
+
disabled,
|
|
10894
|
+
obj
|
|
10895
|
+
}
|
|
10896
|
+
) });
|
|
10897
|
+
}
|
|
10898
|
+
var Product_default = Product;
|
|
10899
|
+
|
|
10900
|
+
// src/components/products/Feilds/index.tsx
|
|
10901
|
+
var ProductField = {
|
|
10902
|
+
Product: Product_default
|
|
10903
|
+
};
|
|
10904
|
+
var Feilds_default5 = ProductField;
|
|
10905
|
+
|
|
10906
|
+
// src/components/packs/Packs.tsx
|
|
10907
|
+
import { useNavigate as useNavigate14 } from "react-router-dom";
|
|
10908
|
+
import { EllipsisVertical as EllipsisVertical7, FilePenLine as FilePenLine6, Trash2 as Trash27 } from "lucide-react";
|
|
10909
|
+
import { useState as useState36 } from "react";
|
|
10910
|
+
import { message as message22 } from "antd";
|
|
10911
|
+
import { Fragment as Fragment17, jsx as jsx72, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
10912
|
+
function Packs({ v, url }) {
|
|
10913
|
+
const [deletePack, setDeletePack] = useState36(null);
|
|
10914
|
+
const { isLoading, remove } = useApis_default();
|
|
10915
|
+
const { data, TransactionViewComponent, reload } = useTransaction_default({
|
|
10916
|
+
url: url || `/packs/get`,
|
|
10917
|
+
v,
|
|
10918
|
+
dateFilter: false
|
|
10919
|
+
});
|
|
10920
|
+
const { Modal: Modal2 } = useModal();
|
|
10921
|
+
const navigate = useNavigate14();
|
|
10922
|
+
const items = (data2) => [
|
|
10923
|
+
{
|
|
10924
|
+
label: `Edit Pack`,
|
|
10925
|
+
icon: /* @__PURE__ */ jsx72(FilePenLine6, { size: 16 }),
|
|
10926
|
+
onClick: () => navigate(`update?id=${data2?._id}`)
|
|
10927
|
+
},
|
|
10928
|
+
{
|
|
10929
|
+
label: `Delete Pack`,
|
|
10930
|
+
icon: /* @__PURE__ */ jsx72(Trash27, { className: "text-red-500", size: 16 }),
|
|
10931
|
+
onClick: () => setDeletePack(data2)
|
|
10932
|
+
}
|
|
10933
|
+
].filter(Boolean);
|
|
10934
|
+
const columns = [
|
|
10935
|
+
{
|
|
10936
|
+
accessorKey: "name",
|
|
10937
|
+
header: "Name",
|
|
10938
|
+
cell: ({ row }) => {
|
|
10939
|
+
const pack = row.original;
|
|
10940
|
+
return /* @__PURE__ */ jsx72("span", { children: pack?.name });
|
|
10941
|
+
}
|
|
10942
|
+
},
|
|
10943
|
+
{
|
|
10944
|
+
accessorKey: "type",
|
|
10945
|
+
header: "Type",
|
|
10946
|
+
cell: ({ row }) => {
|
|
10947
|
+
const pack = row.original;
|
|
10948
|
+
return /* @__PURE__ */ jsx72("span", { className: "capitalize", children: pack?.type });
|
|
10949
|
+
}
|
|
10950
|
+
},
|
|
10951
|
+
{
|
|
10952
|
+
accessorKey: "products",
|
|
10953
|
+
header: "Products Count",
|
|
10954
|
+
cell: ({ row }) => {
|
|
10955
|
+
const pack = row.original;
|
|
10956
|
+
return /* @__PURE__ */ jsxs55("span", { children: [
|
|
10957
|
+
pack?.products?.length || 0,
|
|
10958
|
+
" Products"
|
|
10959
|
+
] });
|
|
10960
|
+
}
|
|
10961
|
+
},
|
|
10962
|
+
{
|
|
10963
|
+
accessorKey: "actions",
|
|
10964
|
+
header: "Actions",
|
|
10965
|
+
cell: ({ row }) => {
|
|
10966
|
+
const data2 = row.original;
|
|
10967
|
+
return /* @__PURE__ */ jsx72(
|
|
10968
|
+
Dropdown,
|
|
10969
|
+
{
|
|
10970
|
+
className: "cursor-pointer w-[150px]",
|
|
10971
|
+
items: items(data2),
|
|
10972
|
+
triggerMode: "hover",
|
|
10973
|
+
children: /* @__PURE__ */ jsx72(EllipsisVertical7, {})
|
|
10974
|
+
}
|
|
10975
|
+
);
|
|
10976
|
+
}
|
|
10977
|
+
}
|
|
10978
|
+
].filter(Boolean);
|
|
10979
|
+
const packs = data?.data || [];
|
|
10980
|
+
const onDelete = async (id) => {
|
|
10981
|
+
try {
|
|
10982
|
+
await remove({ url: `/packs/delete/${id}` });
|
|
10983
|
+
message22.success("Pack deleted successfully");
|
|
10984
|
+
reload();
|
|
10985
|
+
setDeletePack(null);
|
|
10986
|
+
} catch (error) {
|
|
10987
|
+
message22.error(error.message || "Something went wrong");
|
|
10988
|
+
return error;
|
|
10989
|
+
}
|
|
10990
|
+
};
|
|
10991
|
+
return /* @__PURE__ */ jsxs55(Fragment17, { children: [
|
|
10992
|
+
/* @__PURE__ */ jsx72(Modal2, {}),
|
|
10993
|
+
/* @__PURE__ */ jsx72(
|
|
10994
|
+
ConfirmModal,
|
|
10995
|
+
{
|
|
10996
|
+
isOpen: !!deletePack,
|
|
10997
|
+
isLoading,
|
|
10998
|
+
onClose: () => setDeletePack(null),
|
|
10999
|
+
title: `Delete Pack`,
|
|
11000
|
+
description: `Are you sure you want to delete "${deletePack?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
|
|
11001
|
+
confirmationWord: "delete",
|
|
11002
|
+
onSubmit: () => onDelete(deletePack?._id),
|
|
11003
|
+
children: null
|
|
11004
|
+
}
|
|
11005
|
+
),
|
|
11006
|
+
/* @__PURE__ */ jsx72(
|
|
11007
|
+
TransactionViewComponent,
|
|
11008
|
+
{
|
|
11009
|
+
columns,
|
|
11010
|
+
data: packs,
|
|
11011
|
+
title: `Packs`,
|
|
11012
|
+
description: `Add or update product packs`,
|
|
11013
|
+
index: true,
|
|
11014
|
+
createTitle: `Add Pack`,
|
|
11015
|
+
onCreate: () => {
|
|
11016
|
+
navigate("create");
|
|
11017
|
+
}
|
|
11018
|
+
}
|
|
11019
|
+
)
|
|
11020
|
+
] });
|
|
11021
|
+
}
|
|
11022
|
+
var Packs_default = Packs;
|
|
11023
|
+
|
|
11024
|
+
// src/components/packs/schema.ts
|
|
11025
|
+
import { z as z9 } from "zod";
|
|
11026
|
+
var packProductItemSchema = z9.object({
|
|
11027
|
+
product: z9.string({ message: "Product ID is required" }),
|
|
11028
|
+
cost: z9.number().min(0, "Cost must be a positive number"),
|
|
11029
|
+
quantity: z9.number().min(1, "Quantity must be at least 1"),
|
|
11030
|
+
index: z9.number({ message: "Index is required" }),
|
|
11031
|
+
productData: z9.any().optional()
|
|
11032
|
+
});
|
|
11033
|
+
var packTypes = z9.enum(Enums_default.packTypes);
|
|
11034
|
+
var createPackSchema = z9.object({
|
|
11035
|
+
type: packTypes,
|
|
11036
|
+
name: z9.string().min(2, { message: "Name must be at least 2 characters" }),
|
|
11037
|
+
products: z9.array(packProductItemSchema).min(1, "At least one product is required"),
|
|
11038
|
+
tempProduct: z9.string().optional(),
|
|
11039
|
+
tempQty: z9.number().optional(),
|
|
11040
|
+
tempCost: z9.number().optional(),
|
|
11041
|
+
tempData: z9.record(z9.string(), z9.any()).optional()
|
|
11042
|
+
});
|
|
11043
|
+
|
|
11044
|
+
// src/components/packs/PackForm.tsx
|
|
11045
|
+
import { useForm as useForm13, useFieldArray } from "react-hook-form";
|
|
11046
|
+
import { zodResolver as zodResolver12 } from "@hookform/resolvers/zod";
|
|
11047
|
+
import { message as message23 } from "antd";
|
|
11048
|
+
import { useEffect as useEffect29 } from "react";
|
|
11049
|
+
import { Plus as Plus3, Trash2 as Trash28 } from "lucide-react";
|
|
11050
|
+
import { jsx as jsx73, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
11051
|
+
function PackForm() {
|
|
11052
|
+
const { getQuery, navigate } = useApp_default();
|
|
11053
|
+
const id = getQuery("id");
|
|
11054
|
+
const isEdit = !!id;
|
|
11055
|
+
const { post, put, isLoading } = useApis_default();
|
|
11056
|
+
const { isLoading: isLoadingGet, get } = useApis_default();
|
|
11057
|
+
const methods = useForm13({
|
|
11058
|
+
resolver: zodResolver12(createPackSchema),
|
|
11059
|
+
defaultValues: {
|
|
11060
|
+
name: "",
|
|
11061
|
+
type: "boxes",
|
|
11062
|
+
products: [],
|
|
11063
|
+
tempQty: 1,
|
|
11064
|
+
tempCost: 0
|
|
11065
|
+
},
|
|
11066
|
+
shouldUnregister: false
|
|
11067
|
+
});
|
|
11068
|
+
const currentProduct = methods.watch("tempData");
|
|
11069
|
+
const { handleSubmit, control, watch, setValue, getValues } = methods;
|
|
11070
|
+
const { fields, append, remove } = useFieldArray({
|
|
11071
|
+
control,
|
|
11072
|
+
name: "products"
|
|
11073
|
+
});
|
|
11074
|
+
const onAddProduct = () => {
|
|
11075
|
+
const val = getValues("tempProduct");
|
|
11076
|
+
const qty = getValues("tempQty") || 1;
|
|
11077
|
+
const cost = getValues("tempCost") || 0;
|
|
11078
|
+
if (val && currentProduct) {
|
|
11079
|
+
append({
|
|
11080
|
+
product: val,
|
|
11081
|
+
cost: Number(cost),
|
|
11082
|
+
quantity: Number(qty),
|
|
11083
|
+
index: fields.length,
|
|
11084
|
+
productData: currentProduct
|
|
11085
|
+
});
|
|
11086
|
+
setValue("tempProduct", "");
|
|
11087
|
+
setValue("tempQty", 1);
|
|
11088
|
+
setValue("tempCost", 0);
|
|
11089
|
+
} else {
|
|
11090
|
+
message23.warning("Please select a product first");
|
|
11091
|
+
}
|
|
11092
|
+
};
|
|
11093
|
+
const onSubmit = async (data) => {
|
|
11094
|
+
try {
|
|
11095
|
+
const formattedData = {
|
|
11096
|
+
...data,
|
|
11097
|
+
products: data.products.map((p, i) => ({ ...p, index: i }))
|
|
11098
|
+
};
|
|
11099
|
+
if (isEdit) {
|
|
11100
|
+
await put({
|
|
11101
|
+
url: `/packs/update/${id}`,
|
|
11102
|
+
body: formattedData
|
|
11103
|
+
});
|
|
11104
|
+
} else {
|
|
11105
|
+
await post({
|
|
11106
|
+
url: "/packs/create",
|
|
11107
|
+
body: formattedData
|
|
11108
|
+
});
|
|
11109
|
+
}
|
|
11110
|
+
message23.success(`Pack ${isEdit ? "updated" : "created"} successfully`);
|
|
11111
|
+
navigate(-1);
|
|
11112
|
+
} catch (error) {
|
|
11113
|
+
message23.error(error?.message || "Something went wrong");
|
|
11114
|
+
}
|
|
11115
|
+
};
|
|
11116
|
+
const fetches = async () => {
|
|
11117
|
+
try {
|
|
11118
|
+
const res = await get({
|
|
11119
|
+
url: `/packs/get?id=${id}`
|
|
11120
|
+
});
|
|
11121
|
+
const data = res.data;
|
|
11122
|
+
data.products = data.products.map((p, index) => ({
|
|
11123
|
+
...p,
|
|
11124
|
+
tempData: p?.productData,
|
|
11125
|
+
index
|
|
11126
|
+
}));
|
|
11127
|
+
methods.reset(data);
|
|
11128
|
+
} catch (error) {
|
|
11129
|
+
message23.error(error?.message || "Something went wrong");
|
|
11130
|
+
}
|
|
11131
|
+
};
|
|
11132
|
+
useEffect29(() => {
|
|
11133
|
+
if (isEdit) {
|
|
11134
|
+
fetches();
|
|
11135
|
+
}
|
|
11136
|
+
}, [id]);
|
|
11137
|
+
useEffect29(() => {
|
|
11138
|
+
if (currentProduct) {
|
|
11139
|
+
setValue("tempCost", currentProduct.cost || 0);
|
|
11140
|
+
}
|
|
11141
|
+
}, [currentProduct]);
|
|
11142
|
+
return /* @__PURE__ */ jsxs56(
|
|
11143
|
+
Card,
|
|
11144
|
+
{
|
|
11145
|
+
className: "max-w-5xl mx-auto mt-10 relative",
|
|
11146
|
+
isLoading: isLoadingGet,
|
|
11147
|
+
loadingText: "Processing...",
|
|
11148
|
+
children: [
|
|
11149
|
+
/* @__PURE__ */ jsxs56(Card.Header, { children: [
|
|
11150
|
+
/* @__PURE__ */ jsx73(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Pack` }),
|
|
11151
|
+
/* @__PURE__ */ jsx73(Card.Description, { children: isEdit ? `Update the details for this product pack` : `Create a new product pack and define its components` })
|
|
11152
|
+
] }),
|
|
11153
|
+
/* @__PURE__ */ jsx73(Card.Content, { children: /* @__PURE__ */ jsxs56(
|
|
11154
|
+
"form",
|
|
11155
|
+
{
|
|
11156
|
+
onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
|
|
11157
|
+
children: [
|
|
11158
|
+
/* @__PURE__ */ jsxs56("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4 mb-8", children: [
|
|
11159
|
+
/* @__PURE__ */ jsx73(
|
|
11160
|
+
Fields_default.Input,
|
|
11161
|
+
{
|
|
11162
|
+
label: "Pack Name",
|
|
11163
|
+
form: methods,
|
|
11164
|
+
name: "name",
|
|
11165
|
+
type: "text",
|
|
11166
|
+
placeholder: "e.g. Family Box A",
|
|
11167
|
+
required: true
|
|
11168
|
+
}
|
|
11169
|
+
),
|
|
11170
|
+
/* @__PURE__ */ jsx73(
|
|
11171
|
+
Fields_default.Select,
|
|
11172
|
+
{
|
|
11173
|
+
label: "Pack Type",
|
|
11174
|
+
form: methods,
|
|
11175
|
+
name: "type",
|
|
11176
|
+
enumName: "packTypes",
|
|
11177
|
+
required: true
|
|
11178
|
+
}
|
|
11179
|
+
)
|
|
11180
|
+
] }),
|
|
11181
|
+
/* @__PURE__ */ jsxs56("div", { className: "border rounded-lg p-4 bg-gray-50/50 dark:bg-gray-800/20", children: [
|
|
11182
|
+
/* @__PURE__ */ jsx73("h3", { className: "text-lg font-semibold mb-4", children: "Products in Pack" }),
|
|
11183
|
+
/* @__PURE__ */ jsx73("div", { className: "mb-6 bg-white dark:bg-gray-900 p-4 rounded-lg border shadow-sm", children: /* @__PURE__ */ jsxs56("div", { className: "grid grid-cols-12 gap-3 items-end", children: [
|
|
11184
|
+
/* @__PURE__ */ jsx73("div", { className: "col-span-12 sm:col-span-5", children: /* @__PURE__ */ jsx73(
|
|
11185
|
+
Feilds_default5.Product,
|
|
11186
|
+
{
|
|
11187
|
+
label: "Find Product",
|
|
11188
|
+
form: methods,
|
|
11189
|
+
name: "tempProduct",
|
|
11190
|
+
api: "/products/get",
|
|
11191
|
+
obj: "tempData"
|
|
11192
|
+
}
|
|
11193
|
+
) }),
|
|
11194
|
+
/* @__PURE__ */ jsx73("div", { className: "col-span-4 sm:col-span-2", children: /* @__PURE__ */ jsx73(
|
|
11195
|
+
Fields_default.Input,
|
|
11196
|
+
{
|
|
11197
|
+
label: "Qty",
|
|
11198
|
+
form: methods,
|
|
11199
|
+
name: "tempQty",
|
|
11200
|
+
type: "number",
|
|
11201
|
+
placeholder: "1"
|
|
11202
|
+
}
|
|
11203
|
+
) }),
|
|
11204
|
+
/* @__PURE__ */ jsx73("div", { className: "col-span-5 sm:col-span-3", children: /* @__PURE__ */ jsx73(
|
|
11205
|
+
Fields_default.Input,
|
|
11206
|
+
{
|
|
11207
|
+
label: "Cost",
|
|
11208
|
+
form: methods,
|
|
11209
|
+
name: "tempCost",
|
|
11210
|
+
type: "number",
|
|
11211
|
+
placeholder: "0.00"
|
|
11212
|
+
}
|
|
11213
|
+
) }),
|
|
11214
|
+
/* @__PURE__ */ jsx73("div", { className: "col-span-3 sm:col-span-2", children: /* @__PURE__ */ jsx73(
|
|
11215
|
+
Button,
|
|
11216
|
+
{
|
|
11217
|
+
type: "button",
|
|
11218
|
+
onClick: onAddProduct,
|
|
11219
|
+
className: "w-full h-[40px]",
|
|
11220
|
+
icon: /* @__PURE__ */ jsx73(Plus3, { size: 16 }),
|
|
11221
|
+
children: "Add"
|
|
11222
|
+
}
|
|
11223
|
+
) })
|
|
11224
|
+
] }) }),
|
|
11225
|
+
/* @__PURE__ */ jsx73("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs56("table", { className: "w-full text-left border-collapse", children: [
|
|
11226
|
+
/* @__PURE__ */ jsx73("thead", { className: "bg-gray-100 dark:bg-gray-800/50", children: /* @__PURE__ */ jsxs56("tr", { children: [
|
|
11227
|
+
/* @__PURE__ */ jsx73("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500", children: "Product" }),
|
|
11228
|
+
/* @__PURE__ */ jsx73("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-24", children: "Qty" }),
|
|
11229
|
+
/* @__PURE__ */ jsx73("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-32", children: "Cost" }),
|
|
11230
|
+
/* @__PURE__ */ jsx73("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-32", children: "Line Total" }),
|
|
11231
|
+
/* @__PURE__ */ jsx73("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-16 text-center", children: "Action" })
|
|
11232
|
+
] }) }),
|
|
11233
|
+
/* @__PURE__ */ jsxs56("tbody", { className: "divide-y divide-gray-100 dark:divide-gray-800 bg-white dark:bg-gray-900", children: [
|
|
11234
|
+
fields.map((field, index) => /* @__PURE__ */ jsxs56(
|
|
11235
|
+
"tr",
|
|
11236
|
+
{
|
|
11237
|
+
className: "hover:bg-gray-50/50 dark:hover:bg-gray-800/50 transition-colors",
|
|
11238
|
+
children: [
|
|
11239
|
+
/* @__PURE__ */ jsxs56("td", { className: "px-3 py-2", children: [
|
|
11240
|
+
/* @__PURE__ */ jsx73("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: field.productData?.name || "Product" }),
|
|
11241
|
+
field.productData?.sku && /* @__PURE__ */ jsxs56("p", { className: "text-[10px] text-gray-500", children: [
|
|
11242
|
+
"SKU: ",
|
|
11243
|
+
field.productData?.sku
|
|
11244
|
+
] })
|
|
11245
|
+
] }),
|
|
11246
|
+
/* @__PURE__ */ jsx73("td", { className: "px-3 py-2", children: /* @__PURE__ */ jsx73(
|
|
11247
|
+
Fields_default.Input,
|
|
11248
|
+
{
|
|
11249
|
+
form: methods,
|
|
11250
|
+
name: `products.${index}.quantity`,
|
|
11251
|
+
type: "number",
|
|
11252
|
+
placeholder: "1",
|
|
11253
|
+
required: true,
|
|
11254
|
+
className: "h-8 py-1!"
|
|
11255
|
+
}
|
|
11256
|
+
) }),
|
|
11257
|
+
/* @__PURE__ */ jsx73("td", { className: "px-3 py-2", children: /* @__PURE__ */ jsx73(
|
|
11258
|
+
Fields_default.Input,
|
|
11259
|
+
{
|
|
11260
|
+
form: methods,
|
|
11261
|
+
name: `products.${index}.cost`,
|
|
11262
|
+
type: "number",
|
|
11263
|
+
placeholder: "0.00",
|
|
11264
|
+
required: true,
|
|
11265
|
+
className: "h-8 py-1!"
|
|
11266
|
+
}
|
|
11267
|
+
) }),
|
|
11268
|
+
/* @__PURE__ */ jsx73("td", { className: "px-3 py-2", children: /* @__PURE__ */ jsx73("span", { className: "text-sm font-semibold", children: ((Number(watch(`products.${index}.quantity`)) || 0) * (Number(watch(`products.${index}.cost`)) || 0)).toLocaleString() }) }),
|
|
11269
|
+
/* @__PURE__ */ jsx73("td", { className: "px-3 py-2 text-center", children: /* @__PURE__ */ jsx73(
|
|
11270
|
+
Button,
|
|
11271
|
+
{
|
|
11272
|
+
type: "button",
|
|
11273
|
+
variant: "ghost",
|
|
11274
|
+
size: "sm",
|
|
11275
|
+
className: "text-red-500 hover:text-red-700 hover:bg-red-50 p-1 h-8 w-8",
|
|
11276
|
+
onClick: () => remove(index),
|
|
11277
|
+
children: /* @__PURE__ */ jsx73(Trash28, { size: 16 })
|
|
11278
|
+
}
|
|
11279
|
+
) })
|
|
11280
|
+
]
|
|
11281
|
+
},
|
|
11282
|
+
field.id
|
|
11283
|
+
)),
|
|
11284
|
+
fields.length === 0 && /* @__PURE__ */ jsx73("tr", { children: /* @__PURE__ */ jsx73("td", { colSpan: 5, className: "text-center py-10", children: /* @__PURE__ */ jsx73("p", { className: "text-sm text-gray-500", children: "No products added yet. Use the search above to add products." }) }) })
|
|
11285
|
+
] })
|
|
11286
|
+
] }) }),
|
|
11287
|
+
/* @__PURE__ */ jsxs56("div", { className: "mt-6 pt-6 border-t grid grid-cols-1 sm:grid-cols-3 gap-3", children: [
|
|
11288
|
+
/* @__PURE__ */ jsxs56("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
|
|
11289
|
+
/* @__PURE__ */ jsx73("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Lines" }),
|
|
11290
|
+
/* @__PURE__ */ jsx73("p", { className: "text-lg font-bold text-blue-600", children: watch("products")?.length || 0 })
|
|
11291
|
+
] }),
|
|
11292
|
+
/* @__PURE__ */ jsxs56("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
|
|
11293
|
+
/* @__PURE__ */ jsx73("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Quantity" }),
|
|
11294
|
+
/* @__PURE__ */ jsx73("p", { className: "text-lg font-bold text-indigo-600", children: watch("products")?.reduce(
|
|
11295
|
+
(acc, curr) => acc + (Number(curr.quantity) || 0),
|
|
11296
|
+
0
|
|
11297
|
+
) })
|
|
11298
|
+
] }),
|
|
11299
|
+
/* @__PURE__ */ jsxs56("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
|
|
11300
|
+
/* @__PURE__ */ jsx73("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Cost" }),
|
|
11301
|
+
/* @__PURE__ */ jsxs56("p", { className: "text-lg font-bold text-emerald-600", children: [
|
|
11302
|
+
watch("products")?.reduce(
|
|
11303
|
+
(acc, curr) => acc + (Number(curr.quantity) || 0) * (Number(curr.cost) || 0),
|
|
11304
|
+
0
|
|
11305
|
+
).toLocaleString(),
|
|
11306
|
+
" ",
|
|
11307
|
+
/* @__PURE__ */ jsx73("span", { className: "text-[10px] font-normal text-gray-400", children: "USD" })
|
|
11308
|
+
] })
|
|
11309
|
+
] })
|
|
11310
|
+
] })
|
|
11311
|
+
] }),
|
|
11312
|
+
/* @__PURE__ */ jsx73("footer", { className: "flex justify-end mt-8", children: /* @__PURE__ */ jsx73(
|
|
11313
|
+
Button,
|
|
11314
|
+
{
|
|
11315
|
+
isLoading,
|
|
11316
|
+
disabled: isLoading,
|
|
11317
|
+
type: "submit",
|
|
11318
|
+
className: "min-w-[120px]",
|
|
11319
|
+
variant: !isEdit ? "primary" : "warning",
|
|
11320
|
+
children: isEdit ? "Update Pack" : "Create Pack"
|
|
11321
|
+
}
|
|
11322
|
+
) })
|
|
11323
|
+
]
|
|
11324
|
+
}
|
|
11325
|
+
) })
|
|
11326
|
+
]
|
|
11327
|
+
}
|
|
11328
|
+
);
|
|
11329
|
+
}
|
|
11330
|
+
var PackForm_default = PackForm;
|
|
11331
|
+
|
|
11332
|
+
// src/components/packs/Feilds/Pack.tsx
|
|
11333
|
+
import { jsx as jsx74 } from "react/jsx-runtime";
|
|
11334
|
+
function Pack({
|
|
11335
|
+
name,
|
|
11336
|
+
label,
|
|
11337
|
+
placeholder = "Select Pack",
|
|
11338
|
+
api,
|
|
11339
|
+
form,
|
|
11340
|
+
filter,
|
|
11341
|
+
v,
|
|
11342
|
+
required,
|
|
11343
|
+
disabled
|
|
11344
|
+
}) {
|
|
11345
|
+
return /* @__PURE__ */ jsx74(
|
|
11346
|
+
Fields_default.SearchApi,
|
|
11347
|
+
{
|
|
11348
|
+
label,
|
|
11349
|
+
form,
|
|
11350
|
+
name,
|
|
11351
|
+
api,
|
|
11352
|
+
placeholder,
|
|
11353
|
+
queryKey: "name",
|
|
11354
|
+
labelKey: "name",
|
|
11355
|
+
valueKey: "_id",
|
|
11356
|
+
filter,
|
|
11357
|
+
v,
|
|
11358
|
+
required,
|
|
11359
|
+
disabled
|
|
11360
|
+
}
|
|
11361
|
+
);
|
|
11362
|
+
}
|
|
11363
|
+
var Pack_default = { Pack };
|
|
11364
|
+
|
|
10093
11365
|
// src/components/ErrorPage/ErrorPage.tsx
|
|
10094
|
-
import { jsx as
|
|
11366
|
+
import { jsx as jsx75, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
10095
11367
|
var ErrorPageBase = ({
|
|
10096
11368
|
title,
|
|
10097
|
-
message:
|
|
11369
|
+
message: message24,
|
|
10098
11370
|
statusCode,
|
|
10099
11371
|
action,
|
|
10100
11372
|
className = ""
|
|
10101
11373
|
}) => {
|
|
10102
|
-
return /* @__PURE__ */
|
|
11374
|
+
return /* @__PURE__ */ jsx75(
|
|
10103
11375
|
"div",
|
|
10104
11376
|
{
|
|
10105
11377
|
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}`,
|
|
10106
|
-
children: /* @__PURE__ */
|
|
10107
|
-
statusCode && /* @__PURE__ */
|
|
10108
|
-
/* @__PURE__ */
|
|
10109
|
-
statusCode && /* @__PURE__ */
|
|
11378
|
+
children: /* @__PURE__ */ jsxs57("div", { className: "relative flex flex-col items-center justify-center w-full max-w-2xl text-center", children: [
|
|
11379
|
+
statusCode && /* @__PURE__ */ jsx75("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__ */ jsx75("span", { className: "text-[12rem] sm:text-[16rem] md:text-[20rem] font-bold leading-none tracking-tighter", children: statusCode }) }),
|
|
11380
|
+
/* @__PURE__ */ jsxs57("div", { className: "relative z-10 space-y-6", children: [
|
|
11381
|
+
statusCode && /* @__PURE__ */ jsxs57("h2", { className: "text-xl md:text-2xl font-semibold text-zinc-500 dark:text-zinc-400", children: [
|
|
10110
11382
|
"Error ",
|
|
10111
11383
|
statusCode
|
|
10112
11384
|
] }),
|
|
10113
|
-
title && /* @__PURE__ */
|
|
10114
|
-
|
|
10115
|
-
action && /* @__PURE__ */
|
|
11385
|
+
title && /* @__PURE__ */ jsx75("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
|
|
11386
|
+
message24 && /* @__PURE__ */ jsx75("p", { className: "text-lg md:text-xl text-zinc-600 dark:text-zinc-400 max-w-md mx-auto", children: message24 }),
|
|
11387
|
+
action && /* @__PURE__ */ jsx75("div", { className: "pt-8", children: /* @__PURE__ */ jsx75(
|
|
10116
11388
|
"button",
|
|
10117
11389
|
{
|
|
10118
11390
|
onClick: action.onClick,
|
|
@@ -10128,9 +11400,9 @@ var ErrorPageBase = ({
|
|
|
10128
11400
|
};
|
|
10129
11401
|
|
|
10130
11402
|
// src/components/ErrorPage/ErrorPage.500.tsx
|
|
10131
|
-
import { jsx as
|
|
11403
|
+
import { jsx as jsx76 } from "react/jsx-runtime";
|
|
10132
11404
|
var ErrorPage500 = (props) => {
|
|
10133
|
-
return /* @__PURE__ */
|
|
11405
|
+
return /* @__PURE__ */ jsx76(
|
|
10134
11406
|
ErrorPageBase,
|
|
10135
11407
|
{
|
|
10136
11408
|
statusCode: 500,
|
|
@@ -10143,9 +11415,9 @@ var ErrorPage500 = (props) => {
|
|
|
10143
11415
|
};
|
|
10144
11416
|
|
|
10145
11417
|
// src/components/ErrorPage/ErrorPage.404.tsx
|
|
10146
|
-
import { jsx as
|
|
11418
|
+
import { jsx as jsx77 } from "react/jsx-runtime";
|
|
10147
11419
|
var ErrorPage404 = (props) => {
|
|
10148
|
-
return /* @__PURE__ */
|
|
11420
|
+
return /* @__PURE__ */ jsx77(
|
|
10149
11421
|
ErrorPageBase,
|
|
10150
11422
|
{
|
|
10151
11423
|
statusCode: 404,
|
|
@@ -10158,9 +11430,9 @@ var ErrorPage404 = (props) => {
|
|
|
10158
11430
|
};
|
|
10159
11431
|
|
|
10160
11432
|
// src/components/ErrorPage/ErrorPage.401.tsx
|
|
10161
|
-
import { jsx as
|
|
11433
|
+
import { jsx as jsx78 } from "react/jsx-runtime";
|
|
10162
11434
|
var ErrorPage401 = (props) => {
|
|
10163
|
-
return /* @__PURE__ */
|
|
11435
|
+
return /* @__PURE__ */ jsx78(
|
|
10164
11436
|
ErrorPageBase,
|
|
10165
11437
|
{
|
|
10166
11438
|
statusCode: 401,
|
|
@@ -10173,9 +11445,9 @@ var ErrorPage401 = (props) => {
|
|
|
10173
11445
|
};
|
|
10174
11446
|
|
|
10175
11447
|
// src/components/ErrorPage/ErrorPage.400.tsx
|
|
10176
|
-
import { jsx as
|
|
11448
|
+
import { jsx as jsx79 } from "react/jsx-runtime";
|
|
10177
11449
|
var ErrorPage400 = (props) => {
|
|
10178
|
-
return /* @__PURE__ */
|
|
11450
|
+
return /* @__PURE__ */ jsx79(
|
|
10179
11451
|
ErrorPageBase,
|
|
10180
11452
|
{
|
|
10181
11453
|
statusCode: 400,
|
|
@@ -10200,7 +11472,10 @@ export {
|
|
|
10200
11472
|
Accounts_default as Accounts,
|
|
10201
11473
|
AdminProtectedRoute,
|
|
10202
11474
|
Badge,
|
|
11475
|
+
Feilds_default3 as BrandField,
|
|
11476
|
+
BrandForm_default as BrandForm,
|
|
10203
11477
|
Branding,
|
|
11478
|
+
Brands_default as Brands,
|
|
10204
11479
|
Breadcrumbs,
|
|
10205
11480
|
Button,
|
|
10206
11481
|
Card,
|
|
@@ -10209,7 +11484,10 @@ export {
|
|
|
10209
11484
|
CardFooter,
|
|
10210
11485
|
CardHeader,
|
|
10211
11486
|
CardTitle,
|
|
11487
|
+
Categories_default as Categories,
|
|
10212
11488
|
CategoryCard,
|
|
11489
|
+
Feilds_default4 as CategoryField,
|
|
11490
|
+
CategoryForm_default as CategoryForm,
|
|
10213
11491
|
ClassicSpin,
|
|
10214
11492
|
CodeBlock,
|
|
10215
11493
|
ConfirmModal,
|
|
@@ -10227,10 +11505,16 @@ export {
|
|
|
10227
11505
|
LoadingSpin,
|
|
10228
11506
|
Modal,
|
|
10229
11507
|
OverlaySpin,
|
|
11508
|
+
Pack_default as PackField,
|
|
11509
|
+
PackForm_default as PackForm,
|
|
11510
|
+
Packs_default as Packs,
|
|
10230
11511
|
PageA4,
|
|
10231
11512
|
PageHeader,
|
|
10232
11513
|
PhoneInput,
|
|
10233
11514
|
PostTable,
|
|
11515
|
+
Feilds_default5 as ProductField,
|
|
11516
|
+
ProductForm_default as ProductForm,
|
|
11517
|
+
Products_default as Products,
|
|
10234
11518
|
ProfileCard,
|
|
10235
11519
|
ProfileDropdown,
|
|
10236
11520
|
ProfilePage_default as ProfilePage,
|
|
@@ -10261,10 +11545,16 @@ export {
|
|
|
10261
11545
|
Wallets_default as Wallets,
|
|
10262
11546
|
WarqadProvider,
|
|
10263
11547
|
createAccountSchema,
|
|
11548
|
+
createBrandSchema,
|
|
11549
|
+
createCategorySchema,
|
|
11550
|
+
createPackSchema,
|
|
11551
|
+
createProductSchema,
|
|
10264
11552
|
createUserSchema,
|
|
10265
11553
|
createWalletSchema,
|
|
10266
11554
|
generatePdf,
|
|
10267
11555
|
linkUserSchema,
|
|
11556
|
+
packProductItemSchema,
|
|
11557
|
+
packTypes,
|
|
10268
11558
|
resetPasswordSchema,
|
|
10269
11559
|
storage,
|
|
10270
11560
|
updateUserEmailSchema,
|