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.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 message16 = error;
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
- message16 = errorObj?.message;
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
- message16 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message16 })
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 message16 = error;
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
- message16 = currentError?.message || message16;
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
- message16 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message16 })
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 message16 = error;
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
- message16 = currentError?.message || message16;
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
- message16 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message16 })
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 message16 = error;
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
- message16 = errorObj?.message;
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
- message16 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message16 })
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 message16 = error || errorMessage;
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
- message16 = currentError?.message || message16;
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: message16,
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 message16 = error;
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
- message16 = errorObj?.message;
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
- ${message16 ? "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"}
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 && !message16 ? primaryColor : void 0,
3195
- boxShadow: isFocused && !message16 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
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: message16 ? "#ef4444" : isFocused ? primaryColor : void 0
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
- message16 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message16 })
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, message16) {
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"), message16);
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, message16) {
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"), message16);
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, message16) {
7535
- if (!valid && !warned[message16]) {
7536
- method(false, message16);
7537
- warned[message16] = true;
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, message16) {
7541
- call(warning, valid, message16);
7559
+ function warningOnce(valid, message24) {
7560
+ call(warning, valid, message24);
7542
7561
  }
7543
- function noteOnce(valid, message16) {
7544
- call(note, valid, message16);
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, message16) {
7556
- warningOnce(valid, `[@ant-design/icons] ${message16}`);
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,1300 @@ 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 [deleteBrand, setDeleteBrand] = (0, import_react45.useState)(null);
10159
+ const { isLoading, remove } = useApis_default();
10160
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
10161
+ url: url || `/brands/get`,
10162
+ v,
10163
+ dateFilter: false
10164
+ });
10165
+ const { Modal: Modal2 } = useModal();
10166
+ const navigate = (0, import_react_router_dom17.useNavigate)();
10167
+ const items = (data2) => [
10168
+ {
10169
+ label: `Edit Brand`,
10170
+ icon: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react26.FilePenLine, { size: 16 }),
10171
+ onClick: () => navigate(`update?id=${data2?._id}`)
10172
+ },
10173
+ {
10174
+ label: `Delete Brand`,
10175
+ icon: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react26.Trash2, { className: "text-red-500", size: 16 }),
10176
+ onClick: () => setDeleteBrand(data2)
10177
+ }
10178
+ ].filter(Boolean);
10179
+ const columns = [
10180
+ {
10181
+ accessorKey: "name",
10182
+ header: "Name",
10183
+ cell: ({ row }) => {
10184
+ const brand = row.original;
10185
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { children: brand?.name });
10186
+ }
10187
+ },
10188
+ {
10189
+ accessorKey: "actions",
10190
+ header: "Actions",
10191
+ cell: ({ row }) => {
10192
+ const data2 = row.original;
10193
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
10194
+ Dropdown,
10195
+ {
10196
+ className: "cursor-pointer w-[150px]",
10197
+ items: items(data2),
10198
+ triggerMode: "hover",
10199
+ children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_lucide_react26.EllipsisVertical, {})
10200
+ }
10201
+ );
10202
+ }
10203
+ }
10204
+ ].filter(Boolean);
10205
+ const brands = data?.data || [];
10206
+ const onDelete = async (id) => {
10207
+ try {
10208
+ await remove({ url: `/brands/delete/${id}` });
10209
+ import_antd18.message.success("Brand deleted successfully");
10210
+ reload();
10211
+ setDeleteBrand(null);
10212
+ } catch (error) {
10213
+ import_antd18.message.error(error.message || "Something went wrong");
10214
+ return error;
10215
+ }
10216
+ };
10217
+ return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
10218
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Modal2, {}),
10219
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
10220
+ ConfirmModal,
10221
+ {
10222
+ isOpen: !!deleteBrand,
10223
+ isLoading,
10224
+ onClose: () => setDeleteBrand(null),
10225
+ title: `Delete Brand`,
10226
+ description: `Are you sure you want to delete "${deleteBrand?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
10227
+ confirmationWord: "delete",
10228
+ onSubmit: () => onDelete(deleteBrand?._id),
10229
+ children: null
10230
+ }
10231
+ ),
10232
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
10233
+ TransactionViewComponent,
10234
+ {
10235
+ columns,
10236
+ data: brands,
10237
+ title: `Brands`,
10238
+ description: `Add or update brands`,
10239
+ index: true,
10240
+ createTitle: `Add Brand`,
10241
+ onCreate: () => {
10242
+ navigate("create");
10243
+ }
10244
+ }
10245
+ )
10246
+ ] });
10247
+ }
10248
+ var Brands_default = Brands;
10249
+
10250
+ // src/components/brands/schema.ts
10251
+ var import_zod12 = require("zod");
10252
+ var createBrandSchema = import_zod12.z.object({
10253
+ name: import_zod12.z.string().min(2, { message: "Name must be at least 2 characters" })
10254
+ });
10255
+
10256
+ // src/components/brands/BrandForm.tsx
10257
+ var import_react_hook_form16 = require("react-hook-form");
10258
+ var import_zod13 = require("@hookform/resolvers/zod");
10259
+ var import_antd19 = require("antd");
10260
+ var import_react46 = require("react");
10261
+ var import_jsx_runtime64 = require("react/jsx-runtime");
10262
+ function BrandForm() {
10263
+ const { getQuery, navigate } = useApp_default();
10264
+ const id = getQuery("id");
10265
+ const isEdit = !!id;
10266
+ const { post, put, isLoading } = useApis_default();
10267
+ const { isLoading: isLoadingGet, get } = useApis_default();
10268
+ const methods = (0, import_react_hook_form16.useForm)({
10269
+ resolver: (0, import_zod13.zodResolver)(createBrandSchema),
10270
+ defaultValues: {
10271
+ name: ""
10272
+ },
10273
+ shouldUnregister: false
10274
+ });
10275
+ const { handleSubmit } = methods;
10276
+ const onSubmit = async (data) => {
10277
+ try {
10278
+ if (isEdit) {
10279
+ await put({
10280
+ url: `/brands/update/${id}`,
10281
+ body: data
10282
+ });
10283
+ } else {
10284
+ await post({
10285
+ url: "/brands/create",
10286
+ body: data
10287
+ });
10288
+ }
10289
+ import_antd19.message.success(`Brand ${isEdit ? "updated" : "created"} successfully`);
10290
+ navigate(-1);
10291
+ } catch (error) {
10292
+ import_antd19.message.error(error?.message || "Something went wrong");
10293
+ }
10294
+ };
10295
+ const fetches = async () => {
10296
+ try {
10297
+ const res = await get({
10298
+ url: `/brands/get?id=${id}`
10299
+ });
10300
+ const data = res.data;
10301
+ methods.reset(data);
10302
+ } catch (error) {
10303
+ import_antd19.message.error(error?.message || "Something went wrong");
10304
+ }
10305
+ };
10306
+ (0, import_react46.useEffect)(() => {
10307
+ if (isEdit) {
10308
+ fetches();
10309
+ }
10310
+ }, [id]);
10311
+ return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
10312
+ Card,
10313
+ {
10314
+ className: "max-w-4xl mx-auto mt-10 relative",
10315
+ isLoading: isLoadingGet,
10316
+ loadingText: "Processing...",
10317
+ children: [
10318
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Card.Header, { children: [
10319
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Brand` }),
10320
+ /* @__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` })
10321
+ ] }),
10322
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
10323
+ "form",
10324
+ {
10325
+ onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
10326
+ children: [
10327
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
10328
+ Fields_default.Input,
10329
+ {
10330
+ label: "Name",
10331
+ form: methods,
10332
+ name: "name",
10333
+ type: "text",
10334
+ placeholder: "Enter Brand Name",
10335
+ required: true
10336
+ }
10337
+ ) }),
10338
+ /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
10339
+ Button,
10340
+ {
10341
+ isLoading,
10342
+ disabled: isLoading,
10343
+ type: "submit",
10344
+ className: "min-w-[100px]",
10345
+ variant: !isEdit ? "primary" : "warning",
10346
+ children: isEdit ? "Update" : "Add"
10347
+ }
10348
+ ) })
10349
+ ]
10350
+ }
10351
+ ) })
10352
+ ]
10353
+ }
10354
+ );
10355
+ }
10356
+ var BrandForm_default = BrandForm;
10357
+
10358
+ // src/components/brands/Feilds/Brand.tsx
10359
+ var import_react_router_dom18 = require("react-router-dom");
10360
+ var import_jsx_runtime65 = require("react/jsx-runtime");
10361
+ function Brand({
10362
+ name,
10363
+ label,
10364
+ placeholder,
10365
+ api,
10366
+ form,
10367
+ filter,
10368
+ v = 1,
10369
+ required,
10370
+ disabled
10371
+ }) {
10372
+ const { branchId } = (0, import_react_router_dom18.useParams)();
10373
+ return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
10374
+ Fields_default.SearchApi,
10375
+ {
10376
+ name,
10377
+ form,
10378
+ label,
10379
+ placeholder: placeholder || `Select ${name}`,
10380
+ api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
10381
+ queryKey: "search",
10382
+ filter,
10383
+ v,
10384
+ labelKey: "name",
10385
+ valueKey: "_id",
10386
+ required,
10387
+ disabled
10388
+ }
10389
+ ) });
10390
+ }
10391
+ var Brand_default = Brand;
10392
+
10393
+ // src/components/brands/Feilds/index.tsx
10394
+ var BrandField = {
10395
+ Brand: Brand_default
10396
+ };
10397
+ var Feilds_default3 = BrandField;
10398
+
10399
+ // src/components/categories/Categories.tsx
10400
+ var import_react_router_dom19 = require("react-router-dom");
10401
+ var import_lucide_react27 = require("lucide-react");
10402
+ var import_react47 = require("react");
10403
+ var import_antd20 = require("antd");
10404
+ var import_jsx_runtime66 = require("react/jsx-runtime");
10405
+ function Categories({ v, url }) {
10406
+ const [deleteCategory, setDeleteCategory] = (0, import_react47.useState)(null);
10407
+ const { isLoading, remove } = useApis_default();
10408
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
10409
+ url: url || `/categories/get`,
10410
+ v,
10411
+ dateFilter: false
10412
+ });
10413
+ const { Modal: Modal2 } = useModal();
10414
+ const navigate = (0, import_react_router_dom19.useNavigate)();
10415
+ const items = (data2) => [
10416
+ {
10417
+ label: `Edit Category`,
10418
+ icon: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react27.FilePenLine, { size: 16 }),
10419
+ onClick: () => navigate(`update?id=${data2?._id}`)
10420
+ },
10421
+ {
10422
+ label: `Delete Category`,
10423
+ icon: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react27.Trash2, { className: "text-red-500", size: 16 }),
10424
+ onClick: () => setDeleteCategory(data2)
10425
+ }
10426
+ ].filter(Boolean);
10427
+ const columns = [
10428
+ {
10429
+ accessorKey: "name",
10430
+ header: "Name",
10431
+ cell: ({ row }) => {
10432
+ const category = row.original;
10433
+ return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("span", { children: category?.name });
10434
+ }
10435
+ },
10436
+ {
10437
+ accessorKey: "actions",
10438
+ header: "Actions",
10439
+ cell: ({ row }) => {
10440
+ const data2 = row.original;
10441
+ return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
10442
+ Dropdown,
10443
+ {
10444
+ className: "cursor-pointer w-[150px]",
10445
+ items: items(data2),
10446
+ triggerMode: "hover",
10447
+ children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_lucide_react27.EllipsisVertical, {})
10448
+ }
10449
+ );
10450
+ }
10451
+ }
10452
+ ].filter(Boolean);
10453
+ const categories = data?.data || [];
10454
+ const onDelete = async (id) => {
10455
+ try {
10456
+ await remove({ url: `/categories/delete/${id}` });
10457
+ import_antd20.message.success("Category deleted successfully");
10458
+ reload();
10459
+ setDeleteCategory(null);
10460
+ } catch (error) {
10461
+ import_antd20.message.error(error.message || "Something went wrong");
10462
+ return error;
10463
+ }
10464
+ };
10465
+ return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
10466
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Modal2, {}),
10467
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
10468
+ ConfirmModal,
10469
+ {
10470
+ isOpen: !!deleteCategory,
10471
+ isLoading,
10472
+ onClose: () => setDeleteCategory(null),
10473
+ title: `Delete Category`,
10474
+ description: `Are you sure you want to delete "${deleteCategory?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
10475
+ confirmationWord: "delete",
10476
+ onSubmit: () => onDelete(deleteCategory?._id),
10477
+ children: null
10478
+ }
10479
+ ),
10480
+ /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
10481
+ TransactionViewComponent,
10482
+ {
10483
+ columns,
10484
+ data: categories,
10485
+ title: `Categories`,
10486
+ description: `Add or update categories`,
10487
+ index: true,
10488
+ createTitle: `Add Category`,
10489
+ onCreate: () => {
10490
+ navigate("create");
10491
+ }
10492
+ }
10493
+ )
10494
+ ] });
10495
+ }
10496
+ var Categories_default = Categories;
10497
+
10498
+ // src/components/categories/schema.ts
10499
+ var import_zod14 = require("zod");
10500
+ var createCategorySchema = import_zod14.z.object({
10501
+ name: import_zod14.z.string().min(2, { message: "Name must be at least 2 characters" })
10502
+ });
10503
+
10504
+ // src/components/categories/CategoryForm.tsx
10505
+ var import_react_hook_form17 = require("react-hook-form");
10506
+ var import_zod15 = require("@hookform/resolvers/zod");
10507
+ var import_antd21 = require("antd");
10508
+ var import_react48 = require("react");
10509
+ var import_jsx_runtime67 = require("react/jsx-runtime");
10510
+ function CategoryForm() {
10511
+ const { getQuery, navigate } = useApp_default();
10512
+ const id = getQuery("id");
10513
+ const isEdit = !!id;
10514
+ const { post, put, isLoading } = useApis_default();
10515
+ const { isLoading: isLoadingGet, get } = useApis_default();
10516
+ const methods = (0, import_react_hook_form17.useForm)({
10517
+ resolver: (0, import_zod15.zodResolver)(createCategorySchema),
10518
+ defaultValues: {
10519
+ name: ""
10520
+ },
10521
+ shouldUnregister: false
10522
+ });
10523
+ const { handleSubmit } = methods;
10524
+ const onSubmit = async (data) => {
10525
+ try {
10526
+ if (isEdit) {
10527
+ await put({
10528
+ url: `/categories/update/${id}`,
10529
+ body: data
10530
+ });
10531
+ } else {
10532
+ await post({
10533
+ url: "/categories/create",
10534
+ body: data
10535
+ });
10536
+ }
10537
+ import_antd21.message.success(`Category ${isEdit ? "updated" : "created"} successfully`);
10538
+ navigate(-1);
10539
+ } catch (error) {
10540
+ import_antd21.message.error(error?.message || "Something went wrong");
10541
+ }
10542
+ };
10543
+ const fetches = async () => {
10544
+ try {
10545
+ const res = await get({
10546
+ url: `/categories/get?id=${id}`
10547
+ });
10548
+ const data = res.data;
10549
+ methods.reset(data);
10550
+ } catch (error) {
10551
+ import_antd21.message.error(error?.message || "Something went wrong");
10552
+ }
10553
+ };
10554
+ (0, import_react48.useEffect)(() => {
10555
+ if (isEdit) {
10556
+ fetches();
10557
+ }
10558
+ }, [id]);
10559
+ return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
10560
+ Card,
10561
+ {
10562
+ className: "max-w-4xl mx-auto mt-10 relative",
10563
+ isLoading: isLoadingGet,
10564
+ loadingText: "Processing...",
10565
+ children: [
10566
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Card.Header, { children: [
10567
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Category` }),
10568
+ /* @__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` })
10569
+ ] }),
10570
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
10571
+ "form",
10572
+ {
10573
+ onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
10574
+ children: [
10575
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
10576
+ Fields_default.Input,
10577
+ {
10578
+ label: "Name",
10579
+ form: methods,
10580
+ name: "name",
10581
+ type: "text",
10582
+ placeholder: "Enter Category Name",
10583
+ required: true
10584
+ }
10585
+ ) }),
10586
+ /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
10587
+ Button,
10588
+ {
10589
+ isLoading,
10590
+ disabled: isLoading,
10591
+ type: "submit",
10592
+ className: "min-w-[100px]",
10593
+ variant: !isEdit ? "primary" : "warning",
10594
+ children: isEdit ? "Update" : "Add"
10595
+ }
10596
+ ) })
10597
+ ]
10598
+ }
10599
+ ) })
10600
+ ]
10601
+ }
10602
+ );
10603
+ }
10604
+ var CategoryForm_default = CategoryForm;
10605
+
10606
+ // src/components/categories/Feilds/Category.tsx
10607
+ var import_react_router_dom20 = require("react-router-dom");
10608
+ var import_jsx_runtime68 = require("react/jsx-runtime");
10609
+ function Category({
10610
+ name,
10611
+ label,
10612
+ placeholder,
10613
+ api,
10614
+ form,
10615
+ filter,
10616
+ v = 1,
10617
+ required,
10618
+ disabled
10619
+ }) {
10620
+ const { branchId } = (0, import_react_router_dom20.useParams)();
10621
+ return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
10622
+ Fields_default.SearchApi,
10623
+ {
10624
+ name,
10625
+ form,
10626
+ label,
10627
+ placeholder: placeholder || `Select ${name}`,
10628
+ api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
10629
+ queryKey: "search",
10630
+ filter,
10631
+ v,
10632
+ labelKey: "name",
10633
+ valueKey: "_id",
10634
+ required,
10635
+ disabled
10636
+ }
10637
+ ) });
10638
+ }
10639
+ var Category_default = Category;
10640
+
10641
+ // src/components/categories/Feilds/index.tsx
10642
+ var CategoryField = {
10643
+ Category: Category_default
10644
+ };
10645
+ var Feilds_default4 = CategoryField;
10646
+
10647
+ // src/components/products/Products.tsx
10648
+ var import_react_router_dom21 = require("react-router-dom");
10649
+ var import_lucide_react28 = require("lucide-react");
10650
+ var import_react49 = require("react");
10651
+ var import_antd22 = require("antd");
10652
+ var import_jsx_runtime69 = require("react/jsx-runtime");
10653
+ function Products({ v, url }) {
10654
+ const [deleteProduct, setDeleteProduct] = (0, import_react49.useState)(null);
10655
+ const { isLoading, remove } = useApis_default();
10656
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
10657
+ url: url || `/products/get`,
10658
+ v,
10659
+ dateFilter: false
10660
+ });
10661
+ const { Modal: Modal2 } = useModal();
10662
+ const navigate = (0, import_react_router_dom21.useNavigate)();
10663
+ const items = (data2) => [
10664
+ {
10665
+ label: `Edit Product`,
10666
+ icon: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_lucide_react28.FilePenLine, { size: 16 }),
10667
+ onClick: () => navigate(`update?id=${data2?._id}`)
10668
+ },
10669
+ {
10670
+ label: `Delete Product`,
10671
+ icon: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_lucide_react28.Trash2, { className: "text-red-500", size: 16 }),
10672
+ onClick: () => setDeleteProduct(data2)
10673
+ }
10674
+ ].filter(Boolean);
10675
+ const columns = [
10676
+ {
10677
+ accessorKey: "name",
10678
+ header: "Name",
10679
+ cell: ({ row }) => {
10680
+ const product = row.original;
10681
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: product?.name });
10682
+ }
10683
+ },
10684
+ {
10685
+ accessorKey: "category",
10686
+ header: "Category",
10687
+ cell: ({ row }) => {
10688
+ const product = row.original;
10689
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: product?.categoryData?.name || "N/A" });
10690
+ }
10691
+ },
10692
+ {
10693
+ accessorKey: "brand",
10694
+ header: "Brand",
10695
+ cell: ({ row }) => {
10696
+ const product = row.original;
10697
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { children: product?.brandData?.name || "N/A" });
10698
+ }
10699
+ },
10700
+ {
10701
+ accessorKey: "cost",
10702
+ header: "Cost",
10703
+ cell: ({ row }) => {
10704
+ const product = row.original;
10705
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("span", { children: [
10706
+ " ",
10707
+ product?.cost?.toLocaleString()
10708
+ ] });
10709
+ }
10710
+ },
10711
+ {
10712
+ accessorKey: "actions",
10713
+ header: "Actions",
10714
+ cell: ({ row }) => {
10715
+ const data2 = row.original;
10716
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
10717
+ Dropdown,
10718
+ {
10719
+ className: "cursor-pointer w-[150px]",
10720
+ items: items(data2),
10721
+ triggerMode: "hover",
10722
+ children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_lucide_react28.EllipsisVertical, {})
10723
+ }
10724
+ );
10725
+ }
10726
+ }
10727
+ ].filter(Boolean);
10728
+ const products = data?.data || [];
10729
+ const onDelete = async (id) => {
10730
+ try {
10731
+ await remove({ url: `/products/delete/${id}` });
10732
+ import_antd22.message.success("Product deleted successfully");
10733
+ reload();
10734
+ setDeleteProduct(null);
10735
+ } catch (error) {
10736
+ import_antd22.message.error(error.message || "Something went wrong");
10737
+ return error;
10738
+ }
10739
+ };
10740
+ return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
10741
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Modal2, {}),
10742
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
10743
+ ConfirmModal,
10744
+ {
10745
+ isOpen: !!deleteProduct,
10746
+ isLoading,
10747
+ onClose: () => setDeleteProduct(null),
10748
+ title: `Delete Product`,
10749
+ description: `Are you sure you want to delete "${deleteProduct?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
10750
+ confirmationWord: "delete",
10751
+ onSubmit: () => onDelete(deleteProduct?._id),
10752
+ children: null
10753
+ }
10754
+ ),
10755
+ /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
10756
+ TransactionViewComponent,
10757
+ {
10758
+ columns,
10759
+ data: products,
10760
+ title: `Products`,
10761
+ description: `Add or update products`,
10762
+ index: true,
10763
+ createTitle: `Add Product`,
10764
+ onCreate: () => {
10765
+ navigate("create");
10766
+ }
10767
+ }
10768
+ )
10769
+ ] });
10770
+ }
10771
+ var Products_default = Products;
10772
+
10773
+ // src/components/products/schema.ts
10774
+ var import_zod16 = require("zod");
10775
+ var createProductSchema = import_zod16.z.object({
10776
+ name: import_zod16.z.string().min(2, { message: "Name must be at least 2 characters" }),
10777
+ category: import_zod16.z.string().optional(),
10778
+ brand: import_zod16.z.string().optional(),
10779
+ cost: import_zod16.z.number({ message: "Cost is required" }).min(0)
10780
+ });
10781
+
10782
+ // src/components/products/ProductForm.tsx
10783
+ var import_react_hook_form18 = require("react-hook-form");
10784
+ var import_zod17 = require("@hookform/resolvers/zod");
10785
+ var import_antd23 = require("antd");
10786
+ var import_react50 = require("react");
10787
+ var import_jsx_runtime70 = require("react/jsx-runtime");
10788
+ function ProductForm() {
10789
+ const { getQuery, navigate } = useApp_default();
10790
+ const id = getQuery("id");
10791
+ const isEdit = !!id;
10792
+ const { post, put, isLoading } = useApis_default();
10793
+ const { isLoading: isLoadingGet, get } = useApis_default();
10794
+ const methods = (0, import_react_hook_form18.useForm)({
10795
+ resolver: (0, import_zod17.zodResolver)(createProductSchema),
10796
+ defaultValues: {
10797
+ name: "",
10798
+ category: void 0,
10799
+ brand: void 0,
10800
+ cost: 0
10801
+ },
10802
+ shouldUnregister: false
10803
+ });
10804
+ const { handleSubmit } = methods;
10805
+ const onSubmit = async (data) => {
10806
+ try {
10807
+ if (isEdit) {
10808
+ await put({
10809
+ url: `/products/update/${id}`,
10810
+ body: data
10811
+ });
10812
+ } else {
10813
+ await post({
10814
+ url: "/products/create",
10815
+ body: data
10816
+ });
10817
+ }
10818
+ import_antd23.message.success(`Product ${isEdit ? "updated" : "created"} successfully`);
10819
+ navigate(-1);
10820
+ } catch (error) {
10821
+ import_antd23.message.error(error?.message || "Something went wrong");
10822
+ }
10823
+ };
10824
+ const fetches = async () => {
10825
+ try {
10826
+ const res = await get({
10827
+ url: `/products/get?id=${id}`
10828
+ });
10829
+ const data = res.data;
10830
+ methods.reset(data);
10831
+ } catch (error) {
10832
+ import_antd23.message.error(error?.message || "Something went wrong");
10833
+ }
10834
+ };
10835
+ (0, import_react50.useEffect)(() => {
10836
+ if (isEdit) {
10837
+ fetches();
10838
+ }
10839
+ }, [id]);
10840
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
10841
+ Card,
10842
+ {
10843
+ className: "max-w-4xl mx-auto mt-10 relative",
10844
+ isLoading: isLoadingGet,
10845
+ loadingText: "Processing...",
10846
+ children: [
10847
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Card.Header, { children: [
10848
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Product` }),
10849
+ /* @__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` })
10850
+ ] }),
10851
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
10852
+ "form",
10853
+ {
10854
+ onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
10855
+ children: [
10856
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
10857
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
10858
+ Fields_default.Input,
10859
+ {
10860
+ label: "Name",
10861
+ form: methods,
10862
+ name: "name",
10863
+ type: "text",
10864
+ placeholder: "Enter Product Name",
10865
+ required: true
10866
+ }
10867
+ ),
10868
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
10869
+ Fields_default.Input,
10870
+ {
10871
+ label: "Cost",
10872
+ form: methods,
10873
+ name: "cost",
10874
+ type: "number",
10875
+ placeholder: "0.00",
10876
+ required: true
10877
+ }
10878
+ ),
10879
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
10880
+ Feilds_default4.Category,
10881
+ {
10882
+ label: "Category",
10883
+ form: methods,
10884
+ name: "category",
10885
+ api: "/categories/get"
10886
+ }
10887
+ ),
10888
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
10889
+ Feilds_default3.Brand,
10890
+ {
10891
+ label: "Brand",
10892
+ form: methods,
10893
+ name: "brand",
10894
+ api: "/brands/get"
10895
+ }
10896
+ )
10897
+ ] }),
10898
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
10899
+ Button,
10900
+ {
10901
+ isLoading,
10902
+ disabled: isLoading,
10903
+ type: "submit",
10904
+ className: "min-w-[100px]",
10905
+ variant: !isEdit ? "primary" : "warning",
10906
+ children: isEdit ? "Update" : "Add"
10907
+ }
10908
+ ) })
10909
+ ]
10910
+ }
10911
+ ) })
10912
+ ]
10913
+ }
10914
+ );
10915
+ }
10916
+ var ProductForm_default = ProductForm;
10917
+
10918
+ // src/components/products/Feilds/Product.tsx
10919
+ var import_react_router_dom22 = require("react-router-dom");
10920
+ var import_jsx_runtime71 = require("react/jsx-runtime");
10921
+ function Product({
10922
+ name,
10923
+ label,
10924
+ placeholder,
10925
+ api,
10926
+ form,
10927
+ filter,
10928
+ v = 1,
10929
+ required,
10930
+ disabled,
10931
+ onChange,
10932
+ obj
10933
+ }) {
10934
+ const { branchId } = (0, import_react_router_dom22.useParams)();
10935
+ return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
10936
+ Fields_default.SearchApi,
10937
+ {
10938
+ name,
10939
+ form,
10940
+ label,
10941
+ onChange,
10942
+ placeholder: placeholder || `Select ${name}`,
10943
+ api: `${api}${branchId ? `?branch=${branchId}` : ""}`,
10944
+ queryKey: "search",
10945
+ filter,
10946
+ v,
10947
+ labelKey: "name",
10948
+ valueKey: "_id",
10949
+ required,
10950
+ disabled,
10951
+ obj
10952
+ }
10953
+ ) });
10954
+ }
10955
+ var Product_default = Product;
10956
+
10957
+ // src/components/products/Feilds/index.tsx
10958
+ var ProductField = {
10959
+ Product: Product_default
10960
+ };
10961
+ var Feilds_default5 = ProductField;
10962
+
10963
+ // src/components/packs/Packs.tsx
10964
+ var import_react_router_dom23 = require("react-router-dom");
10965
+ var import_lucide_react29 = require("lucide-react");
10966
+ var import_react51 = require("react");
10967
+ var import_antd24 = require("antd");
10968
+ var import_jsx_runtime72 = require("react/jsx-runtime");
10969
+ function Packs({ v, url }) {
10970
+ const [deletePack, setDeletePack] = (0, import_react51.useState)(null);
10971
+ const { isLoading, remove } = useApis_default();
10972
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
10973
+ url: url || `/packs/get`,
10974
+ v,
10975
+ dateFilter: false
10976
+ });
10977
+ const { Modal: Modal2 } = useModal();
10978
+ const navigate = (0, import_react_router_dom23.useNavigate)();
10979
+ const items = (data2) => [
10980
+ {
10981
+ label: `Edit Pack`,
10982
+ icon: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_lucide_react29.FilePenLine, { size: 16 }),
10983
+ onClick: () => navigate(`update?id=${data2?._id}`)
10984
+ },
10985
+ {
10986
+ label: `Delete Pack`,
10987
+ icon: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_lucide_react29.Trash2, { className: "text-red-500", size: 16 }),
10988
+ onClick: () => setDeletePack(data2)
10989
+ }
10990
+ ].filter(Boolean);
10991
+ const columns = [
10992
+ {
10993
+ accessorKey: "name",
10994
+ header: "Name",
10995
+ cell: ({ row }) => {
10996
+ const pack = row.original;
10997
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { children: pack?.name });
10998
+ }
10999
+ },
11000
+ {
11001
+ accessorKey: "type",
11002
+ header: "Type",
11003
+ cell: ({ row }) => {
11004
+ const pack = row.original;
11005
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "capitalize", children: pack?.type });
11006
+ }
11007
+ },
11008
+ {
11009
+ accessorKey: "products",
11010
+ header: "Products Count",
11011
+ cell: ({ row }) => {
11012
+ const pack = row.original;
11013
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("span", { children: [
11014
+ pack?.products?.length || 0,
11015
+ " Products"
11016
+ ] });
11017
+ }
11018
+ },
11019
+ {
11020
+ accessorKey: "actions",
11021
+ header: "Actions",
11022
+ cell: ({ row }) => {
11023
+ const data2 = row.original;
11024
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
11025
+ Dropdown,
11026
+ {
11027
+ className: "cursor-pointer w-[150px]",
11028
+ items: items(data2),
11029
+ triggerMode: "hover",
11030
+ children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_lucide_react29.EllipsisVertical, {})
11031
+ }
11032
+ );
11033
+ }
11034
+ }
11035
+ ].filter(Boolean);
11036
+ const packs = data?.data || [];
11037
+ const onDelete = async (id) => {
11038
+ try {
11039
+ await remove({ url: `/packs/delete/${id}` });
11040
+ import_antd24.message.success("Pack deleted successfully");
11041
+ reload();
11042
+ setDeletePack(null);
11043
+ } catch (error) {
11044
+ import_antd24.message.error(error.message || "Something went wrong");
11045
+ return error;
11046
+ }
11047
+ };
11048
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
11049
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Modal2, {}),
11050
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
11051
+ ConfirmModal,
11052
+ {
11053
+ isOpen: !!deletePack,
11054
+ isLoading,
11055
+ onClose: () => setDeletePack(null),
11056
+ title: `Delete Pack`,
11057
+ description: `Are you sure you want to delete "${deletePack?.name}"? This action cannot be undone. and Please type "delete" to confirm.`,
11058
+ confirmationWord: "delete",
11059
+ onSubmit: () => onDelete(deletePack?._id),
11060
+ children: null
11061
+ }
11062
+ ),
11063
+ /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
11064
+ TransactionViewComponent,
11065
+ {
11066
+ columns,
11067
+ data: packs,
11068
+ title: `Packs`,
11069
+ description: `Add or update product packs`,
11070
+ index: true,
11071
+ createTitle: `Add Pack`,
11072
+ onCreate: () => {
11073
+ navigate("create");
11074
+ }
11075
+ }
11076
+ )
11077
+ ] });
11078
+ }
11079
+ var Packs_default = Packs;
11080
+
11081
+ // src/components/packs/schema.ts
11082
+ var import_zod18 = require("zod");
11083
+ var packProductItemSchema = import_zod18.z.object({
11084
+ product: import_zod18.z.string({ message: "Product ID is required" }),
11085
+ cost: import_zod18.z.number().min(0, "Cost must be a positive number"),
11086
+ quantity: import_zod18.z.number().min(1, "Quantity must be at least 1"),
11087
+ index: import_zod18.z.number({ message: "Index is required" }),
11088
+ productData: import_zod18.z.any().optional()
11089
+ });
11090
+ var packTypes = import_zod18.z.enum(Enums_default.packTypes);
11091
+ var createPackSchema = import_zod18.z.object({
11092
+ type: packTypes,
11093
+ name: import_zod18.z.string().min(2, { message: "Name must be at least 2 characters" }),
11094
+ products: import_zod18.z.array(packProductItemSchema).min(1, "At least one product is required"),
11095
+ tempProduct: import_zod18.z.string().optional(),
11096
+ tempQty: import_zod18.z.number().optional(),
11097
+ tempCost: import_zod18.z.number().optional(),
11098
+ tempData: import_zod18.z.record(import_zod18.z.string(), import_zod18.z.any()).optional()
11099
+ });
11100
+
11101
+ // src/components/packs/PackForm.tsx
11102
+ var import_react_hook_form19 = require("react-hook-form");
11103
+ var import_zod19 = require("@hookform/resolvers/zod");
11104
+ var import_antd25 = require("antd");
11105
+ var import_react52 = require("react");
11106
+ var import_lucide_react30 = require("lucide-react");
11107
+ var import_jsx_runtime73 = require("react/jsx-runtime");
11108
+ function PackForm() {
11109
+ const { getQuery, navigate } = useApp_default();
11110
+ const id = getQuery("id");
11111
+ const isEdit = !!id;
11112
+ const { post, put, isLoading } = useApis_default();
11113
+ const { isLoading: isLoadingGet, get } = useApis_default();
11114
+ const methods = (0, import_react_hook_form19.useForm)({
11115
+ resolver: (0, import_zod19.zodResolver)(createPackSchema),
11116
+ defaultValues: {
11117
+ name: "",
11118
+ type: "boxes",
11119
+ products: [],
11120
+ tempQty: 1,
11121
+ tempCost: 0
11122
+ },
11123
+ shouldUnregister: false
11124
+ });
11125
+ const currentProduct = methods.watch("tempData");
11126
+ const { handleSubmit, control, watch, setValue, getValues } = methods;
11127
+ const { fields, append, remove } = (0, import_react_hook_form19.useFieldArray)({
11128
+ control,
11129
+ name: "products"
11130
+ });
11131
+ const onAddProduct = () => {
11132
+ const val = getValues("tempProduct");
11133
+ const qty = getValues("tempQty") || 1;
11134
+ const cost = getValues("tempCost") || 0;
11135
+ if (val && currentProduct) {
11136
+ append({
11137
+ product: val,
11138
+ cost: Number(cost),
11139
+ quantity: Number(qty),
11140
+ index: fields.length,
11141
+ productData: currentProduct
11142
+ });
11143
+ setValue("tempProduct", "");
11144
+ setValue("tempQty", 1);
11145
+ setValue("tempCost", 0);
11146
+ } else {
11147
+ import_antd25.message.warning("Please select a product first");
11148
+ }
11149
+ };
11150
+ const onSubmit = async (data) => {
11151
+ try {
11152
+ const formattedData = {
11153
+ ...data,
11154
+ products: data.products.map((p, i) => ({ ...p, index: i }))
11155
+ };
11156
+ if (isEdit) {
11157
+ await put({
11158
+ url: `/packs/update/${id}`,
11159
+ body: formattedData
11160
+ });
11161
+ } else {
11162
+ await post({
11163
+ url: "/packs/create",
11164
+ body: formattedData
11165
+ });
11166
+ }
11167
+ import_antd25.message.success(`Pack ${isEdit ? "updated" : "created"} successfully`);
11168
+ navigate(-1);
11169
+ } catch (error) {
11170
+ import_antd25.message.error(error?.message || "Something went wrong");
11171
+ }
11172
+ };
11173
+ const fetches = async () => {
11174
+ try {
11175
+ const res = await get({
11176
+ url: `/packs/get?id=${id}`
11177
+ });
11178
+ const data = res.data;
11179
+ data.products = data.products.map((p, index) => ({
11180
+ ...p,
11181
+ tempData: p?.productData,
11182
+ index
11183
+ }));
11184
+ methods.reset(data);
11185
+ } catch (error) {
11186
+ import_antd25.message.error(error?.message || "Something went wrong");
11187
+ }
11188
+ };
11189
+ (0, import_react52.useEffect)(() => {
11190
+ if (isEdit) {
11191
+ fetches();
11192
+ }
11193
+ }, [id]);
11194
+ (0, import_react52.useEffect)(() => {
11195
+ if (currentProduct) {
11196
+ setValue("tempCost", currentProduct.cost || 0);
11197
+ }
11198
+ }, [currentProduct]);
11199
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
11200
+ Card,
11201
+ {
11202
+ className: "max-w-5xl mx-auto mt-10 relative",
11203
+ isLoading: isLoadingGet,
11204
+ loadingText: "Processing...",
11205
+ children: [
11206
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(Card.Header, { children: [
11207
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Pack` }),
11208
+ /* @__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` })
11209
+ ] }),
11210
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
11211
+ "form",
11212
+ {
11213
+ onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
11214
+ children: [
11215
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4 mb-8", children: [
11216
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11217
+ Fields_default.Input,
11218
+ {
11219
+ label: "Pack Name",
11220
+ form: methods,
11221
+ name: "name",
11222
+ type: "text",
11223
+ placeholder: "e.g. Family Box A",
11224
+ required: true
11225
+ }
11226
+ ),
11227
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11228
+ Fields_default.Select,
11229
+ {
11230
+ label: "Pack Type",
11231
+ form: methods,
11232
+ name: "type",
11233
+ enumName: "packTypes",
11234
+ required: true
11235
+ }
11236
+ )
11237
+ ] }),
11238
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "border rounded-lg p-4 bg-gray-50/50 dark:bg-gray-800/20", children: [
11239
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("h3", { className: "text-lg font-semibold mb-4", children: "Products in Pack" }),
11240
+ /* @__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: [
11241
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-12 sm:col-span-5", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11242
+ Feilds_default5.Product,
11243
+ {
11244
+ label: "Find Product",
11245
+ form: methods,
11246
+ name: "tempProduct",
11247
+ api: "/products/get",
11248
+ obj: "tempData"
11249
+ }
11250
+ ) }),
11251
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-4 sm:col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11252
+ Fields_default.Input,
11253
+ {
11254
+ label: "Qty",
11255
+ form: methods,
11256
+ name: "tempQty",
11257
+ type: "number",
11258
+ placeholder: "1"
11259
+ }
11260
+ ) }),
11261
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-5 sm:col-span-3", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11262
+ Fields_default.Input,
11263
+ {
11264
+ label: "Cost",
11265
+ form: methods,
11266
+ name: "tempCost",
11267
+ type: "number",
11268
+ placeholder: "0.00"
11269
+ }
11270
+ ) }),
11271
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "col-span-3 sm:col-span-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11272
+ Button,
11273
+ {
11274
+ type: "button",
11275
+ onClick: onAddProduct,
11276
+ className: "w-full h-[40px]",
11277
+ icon: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_lucide_react30.Plus, { size: 16 }),
11278
+ children: "Add"
11279
+ }
11280
+ ) })
11281
+ ] }) }),
11282
+ /* @__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: [
11283
+ /* @__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: [
11284
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500", children: "Product" }),
11285
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-24", children: "Qty" }),
11286
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("th", { className: "px-3 py-2 text-xs font-bold uppercase text-gray-500 w-32", children: "Cost" }),
11287
+ /* @__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" }),
11288
+ /* @__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" })
11289
+ ] }) }),
11290
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("tbody", { className: "divide-y divide-gray-100 dark:divide-gray-800 bg-white dark:bg-gray-900", children: [
11291
+ fields.map((field, index) => /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
11292
+ "tr",
11293
+ {
11294
+ className: "hover:bg-gray-50/50 dark:hover:bg-gray-800/50 transition-colors",
11295
+ children: [
11296
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("td", { className: "px-3 py-2", children: [
11297
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: field.productData?.name || "Product" }),
11298
+ field.productData?.sku && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("p", { className: "text-[10px] text-gray-500", children: [
11299
+ "SKU: ",
11300
+ field.productData?.sku
11301
+ ] })
11302
+ ] }),
11303
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11304
+ Fields_default.Input,
11305
+ {
11306
+ form: methods,
11307
+ name: `products.${index}.quantity`,
11308
+ type: "number",
11309
+ placeholder: "1",
11310
+ required: true,
11311
+ className: "h-8 py-1!"
11312
+ }
11313
+ ) }),
11314
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11315
+ Fields_default.Input,
11316
+ {
11317
+ form: methods,
11318
+ name: `products.${index}.cost`,
11319
+ type: "number",
11320
+ placeholder: "0.00",
11321
+ required: true,
11322
+ className: "h-8 py-1!"
11323
+ }
11324
+ ) }),
11325
+ /* @__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() }) }),
11326
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("td", { className: "px-3 py-2 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11327
+ Button,
11328
+ {
11329
+ type: "button",
11330
+ variant: "ghost",
11331
+ size: "sm",
11332
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50 p-1 h-8 w-8",
11333
+ onClick: () => remove(index),
11334
+ children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_lucide_react30.Trash2, { size: 16 })
11335
+ }
11336
+ ) })
11337
+ ]
11338
+ },
11339
+ field.id
11340
+ )),
11341
+ 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." }) }) })
11342
+ ] })
11343
+ ] }) }),
11344
+ /* @__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: [
11345
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
11346
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Lines" }),
11347
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-lg font-bold text-blue-600", children: watch("products")?.length || 0 })
11348
+ ] }),
11349
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
11350
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Quantity" }),
11351
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-lg font-bold text-indigo-600", children: watch("products")?.reduce(
11352
+ (acc, curr) => acc + (Number(curr.quantity) || 0),
11353
+ 0
11354
+ ) })
11355
+ ] }),
11356
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "bg-white dark:bg-gray-900 p-3 rounded-lg border shadow-sm", children: [
11357
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "text-[10px] text-gray-500 uppercase font-bold mb-0.5", children: "Total Cost" }),
11358
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("p", { className: "text-lg font-bold text-emerald-600", children: [
11359
+ watch("products")?.reduce(
11360
+ (acc, curr) => acc + (Number(curr.quantity) || 0) * (Number(curr.cost) || 0),
11361
+ 0
11362
+ ).toLocaleString(),
11363
+ " ",
11364
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "text-[10px] font-normal text-gray-400", children: "USD" })
11365
+ ] })
11366
+ ] })
11367
+ ] })
11368
+ ] }),
11369
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("footer", { className: "flex justify-end mt-8", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
11370
+ Button,
11371
+ {
11372
+ isLoading,
11373
+ disabled: isLoading,
11374
+ type: "submit",
11375
+ className: "min-w-[120px]",
11376
+ variant: !isEdit ? "primary" : "warning",
11377
+ children: isEdit ? "Update Pack" : "Create Pack"
11378
+ }
11379
+ ) })
11380
+ ]
11381
+ }
11382
+ ) })
11383
+ ]
11384
+ }
11385
+ );
11386
+ }
11387
+ var PackForm_default = PackForm;
11388
+
11389
+ // src/components/packs/Feilds/Pack.tsx
11390
+ var import_jsx_runtime74 = require("react/jsx-runtime");
11391
+ function Pack({
11392
+ name,
11393
+ label,
11394
+ placeholder = "Select Pack",
11395
+ api,
11396
+ form,
11397
+ filter,
11398
+ v,
11399
+ required,
11400
+ disabled
11401
+ }) {
11402
+ return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
11403
+ Fields_default.SearchApi,
11404
+ {
11405
+ label,
11406
+ form,
11407
+ name,
11408
+ api,
11409
+ placeholder,
11410
+ queryKey: "name",
11411
+ labelKey: "name",
11412
+ valueKey: "_id",
11413
+ filter,
11414
+ v,
11415
+ required,
11416
+ disabled
11417
+ }
11418
+ );
11419
+ }
11420
+ var Pack_default = { Pack };
11421
+
10132
11422
  // src/components/ErrorPage/ErrorPage.tsx
10133
- var import_jsx_runtime63 = require("react/jsx-runtime");
11423
+ var import_jsx_runtime75 = require("react/jsx-runtime");
10134
11424
  var ErrorPageBase = ({
10135
11425
  title,
10136
- message: message16,
11426
+ message: message24,
10137
11427
  statusCode,
10138
11428
  action,
10139
11429
  className = ""
10140
11430
  }) => {
10141
- return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
11431
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
10142
11432
  "div",
10143
11433
  {
10144
11434
  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, import_jsx_runtime63.jsxs)("div", { className: "relative flex flex-col items-center justify-center w-full max-w-2xl text-center", children: [
10146
- statusCode && /* @__PURE__ */ (0, import_jsx_runtime63.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_runtime63.jsx)("span", { className: "text-[12rem] sm:text-[16rem] md:text-[20rem] font-bold leading-none tracking-tighter", children: statusCode }) }),
10147
- /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "relative z-10 space-y-6", children: [
10148
- statusCode && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("h2", { className: "text-xl md:text-2xl font-semibold text-zinc-500 dark:text-zinc-400", children: [
11435
+ 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: [
11436
+ 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 }) }),
11437
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "relative z-10 space-y-6", children: [
11438
+ 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
11439
  "Error ",
10150
11440
  statusCode
10151
11441
  ] }),
10152
- title && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
10153
- message16 && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "text-lg md:text-xl text-zinc-600 dark:text-zinc-400 max-w-md mx-auto", children: message16 }),
10154
- action && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: "pt-8", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
11442
+ title && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
11443
+ 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 }),
11444
+ action && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("div", { className: "pt-8", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
10155
11445
  "button",
10156
11446
  {
10157
11447
  onClick: action.onClick,
@@ -10167,9 +11457,9 @@ var ErrorPageBase = ({
10167
11457
  };
10168
11458
 
10169
11459
  // src/components/ErrorPage/ErrorPage.500.tsx
10170
- var import_jsx_runtime64 = require("react/jsx-runtime");
11460
+ var import_jsx_runtime76 = require("react/jsx-runtime");
10171
11461
  var ErrorPage500 = (props) => {
10172
- return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
11462
+ return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
10173
11463
  ErrorPageBase,
10174
11464
  {
10175
11465
  statusCode: 500,
@@ -10182,9 +11472,9 @@ var ErrorPage500 = (props) => {
10182
11472
  };
10183
11473
 
10184
11474
  // src/components/ErrorPage/ErrorPage.404.tsx
10185
- var import_jsx_runtime65 = require("react/jsx-runtime");
11475
+ var import_jsx_runtime77 = require("react/jsx-runtime");
10186
11476
  var ErrorPage404 = (props) => {
10187
- return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
11477
+ return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
10188
11478
  ErrorPageBase,
10189
11479
  {
10190
11480
  statusCode: 404,
@@ -10197,9 +11487,9 @@ var ErrorPage404 = (props) => {
10197
11487
  };
10198
11488
 
10199
11489
  // src/components/ErrorPage/ErrorPage.401.tsx
10200
- var import_jsx_runtime66 = require("react/jsx-runtime");
11490
+ var import_jsx_runtime78 = require("react/jsx-runtime");
10201
11491
  var ErrorPage401 = (props) => {
10202
- return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
11492
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
10203
11493
  ErrorPageBase,
10204
11494
  {
10205
11495
  statusCode: 401,
@@ -10212,9 +11502,9 @@ var ErrorPage401 = (props) => {
10212
11502
  };
10213
11503
 
10214
11504
  // src/components/ErrorPage/ErrorPage.400.tsx
10215
- var import_jsx_runtime67 = require("react/jsx-runtime");
11505
+ var import_jsx_runtime79 = require("react/jsx-runtime");
10216
11506
  var ErrorPage400 = (props) => {
10217
- return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
11507
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
10218
11508
  ErrorPageBase,
10219
11509
  {
10220
11510
  statusCode: 400,
@@ -10240,7 +11530,10 @@ var ErrorPage = Object.assign(ErrorPageBase, {
10240
11530
  Accounts,
10241
11531
  AdminProtectedRoute,
10242
11532
  Badge,
11533
+ BrandField,
11534
+ BrandForm,
10243
11535
  Branding,
11536
+ Brands,
10244
11537
  Breadcrumbs,
10245
11538
  Button,
10246
11539
  Card,
@@ -10249,7 +11542,10 @@ var ErrorPage = Object.assign(ErrorPageBase, {
10249
11542
  CardFooter,
10250
11543
  CardHeader,
10251
11544
  CardTitle,
11545
+ Categories,
10252
11546
  CategoryCard,
11547
+ CategoryField,
11548
+ CategoryForm,
10253
11549
  ClassicSpin,
10254
11550
  CodeBlock,
10255
11551
  ConfirmModal,
@@ -10267,10 +11563,16 @@ var ErrorPage = Object.assign(ErrorPageBase, {
10267
11563
  LoadingSpin,
10268
11564
  Modal,
10269
11565
  OverlaySpin,
11566
+ PackField,
11567
+ PackForm,
11568
+ Packs,
10270
11569
  PageA4,
10271
11570
  PageHeader,
10272
11571
  PhoneInput,
10273
11572
  PostTable,
11573
+ ProductField,
11574
+ ProductForm,
11575
+ Products,
10274
11576
  ProfileCard,
10275
11577
  ProfileDropdown,
10276
11578
  ProfilePage,
@@ -10301,10 +11603,16 @@ var ErrorPage = Object.assign(ErrorPageBase, {
10301
11603
  Wallets,
10302
11604
  WarqadProvider,
10303
11605
  createAccountSchema,
11606
+ createBrandSchema,
11607
+ createCategorySchema,
11608
+ createPackSchema,
11609
+ createProductSchema,
10304
11610
  createUserSchema,
10305
11611
  createWalletSchema,
10306
11612
  generatePdf,
10307
11613
  linkUserSchema,
11614
+ packProductItemSchema,
11615
+ packTypes,
10308
11616
  resetPasswordSchema,
10309
11617
  storage,
10310
11618
  updateUserEmailSchema,