warqadui 0.0.94 → 0.0.96

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
@@ -63,6 +63,8 @@ __export(index_exports, {
63
63
  Guard: () => Guard,
64
64
  InfoGrid: () => InfoGrid,
65
65
  Input: () => Input,
66
+ JournalForm: () => JournalForm_default,
67
+ Journals: () => Journals_default,
66
68
  LinkUser: () => linkUser_default,
67
69
  LoadingBox: () => LoadingBox,
68
70
  LoadingSpin: () => LoadingSpin,
@@ -115,6 +117,7 @@ __export(index_exports, {
115
117
  createUserSchema: () => createUserSchema,
116
118
  createWalletSchema: () => createWalletSchema,
117
119
  generatePdf: () => generatePdf,
120
+ journalSchema: () => journalSchema,
118
121
  linkUserSchema: () => linkUserSchema,
119
122
  packProductItemSchema: () => packProductItemSchema,
120
123
  packTypes: () => packTypes,
@@ -435,12 +438,21 @@ var useTheme = () => {
435
438
  var Enums = {
436
439
  roles: ["admin", "staff"],
437
440
  sex: ["male", "female"],
438
- accountTypes: ["employee", "supplier", "customer", "amaanah"],
441
+ accountTypes: [
442
+ "employee",
443
+ "supplier",
444
+ "customer",
445
+ "amaanah",
446
+ "account"
447
+ ],
439
448
  verificationTypes: ["email_verification", "password_reset"],
440
449
  auditActions: ["create", "update", "delete", "login", "logout"],
441
450
  walletTypes: ["bank", "cash", "mobile"],
442
451
  currencies: ["USD", "TZS", "KES", "CNY"],
443
- packTypes: ["pressure", "bag", "boxes"]
452
+ packTypes: ["pressure", "bag", "boxes"],
453
+ journalTypes: ["journal"],
454
+ viaTypes: ["direct", "via account"],
455
+ actionTypes: ["credit", "debit"]
444
456
  };
445
457
  var Enums_default = Enums;
446
458
 
@@ -1465,13 +1477,13 @@ var Input = (0, import_react10.forwardRef)(
1465
1477
  }
1466
1478
  }
1467
1479
  }, [props.value, name, form]);
1468
- let message24 = error;
1480
+ let message26 = error;
1469
1481
  if (form && name) {
1470
1482
  const {
1471
1483
  formState: { errors }
1472
1484
  } = form;
1473
1485
  const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
1474
- message24 = errorObj?.message;
1486
+ message26 = errorObj?.message;
1475
1487
  }
1476
1488
  const watchedValue = form?.watch(name);
1477
1489
  (0, import_react10.useEffect)(() => {
@@ -1540,7 +1552,7 @@ var Input = (0, import_react10.forwardRef)(
1540
1552
  }
1541
1553
  )
1542
1554
  ] }),
1543
- message24 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
1555
+ message26 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
1544
1556
  ]
1545
1557
  }
1546
1558
  );
@@ -1863,7 +1875,7 @@ var PhoneInput = (0, import_react13.forwardRef)(
1863
1875
  const [isFocused, setIsFocused] = (0, import_react13.useState)(false);
1864
1876
  const { theme } = useWarqadConfig();
1865
1877
  const primaryColor = theme?.primaryColor;
1866
- let message24 = error;
1878
+ let message26 = error;
1867
1879
  if (form && name) {
1868
1880
  const {
1869
1881
  formState: { errors }
@@ -1873,7 +1885,7 @@ var PhoneInput = (0, import_react13.forwardRef)(
1873
1885
  for (const part of nameParts) {
1874
1886
  currentError = currentError?.[part];
1875
1887
  }
1876
- message24 = currentError?.message || message24;
1888
+ message26 = currentError?.message || message26;
1877
1889
  }
1878
1890
  const renderInput = (onChangeHandler, currentValue) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `space-y-2 group relative ${containerClassName}`, children: [
1879
1891
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
@@ -1924,7 +1936,7 @@ var PhoneInput = (0, import_react13.forwardRef)(
1924
1936
  }
1925
1937
  )
1926
1938
  ] }),
1927
- message24 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
1939
+ message26 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
1928
1940
  ] });
1929
1941
  if (form && name) {
1930
1942
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
@@ -1968,7 +1980,8 @@ var Select = (0, import_react14.forwardRef)((props, ref) => {
1968
1980
  children,
1969
1981
  options: initialOptions = [],
1970
1982
  enum: enumData,
1971
- enumName
1983
+ enumName,
1984
+ ...rest
1972
1985
  } = props;
1973
1986
  const options = (0, import_react14.useMemo)(() => {
1974
1987
  if (initialOptions.length > 0) return initialOptions;
@@ -2005,7 +2018,7 @@ var Select = (0, import_react14.forwardRef)((props, ref) => {
2005
2018
  }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2006
2019
  SelectRoot,
2007
2020
  {
2008
- ...props,
2021
+ ...rest,
2009
2022
  options,
2010
2023
  currentValue: formValue,
2011
2024
  onChangeHandler: (val) => {
@@ -2022,7 +2035,7 @@ var Select = (0, import_react14.forwardRef)((props, ref) => {
2022
2035
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2023
2036
  SelectRoot,
2024
2037
  {
2025
- ...props,
2038
+ ...rest,
2026
2039
  options,
2027
2040
  currentValue: value,
2028
2041
  onChangeHandler: onChange || (() => {
@@ -2050,6 +2063,8 @@ var SelectRoot = ({
2050
2063
  disabled,
2051
2064
  id,
2052
2065
  className = "",
2066
+ enum: enumData,
2067
+ enumName,
2053
2068
  ...props
2054
2069
  }) => {
2055
2070
  const [isOpen, setIsOpen] = (0, import_react14.useState)(false);
@@ -2094,7 +2109,7 @@ var SelectRoot = ({
2094
2109
  document.addEventListener("mousedown", handleClickOutside);
2095
2110
  return () => document.removeEventListener("mousedown", handleClickOutside);
2096
2111
  }, [fieldInternalProps]);
2097
- let message24 = error;
2112
+ let message26 = error;
2098
2113
  if (form && name) {
2099
2114
  const {
2100
2115
  formState: { errors }
@@ -2104,7 +2119,7 @@ var SelectRoot = ({
2104
2119
  for (const part of nameParts) {
2105
2120
  currentError = currentError?.[part];
2106
2121
  }
2107
- message24 = currentError?.message || message24;
2122
+ message26 = currentError?.message || message26;
2108
2123
  }
2109
2124
  const allOptions = initialOptions?.length ? initialOptions : registeredOptions;
2110
2125
  const valueCtx = {
@@ -2165,7 +2180,7 @@ var SelectRoot = ({
2165
2180
  String(opt.value) || index
2166
2181
  )) })
2167
2182
  ] }),
2168
- message24 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
2183
+ message26 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
2169
2184
  ]
2170
2185
  }
2171
2186
  ) });
@@ -2401,13 +2416,13 @@ var Textarea = (0, import_react15.forwardRef)(
2401
2416
  const [isFocused, setIsFocused] = (0, import_react15.useState)(false);
2402
2417
  const { theme } = useWarqadConfig();
2403
2418
  const primaryColor = theme?.primaryColor;
2404
- let message24 = error;
2419
+ let message26 = error;
2405
2420
  if (form && name) {
2406
2421
  const {
2407
2422
  formState: { errors }
2408
2423
  } = form;
2409
2424
  const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
2410
- message24 = errorObj?.message;
2425
+ message26 = errorObj?.message;
2411
2426
  }
2412
2427
  const renderInput = (inputProps, ref2) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: `space-y-2 group w-full! relative ${containerClassName}`, children: [
2413
2428
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
@@ -2445,7 +2460,7 @@ var Textarea = (0, import_react15.forwardRef)(
2445
2460
  }
2446
2461
  }
2447
2462
  ) }),
2448
- message24 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
2463
+ message26 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
2449
2464
  ] });
2450
2465
  (0, import_react15.useEffect)(() => {
2451
2466
  if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
@@ -2764,7 +2779,7 @@ var SearchApiRoot = ({
2764
2779
  const filteredOptions = options.filter(
2765
2780
  (option) => !filter.includes(getOptionValue(option))
2766
2781
  );
2767
- let message24 = error || errorMessage;
2782
+ let message26 = error || errorMessage;
2768
2783
  if (form && name) {
2769
2784
  const {
2770
2785
  formState: { errors }
@@ -2774,7 +2789,7 @@ var SearchApiRoot = ({
2774
2789
  for (const part of nameParts) {
2775
2790
  currentError = currentError?.[part];
2776
2791
  }
2777
- message24 = currentError?.message || message24;
2792
+ message26 = currentError?.message || message26;
2778
2793
  }
2779
2794
  const valueCtx = {
2780
2795
  isOpen,
@@ -2808,7 +2823,7 @@ var SearchApiRoot = ({
2808
2823
  form,
2809
2824
  name,
2810
2825
  obj,
2811
- error: message24,
2826
+ error: message26,
2812
2827
  onSelect,
2813
2828
  onClear
2814
2829
  };
@@ -3175,19 +3190,19 @@ var DateInput = (0, import_react17.forwardRef)(
3175
3190
  const { theme } = useWarqadConfig();
3176
3191
  const primaryColor = theme?.primaryColor;
3177
3192
  const [isFocused, setIsFocused] = (0, import_react17.useState)(false);
3178
- let message24 = error;
3193
+ let message26 = error;
3179
3194
  if (form && name) {
3180
3195
  const {
3181
3196
  formState: { errors }
3182
3197
  } = form;
3183
3198
  const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
3184
- message24 = errorObj?.message;
3199
+ message26 = errorObj?.message;
3185
3200
  }
3186
3201
  const inputStyles = `w-full px-2.5 py-1 rounded-md border! shadow-none transition-all! duration-200! outline-none!
3187
3202
  bg-white! dark:bg-zinc-900!
3188
3203
  text-gray-900! dark:text-zinc-100!
3189
3204
  hover:bg-white! dark:hover:bg-zinc-900!
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"}
3205
+ ${message26 ? "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"}
3191
3206
  [&.ant-picker-focused]:bg-white dark:[&.ant-picker-focused]:bg-zinc-900
3192
3207
  ${className}`;
3193
3208
  const renderDatePicker = (val, changeHandler, blurHandler, refProps) => {
@@ -3210,8 +3225,8 @@ var DateInput = (0, import_react17.forwardRef)(
3210
3225
  needConfirm: false,
3211
3226
  style: {
3212
3227
  height: "var(--input-height, 40px)",
3213
- borderColor: isFocused && !message24 ? primaryColor : void 0,
3214
- boxShadow: isFocused && !message24 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
3228
+ borderColor: isFocused && !message26 ? primaryColor : void 0,
3229
+ boxShadow: isFocused && !message26 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
3215
3230
  },
3216
3231
  classNames: { popup: { root: "z-50" } },
3217
3232
  suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
@@ -3241,7 +3256,7 @@ var DateInput = (0, import_react17.forwardRef)(
3241
3256
  {
3242
3257
  className: "block text-xs font-medium transition-colors duration-200",
3243
3258
  style: {
3244
- color: message24 ? "#ef4444" : isFocused ? primaryColor : void 0
3259
+ color: message26 ? "#ef4444" : isFocused ? primaryColor : void 0
3245
3260
  },
3246
3261
  children: [
3247
3262
  label,
@@ -3262,7 +3277,7 @@ var DateInput = (0, import_react17.forwardRef)(
3262
3277
  )
3263
3278
  }
3264
3279
  ) : renderDatePicker(value, onChange, onBlur, ref),
3265
- message24 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
3280
+ message26 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
3266
3281
  ] });
3267
3282
  }
3268
3283
  );
@@ -3287,6 +3302,7 @@ var Fields_default = Fields;
3287
3302
 
3288
3303
  // src/components/tables/DataTable.tsx
3289
3304
  var import_react18 = __toESM(require("react"));
3305
+ var import_react_dom4 = require("react-dom");
3290
3306
  var import_react_table = require("@tanstack/react-table");
3291
3307
  var import_lucide_react12 = require("lucide-react");
3292
3308
  var import_jsx_runtime25 = require("react/jsx-runtime");
@@ -3338,6 +3354,43 @@ function DataTable({
3338
3354
  setPagination((prev) => ({ ...prev, pageSize: pageRows }));
3339
3355
  }
3340
3356
  }, [pageRows]);
3357
+ const [isVisibilityOpen, setIsVisibilityOpen] = (0, import_react18.useState)(false);
3358
+ const visibilityAnchorRef = (0, import_react18.useRef)(null);
3359
+ const visibilityContentRef = (0, import_react18.useRef)(null);
3360
+ const [visibilityCoords, setVisibilityCoords] = (0, import_react18.useState)({
3361
+ top: 0,
3362
+ left: 0,
3363
+ width: 0
3364
+ });
3365
+ const updateVisibilityPosition = () => {
3366
+ if (visibilityAnchorRef.current) {
3367
+ const rect = visibilityAnchorRef.current.getBoundingClientRect();
3368
+ setVisibilityCoords({
3369
+ top: rect.bottom,
3370
+ left: rect.left,
3371
+ width: rect.width
3372
+ });
3373
+ }
3374
+ };
3375
+ (0, import_react18.useEffect)(() => {
3376
+ if (isVisibilityOpen) {
3377
+ updateVisibilityPosition();
3378
+ const handleScroll = () => updateVisibilityPosition();
3379
+ window.addEventListener("scroll", handleScroll, true);
3380
+ window.addEventListener("resize", handleScroll);
3381
+ const handleClickOutside = (event) => {
3382
+ if (visibilityAnchorRef.current && !visibilityAnchorRef.current.contains(event.target) && visibilityContentRef.current && !visibilityContentRef.current.contains(event.target)) {
3383
+ setIsVisibilityOpen(false);
3384
+ }
3385
+ };
3386
+ document.addEventListener("mousedown", handleClickOutside);
3387
+ return () => {
3388
+ window.removeEventListener("scroll", handleScroll, true);
3389
+ window.removeEventListener("resize", handleScroll);
3390
+ document.removeEventListener("mousedown", handleClickOutside);
3391
+ };
3392
+ }
3393
+ }, [isVisibilityOpen]);
3341
3394
  const [expanded, setExpanded] = (0, import_react18.useState)(() => {
3342
3395
  const initialState = {};
3343
3396
  if (defaultExpanded && renderSubComponent && data) {
@@ -3436,31 +3489,59 @@ function DataTable({
3436
3489
  className: "h-9!"
3437
3490
  }
3438
3491
  ) }),
3439
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative group", children: [
3440
- /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("button", { className: "flex items-center gap-2 px-3 h-9 rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-zinc-800 transition-colors", children: [
3441
- "Columns",
3442
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react12.ChevronDown, { size: 14, className: "text-gray-400" })
3443
- ] }),
3444
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute right-0 top-full mt-2 w-48 py-1 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50", children: table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3445
- "label",
3492
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative", ref: visibilityAnchorRef, children: [
3493
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3494
+ "button",
3446
3495
  {
3447
- className: "flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-zinc-800 cursor-pointer capitalize",
3496
+ onClick: () => setIsVisibilityOpen(!isVisibilityOpen),
3497
+ className: "flex items-center gap-2 px-3 h-9 rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 text-sm font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-zinc-800 transition-colors",
3448
3498
  children: [
3499
+ "Columns",
3449
3500
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3450
- "input",
3501
+ import_lucide_react12.ChevronDown,
3451
3502
  {
3452
- type: "checkbox",
3453
- checked: column.getIsVisible(),
3454
- onChange: (e) => column.toggleVisibility(!!e.target.checked),
3455
- className: "rounded border-gray-300 text-blue-600 focus:ring-blue-500",
3456
- style: { accentColor: primaryColor }
3503
+ size: 14,
3504
+ className: `text-gray-400 transition-transform ${isVisibilityOpen ? "rotate-180" : ""}`
3457
3505
  }
3458
- ),
3459
- column.id
3506
+ )
3460
3507
  ]
3461
- },
3462
- column.id
3463
- )) })
3508
+ }
3509
+ ),
3510
+ isVisibilityOpen && (0, import_react_dom4.createPortal)(
3511
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3512
+ "div",
3513
+ {
3514
+ ref: visibilityContentRef,
3515
+ className: "fixed mt-2 w-48 py-1 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-xl z-[9999]",
3516
+ style: {
3517
+ top: `${visibilityCoords.top}px`,
3518
+ left: `${visibilityCoords.left + visibilityCoords.width - 192}px`
3519
+ // 192px is w-48
3520
+ },
3521
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "max-h-64 overflow-y-auto", children: table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3522
+ "label",
3523
+ {
3524
+ className: "flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-zinc-800 cursor-pointer capitalize",
3525
+ children: [
3526
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3527
+ "input",
3528
+ {
3529
+ type: "checkbox",
3530
+ checked: column.getIsVisible(),
3531
+ onChange: (e) => column.toggleVisibility(!!e.target.checked),
3532
+ className: "rounded border-gray-300 text-blue-600 focus:ring-blue-500",
3533
+ style: { accentColor: primaryColor }
3534
+ }
3535
+ ),
3536
+ column.id
3537
+ ]
3538
+ },
3539
+ column.id
3540
+ )) })
3541
+ }
3542
+ ),
3543
+ document.body
3544
+ )
3464
3545
  ] }) })
3465
3546
  ] }),
3466
3547
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 overflow-hidden relative", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "overflow-x-auto", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
@@ -5123,7 +5204,7 @@ var import_react26 = require("react");
5123
5204
 
5124
5205
  // src/components/Dropdown.tsx
5125
5206
  var import_react25 = require("react");
5126
- var import_react_dom4 = require("react-dom");
5207
+ var import_react_dom5 = require("react-dom");
5127
5208
  var import_jsx_runtime34 = require("react/jsx-runtime");
5128
5209
  var Dropdown = ({
5129
5210
  children,
@@ -5223,7 +5304,7 @@ var Dropdown = ({
5223
5304
  children
5224
5305
  }
5225
5306
  ),
5226
- isOpen && (0, import_react_dom4.createPortal)(
5307
+ isOpen && (0, import_react_dom5.createPortal)(
5227
5308
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5228
5309
  "div",
5229
5310
  {
@@ -7531,17 +7612,17 @@ var preWarningFns = [];
7531
7612
  var preMessage = (fn) => {
7532
7613
  preWarningFns.push(fn);
7533
7614
  };
7534
- function warning(valid, message24) {
7615
+ function warning(valid, message26) {
7535
7616
  if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
7536
- const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message24);
7617
+ const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message26);
7537
7618
  if (finalMessage) {
7538
7619
  console.error(`Warning: ${finalMessage}`);
7539
7620
  }
7540
7621
  }
7541
7622
  }
7542
- function note(valid, message24) {
7623
+ function note(valid, message26) {
7543
7624
  if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
7544
- const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message24);
7625
+ const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message26);
7545
7626
  if (finalMessage) {
7546
7627
  console.warn(`Note: ${finalMessage}`);
7547
7628
  }
@@ -7550,17 +7631,17 @@ function note(valid, message24) {
7550
7631
  function resetWarned() {
7551
7632
  warned = {};
7552
7633
  }
7553
- function call(method, valid, message24) {
7554
- if (!valid && !warned[message24]) {
7555
- method(false, message24);
7556
- warned[message24] = true;
7634
+ function call(method, valid, message26) {
7635
+ if (!valid && !warned[message26]) {
7636
+ method(false, message26);
7637
+ warned[message26] = true;
7557
7638
  }
7558
7639
  }
7559
- function warningOnce(valid, message24) {
7560
- call(warning, valid, message24);
7640
+ function warningOnce(valid, message26) {
7641
+ call(warning, valid, message26);
7561
7642
  }
7562
- function noteOnce(valid, message24) {
7563
- call(note, valid, message24);
7643
+ function noteOnce(valid, message26) {
7644
+ call(note, valid, message26);
7564
7645
  }
7565
7646
  warningOnce.preMessage = preMessage;
7566
7647
  warningOnce.resetWarned = resetWarned;
@@ -7571,8 +7652,8 @@ var import_react31 = __toESM(require("react"));
7571
7652
  function camelCase(input) {
7572
7653
  return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
7573
7654
  }
7574
- function warning2(valid, message24) {
7575
- warningOnce(valid, `[@ant-design/icons] ${message24}`);
7655
+ function warning2(valid, message26) {
7656
+ warningOnce(valid, `[@ant-design/icons] ${message26}`);
7576
7657
  }
7577
7658
  function isIconDefinition(target) {
7578
7659
  return typeof target === "object" && typeof target.name === "string" && typeof target.theme === "string" && (typeof target.icon === "object" || typeof target.icon === "function");
@@ -8311,7 +8392,8 @@ var createAccountSchema = import_zod2.z.object({
8311
8392
  }).transform((val) => val?.toLowerCase()),
8312
8393
  phoneNumber: import_zod2.z.string().optional(),
8313
8394
  sex: import_zod2.z.enum(Enums_default.sex),
8314
- branch: import_zod2.z.string().optional()
8395
+ branch: import_zod2.z.string().optional(),
8396
+ currency: import_zod2.z.string().optional()
8315
8397
  });
8316
8398
 
8317
8399
  // src/components/accounts/AccountForm.tsx
@@ -8368,10 +8450,10 @@ var useAccountbalance = ({
8368
8450
  try {
8369
8451
  const res = await get({
8370
8452
  url,
8371
- v: 2
8453
+ v: 1
8372
8454
  });
8373
- const data = res;
8374
- setBalance(Formats_default.Price(data?.balance, data?.currency));
8455
+ const data = res?.data;
8456
+ setBalance(Formats_default.Price(data?.balance ?? 0, data?.currency ?? "N/A"));
8375
8457
  } catch (error2) {
8376
8458
  setError(error2.message);
8377
8459
  }
@@ -8425,7 +8507,8 @@ function Account({
8425
8507
  v = 1,
8426
8508
  showBalance,
8427
8509
  required,
8428
- disabled
8510
+ disabled,
8511
+ obj
8429
8512
  }) {
8430
8513
  const { branchId } = (0, import_react_router_dom8.useParams)();
8431
8514
  const accountId = form?.watch(name);
@@ -8449,7 +8532,8 @@ function Account({
8449
8532
  labelKey: "name",
8450
8533
  valueKey: "_id",
8451
8534
  required,
8452
- disabled
8535
+ disabled,
8536
+ obj
8453
8537
  }
8454
8538
  ),
8455
8539
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BalanceView, {})
@@ -8469,7 +8553,8 @@ function Customer({
8469
8553
  showBalance,
8470
8554
  required,
8471
8555
  disabled,
8472
- v
8556
+ v,
8557
+ obj
8473
8558
  }) {
8474
8559
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
8475
8560
  Account_default,
@@ -8483,7 +8568,8 @@ function Customer({
8483
8568
  filter,
8484
8569
  showBalance,
8485
8570
  required,
8486
- disabled
8571
+ disabled,
8572
+ obj
8487
8573
  }
8488
8574
  );
8489
8575
  }
@@ -8501,6 +8587,7 @@ function Employee({
8501
8587
  showBalance,
8502
8588
  required,
8503
8589
  disabled,
8590
+ obj,
8504
8591
  v
8505
8592
  }) {
8506
8593
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
@@ -8515,7 +8602,8 @@ function Employee({
8515
8602
  filter,
8516
8603
  required,
8517
8604
  disabled,
8518
- showBalance
8605
+ showBalance,
8606
+ obj
8519
8607
  }
8520
8608
  );
8521
8609
  }
@@ -8583,7 +8671,8 @@ function AccountForm() {
8583
8671
  name: "",
8584
8672
  email: "",
8585
8673
  phoneNumber: "",
8586
- sex: "male"
8674
+ sex: "male",
8675
+ currency: ""
8587
8676
  },
8588
8677
  shouldUnregister: false
8589
8678
  });
@@ -8693,6 +8782,15 @@ function AccountForm() {
8693
8782
  placeholder: "Select Branch",
8694
8783
  api: "/branches/get?noStore=true"
8695
8784
  }
8785
+ ),
8786
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
8787
+ Fields_default.Select,
8788
+ {
8789
+ label: "Currency",
8790
+ form: methods,
8791
+ name: "currency",
8792
+ enumName: "currencies"
8793
+ }
8696
8794
  )
8697
8795
  ] }),
8698
8796
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
@@ -11419,29 +11517,527 @@ function Pack({
11419
11517
  }
11420
11518
  var Pack_default = { Pack };
11421
11519
 
11422
- // src/components/ErrorPage/ErrorPage.tsx
11520
+ // src/components/journals/Journals.tsx
11521
+ var import_react_router_dom24 = require("react-router-dom");
11522
+ var import_lucide_react31 = require("lucide-react");
11523
+ var import_react53 = require("react");
11524
+ var import_antd26 = require("antd");
11423
11525
  var import_jsx_runtime75 = require("react/jsx-runtime");
11526
+ function Journals({ url }) {
11527
+ const { branchId } = (0, import_react_router_dom24.useParams)();
11528
+ const navigate = (0, import_react_router_dom24.useNavigate)();
11529
+ const [deleteJournal, setDeleteJournal] = (0, import_react53.useState)(null);
11530
+ const { isLoading, remove } = useApis_default();
11531
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
11532
+ url: url || `/transactions/get?type=journal${branchId ? `&branch=${branchId}` : ""}`,
11533
+ dateFilter: true
11534
+ });
11535
+ const { Modal: Modal2 } = useModal();
11536
+ const items = (data2) => [
11537
+ {
11538
+ label: `Edit Journal`,
11539
+ icon: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_lucide_react31.FilePenLine, { size: 16 }),
11540
+ onClick: () => navigate(`update?id=${data2?._id}`)
11541
+ },
11542
+ {
11543
+ label: `Delete Journal`,
11544
+ icon: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_lucide_react31.Trash2, { className: "text-red-500", size: 16 }),
11545
+ onClick: () => setDeleteJournal(data2)
11546
+ }
11547
+ ].filter(Boolean);
11548
+ const columns = [
11549
+ {
11550
+ accessorKey: "date",
11551
+ header: "Date",
11552
+ cell: ({ row }) => {
11553
+ const journal = row.original;
11554
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { children: journal?.date });
11555
+ }
11556
+ },
11557
+ {
11558
+ accessorKey: "account",
11559
+ header: "Account",
11560
+ cell: ({ row }) => {
11561
+ const journal = row.original;
11562
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { children: journal?.accountData?.name || "N/A" });
11563
+ }
11564
+ },
11565
+ {
11566
+ accessorKey: "amount",
11567
+ header: "Amount",
11568
+ cell: ({ row }) => {
11569
+ const journal = row.original;
11570
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "flex flex-col", children: [
11571
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { children: Formats_default.Price(journal?.amount, journal?.currency) }),
11572
+ journal?.fee && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("span", { className: "text-xs text-green-600", children: [
11573
+ "with fee: ",
11574
+ Formats_default.Price(journal?.feeAmount, journal?.currency)
11575
+ ] }),
11576
+ journal?.exchange?.rate && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("span", { className: "text-xs text-green-600", children: [
11577
+ "Exchanged:",
11578
+ " ",
11579
+ Formats_default.Price(
11580
+ journal?.exchange?.amount,
11581
+ journal?.exchange?.currency
11582
+ )
11583
+ ] })
11584
+ ] });
11585
+ }
11586
+ },
11587
+ {
11588
+ accessorKey: "journal",
11589
+ header: "Type",
11590
+ cell: ({ row }) => {
11591
+ const journal = row.original;
11592
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "capitalize", children: journal?.journal });
11593
+ }
11594
+ },
11595
+ {
11596
+ accessorKey: "journalVia",
11597
+ header: "Via",
11598
+ cell: ({ row }) => {
11599
+ const journal = row.original;
11600
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "", children: [
11601
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { className: "capitalize", children: journal?.journalVia }),
11602
+ journal?.journalVia === "via account" && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("p", { className: "capitalize text-xs text-gray-600", children: journal?.viaAccountData?.name })
11603
+ ] });
11604
+ }
11605
+ },
11606
+ {
11607
+ accessorKey: "action",
11608
+ header: "Action",
11609
+ cell: ({ row }) => {
11610
+ const journal = row.original;
11611
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)("span", { className: "capitalize", children: journal?.action });
11612
+ }
11613
+ },
11614
+ {
11615
+ accessorKey: "actions",
11616
+ header: "Actions",
11617
+ cell: ({ row }) => {
11618
+ const data2 = row.original;
11619
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
11620
+ Dropdown,
11621
+ {
11622
+ className: "cursor-pointer w-[150px]",
11623
+ items: items(data2),
11624
+ triggerMode: "hover",
11625
+ children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_lucide_react31.EllipsisVertical, {})
11626
+ }
11627
+ );
11628
+ }
11629
+ }
11630
+ ];
11631
+ const journals = data?.data || [];
11632
+ const onDelete = async (id) => {
11633
+ try {
11634
+ await remove({ url: `/journals/delete/${id}` });
11635
+ import_antd26.message.success("Journal deleted successfully");
11636
+ reload();
11637
+ setDeleteJournal(null);
11638
+ } catch (error) {
11639
+ import_antd26.message.error(error.message || "Something went wrong");
11640
+ return error;
11641
+ }
11642
+ };
11643
+ return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(import_jsx_runtime75.Fragment, { children: [
11644
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Modal2, {}),
11645
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
11646
+ ConfirmModal,
11647
+ {
11648
+ isOpen: !!deleteJournal,
11649
+ isLoading,
11650
+ onClose: () => setDeleteJournal(null),
11651
+ title: `Delete Journal`,
11652
+ description: `Are you sure you want to delete this journal entry of "${deleteJournal?.amount}"? This action cannot be undone.`,
11653
+ confirmationWord: "delete",
11654
+ onSubmit: () => onDelete(deleteJournal?._id),
11655
+ children: null
11656
+ }
11657
+ ),
11658
+ /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
11659
+ TransactionViewComponent,
11660
+ {
11661
+ columns,
11662
+ data: journals,
11663
+ title: "Journals",
11664
+ description: "Manage your journal entries",
11665
+ index: true,
11666
+ createTitle: "Add Journal",
11667
+ onCreate: () => {
11668
+ navigate("create");
11669
+ }
11670
+ }
11671
+ )
11672
+ ] });
11673
+ }
11674
+ var Journals_default = Journals;
11675
+
11676
+ // src/utils/zod.ts
11677
+ var import_moment2 = __toESM(require("moment"));
11678
+ var import_zod20 = require("zod");
11679
+ var zodFields = {
11680
+ date: import_zod20.z.string().regex(
11681
+ /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/,
11682
+ "Date must be in format DD/MM/YYYY"
11683
+ ).refine((val) => (0, import_moment2.default)(val, "DD/MM/YYYY", true).isValid(), {
11684
+ message: "Date is not a valid calendar date"
11685
+ })
11686
+ };
11687
+
11688
+ // src/components/journals/schema.ts
11689
+ var import_zod22 = require("zod");
11690
+ var journalSchema = import_zod22.z.object({
11691
+ date: zodFields.date,
11692
+ amount: import_zod22.z.number().gt(0, "Amount must be greater than 0"),
11693
+ account: import_zod22.z.string(),
11694
+ description: import_zod22.z.string(),
11695
+ journalVia: import_zod22.z.enum(Enums_default.viaTypes),
11696
+ action: import_zod22.z.enum(Enums_default.actionTypes).optional(),
11697
+ viaAccount: import_zod22.z.string().optional(),
11698
+ viaAccountObject: import_zod22.z.any().optional(),
11699
+ accountObject: import_zod22.z.any().optional(),
11700
+ //exchange
11701
+ rate: import_zod22.z.coerce.number().gte(0).optional(),
11702
+ exchangedAmount: import_zod22.z.coerce.number().gte(0).optional(),
11703
+ fee: import_zod22.z.coerce.number().gte(0)
11704
+ });
11705
+
11706
+ // src/components/journals/JournalForm.tsx
11707
+ var import_react_hook_form20 = require("react-hook-form");
11708
+ var import_zod23 = require("@hookform/resolvers/zod");
11709
+ var import_antd27 = require("antd");
11710
+ var import_react54 = require("react");
11711
+ var import_react_router_dom25 = require("react-router-dom");
11712
+
11713
+ // src/utils/forex.ts
11714
+ function exchangedAmount({
11715
+ accountCurrency,
11716
+ amount,
11717
+ exchangeRate,
11718
+ transactionCurrency,
11719
+ trunc = false
11720
+ }) {
11721
+ if (!Enums_default.currencies.includes(accountCurrency)) {
11722
+ throw new Error("Invalid account currency");
11723
+ }
11724
+ if (!Enums_default.currencies.includes(transactionCurrency)) {
11725
+ throw new Error("Invalid transaction currency");
11726
+ }
11727
+ let result;
11728
+ if (accountCurrency === transactionCurrency) {
11729
+ result = amount;
11730
+ } else if (accountCurrency === "USD") {
11731
+ result = amount / exchangeRate;
11732
+ } else if (accountCurrency === "CNY") {
11733
+ result = transactionCurrency === "USD" ? amount * exchangeRate : amount / exchangeRate;
11734
+ } else if (accountCurrency === "KES") {
11735
+ result = transactionCurrency === "TZS" ? amount / exchangeRate : amount * exchangeRate;
11736
+ } else if (accountCurrency === "TZS") {
11737
+ result = amount * exchangeRate;
11738
+ } else {
11739
+ throw new Error("Unsupported currency conversion");
11740
+ }
11741
+ return trunc ? Math.trunc(result) : result;
11742
+ }
11743
+ var Forex = {
11744
+ exchangedAmount
11745
+ };
11746
+ var forex_default = Forex;
11747
+
11748
+ // src/components/journals/JournalForm.tsx
11749
+ var import_jsx_runtime76 = require("react/jsx-runtime");
11750
+ function JournalForm({
11751
+ isFee = true,
11752
+ accountType = "all"
11753
+ }) {
11754
+ const { branchId } = (0, import_react_router_dom25.useParams)();
11755
+ const { getQuery, navigate } = useApp_default();
11756
+ const id = getQuery("id");
11757
+ const isEdit = !!id;
11758
+ const [ref, setRef] = (0, import_react54.useState)("");
11759
+ const { post, isLoading } = useApis_default();
11760
+ const { isLoading: isLoadingGet, get } = useApis_default();
11761
+ const methods = (0, import_react_hook_form20.useForm)({
11762
+ resolver: (0, import_zod23.zodResolver)(journalSchema),
11763
+ defaultValues: {
11764
+ date: (/* @__PURE__ */ new Date()).toLocaleDateString("en-GB"),
11765
+ amount: 0,
11766
+ account: "",
11767
+ fee: 0,
11768
+ action: "debit",
11769
+ journalVia: "direct"
11770
+ }
11771
+ });
11772
+ const { handleSubmit } = methods;
11773
+ const journalVia = methods.watch("journalVia");
11774
+ const account = methods.watch("account");
11775
+ const viaAccount = methods.watch("viaAccount");
11776
+ const viaAccountObj = methods.watch("viaAccountObject");
11777
+ const accountObj = methods.watch("accountObject");
11778
+ const amount = methods.watch("amount");
11779
+ const fee = methods.watch("fee");
11780
+ const rate = methods.watch("rate");
11781
+ const isRate = accountObj?.currency && viaAccountObj?.currency && accountObj?.currency !== viaAccountObj?.currency;
11782
+ const onSubmit = async (data) => {
11783
+ try {
11784
+ const payload = {
11785
+ ...data,
11786
+ journal: "journal",
11787
+ type: "journal",
11788
+ action: data.journalVia === "via account" ? "debit" : data.action,
11789
+ branch: branchId ?? void 0
11790
+ };
11791
+ await post({
11792
+ url: `/transactions/add${isEdit ? `?ref=${ref}` : ""}`,
11793
+ body: payload
11794
+ });
11795
+ import_antd27.message.success(`Journal saved successfully`);
11796
+ navigate(-1);
11797
+ } catch (error) {
11798
+ import_antd27.message.error(error?.message || "Something went wrong");
11799
+ }
11800
+ };
11801
+ const fetches = async () => {
11802
+ try {
11803
+ const res = await get({
11804
+ url: `/transactions/get?id=${id}${branchId ? `&fromBranch=${branchId}` : ""}`
11805
+ });
11806
+ const data = res.data;
11807
+ console.log(data);
11808
+ methods.reset({
11809
+ ...data,
11810
+ rate: data?.exchange?.rate
11811
+ });
11812
+ setRef(data?.ref);
11813
+ } catch (error) {
11814
+ import_antd27.message.error(error?.message || "Something went wrong");
11815
+ navigate(-1);
11816
+ }
11817
+ };
11818
+ const exchangedAmount2 = (0, import_react54.useMemo)(() => {
11819
+ if (isRate) {
11820
+ const am = forex_default.exchangedAmount({
11821
+ accountCurrency: accountObj?.currency,
11822
+ amount,
11823
+ exchangeRate: rate ?? 1,
11824
+ transactionCurrency: viaAccountObj?.currency
11825
+ });
11826
+ return Formats_default.Price(am, accountObj?.currency ?? "N/A");
11827
+ }
11828
+ }, [
11829
+ amount,
11830
+ viaAccountObj?.rate,
11831
+ accountObj?.currency,
11832
+ viaAccountObj?.currency,
11833
+ rate
11834
+ ]);
11835
+ const viaAccountAmount = (0, import_react54.useMemo)(() => {
11836
+ if (fee) {
11837
+ const am = amount + fee / 100 * amount;
11838
+ return Formats_default.Price(
11839
+ am,
11840
+ viaAccountObj?.currency ?? accountObj?.currency ?? "N/A"
11841
+ );
11842
+ } else {
11843
+ return Formats_default.Price(
11844
+ amount,
11845
+ viaAccountObj?.currency ?? accountObj?.currency ?? "N/A"
11846
+ );
11847
+ }
11848
+ }, [fee, amount, viaAccountObj?.currency, accountObj?.currency]);
11849
+ (0, import_react54.useEffect)(() => {
11850
+ if (isEdit) {
11851
+ fetches();
11852
+ }
11853
+ }, [id]);
11854
+ return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
11855
+ Card,
11856
+ {
11857
+ className: "max-w-4xl mx-auto mt-10 relative",
11858
+ isLoading: isLoadingGet,
11859
+ loadingText: "Processing...",
11860
+ children: [
11861
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Card.Header, { children: [
11862
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Journal` }),
11863
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Card.Description, { children: isEdit ? `Update the details for this journal entry` : `Create a new journal entry` })
11864
+ ] }),
11865
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Card.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
11866
+ "form",
11867
+ {
11868
+ className: "space-y-4",
11869
+ onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
11870
+ children: [
11871
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
11872
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11873
+ Fields_default.Input,
11874
+ {
11875
+ label: "Description",
11876
+ form: methods,
11877
+ name: "description",
11878
+ placeholder: "Enter description",
11879
+ required: true
11880
+ }
11881
+ ),
11882
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11883
+ Fields_default.Select,
11884
+ {
11885
+ label: "Journal Via",
11886
+ form: methods,
11887
+ name: "journalVia",
11888
+ enumName: "viaTypes",
11889
+ required: true
11890
+ }
11891
+ )
11892
+ ] }),
11893
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
11894
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11895
+ Fields_default.DateInput,
11896
+ {
11897
+ label: "Date",
11898
+ form: methods,
11899
+ name: "date",
11900
+ required: true
11901
+ }
11902
+ ),
11903
+ journalVia === "via account" && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11904
+ Feilds_default.Account,
11905
+ {
11906
+ label: "Via Account",
11907
+ form: methods,
11908
+ name: "viaAccount",
11909
+ api: "/accounts/get/all",
11910
+ placeholder: "Search for account...",
11911
+ filter: [account],
11912
+ required: true,
11913
+ obj: "viaAccountObject",
11914
+ showBalance: true
11915
+ }
11916
+ ),
11917
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11918
+ Feilds_default.Account,
11919
+ {
11920
+ label: accountType === "all" ? "Account" : accountType,
11921
+ form: methods,
11922
+ name: "account",
11923
+ api: `/accounts/get/${accountType}`,
11924
+ placeholder: "Search for account...",
11925
+ filter: [viaAccount],
11926
+ required: true,
11927
+ showBalance: true,
11928
+ obj: "accountObject"
11929
+ }
11930
+ ),
11931
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11932
+ Fields_default.Input,
11933
+ {
11934
+ label: "Amount",
11935
+ form: methods,
11936
+ name: "amount",
11937
+ type: "number",
11938
+ placeholder: "0.00",
11939
+ required: true
11940
+ }
11941
+ ),
11942
+ journalVia !== "via account" && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11943
+ Fields_default.Select,
11944
+ {
11945
+ label: "Action",
11946
+ form: methods,
11947
+ name: "action",
11948
+ enumName: "actionTypes",
11949
+ required: true
11950
+ }
11951
+ ),
11952
+ isRate && /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
11953
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11954
+ Fields_default.Input,
11955
+ {
11956
+ label: "Rate",
11957
+ type: "number",
11958
+ name: "rate",
11959
+ form: methods,
11960
+ required: true
11961
+ }
11962
+ ),
11963
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11964
+ Fields_default.Input,
11965
+ {
11966
+ label: "Exchanged Amount",
11967
+ type: "text",
11968
+ readOnly: true,
11969
+ disabled: true,
11970
+ value: exchangedAmount2
11971
+ }
11972
+ ),
11973
+ " "
11974
+ ] }),
11975
+ isFee && /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
11976
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11977
+ Fields_default.Input,
11978
+ {
11979
+ label: "Fee",
11980
+ type: "number",
11981
+ name: "fee",
11982
+ form: methods,
11983
+ required: true
11984
+ }
11985
+ ),
11986
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11987
+ Fields_default.Input,
11988
+ {
11989
+ label: "Amount After Fee",
11990
+ type: "text",
11991
+ readOnly: true,
11992
+ disabled: true,
11993
+ value: viaAccountAmount
11994
+ }
11995
+ )
11996
+ ] })
11997
+ ] }),
11998
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
11999
+ Button,
12000
+ {
12001
+ isLoading,
12002
+ disabled: isLoading,
12003
+ type: "submit",
12004
+ className: "min-w-[100px]",
12005
+ variant: !isEdit ? "primary" : "warning",
12006
+ children: isEdit ? "Update" : "Add"
12007
+ }
12008
+ ) })
12009
+ ]
12010
+ }
12011
+ ) })
12012
+ ]
12013
+ }
12014
+ );
12015
+ }
12016
+ var JournalForm_default = JournalForm;
12017
+
12018
+ // src/components/ErrorPage/ErrorPage.tsx
12019
+ var import_jsx_runtime77 = require("react/jsx-runtime");
11424
12020
  var ErrorPageBase = ({
11425
12021
  title,
11426
- message: message24,
12022
+ message: message26,
11427
12023
  statusCode,
11428
12024
  action,
11429
12025
  className = ""
11430
12026
  }) => {
11431
- return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
12027
+ return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
11432
12028
  "div",
11433
12029
  {
11434
12030
  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}`,
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: [
12031
+ children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "relative flex flex-col items-center justify-center w-full max-w-2xl text-center", children: [
12032
+ statusCode && /* @__PURE__ */ (0, import_jsx_runtime77.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_runtime77.jsx)("span", { className: "text-[12rem] sm:text-[16rem] md:text-[20rem] font-bold leading-none tracking-tighter", children: statusCode }) }),
12033
+ /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "relative z-10 space-y-6", children: [
12034
+ statusCode && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("h2", { className: "text-xl md:text-2xl font-semibold text-zinc-500 dark:text-zinc-400", children: [
11439
12035
  "Error ",
11440
12036
  statusCode
11441
12037
  ] }),
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)(
12038
+ title && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
12039
+ message26 && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("p", { className: "text-lg md:text-xl text-zinc-600 dark:text-zinc-400 max-w-md mx-auto", children: message26 }),
12040
+ action && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "pt-8", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
11445
12041
  "button",
11446
12042
  {
11447
12043
  onClick: action.onClick,
@@ -11457,9 +12053,9 @@ var ErrorPageBase = ({
11457
12053
  };
11458
12054
 
11459
12055
  // src/components/ErrorPage/ErrorPage.500.tsx
11460
- var import_jsx_runtime76 = require("react/jsx-runtime");
12056
+ var import_jsx_runtime78 = require("react/jsx-runtime");
11461
12057
  var ErrorPage500 = (props) => {
11462
- return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
12058
+ return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
11463
12059
  ErrorPageBase,
11464
12060
  {
11465
12061
  statusCode: 500,
@@ -11472,9 +12068,9 @@ var ErrorPage500 = (props) => {
11472
12068
  };
11473
12069
 
11474
12070
  // src/components/ErrorPage/ErrorPage.404.tsx
11475
- var import_jsx_runtime77 = require("react/jsx-runtime");
12071
+ var import_jsx_runtime79 = require("react/jsx-runtime");
11476
12072
  var ErrorPage404 = (props) => {
11477
- return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
12073
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
11478
12074
  ErrorPageBase,
11479
12075
  {
11480
12076
  statusCode: 404,
@@ -11487,9 +12083,9 @@ var ErrorPage404 = (props) => {
11487
12083
  };
11488
12084
 
11489
12085
  // src/components/ErrorPage/ErrorPage.401.tsx
11490
- var import_jsx_runtime78 = require("react/jsx-runtime");
12086
+ var import_jsx_runtime80 = require("react/jsx-runtime");
11491
12087
  var ErrorPage401 = (props) => {
11492
- return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
12088
+ return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
11493
12089
  ErrorPageBase,
11494
12090
  {
11495
12091
  statusCode: 401,
@@ -11502,9 +12098,9 @@ var ErrorPage401 = (props) => {
11502
12098
  };
11503
12099
 
11504
12100
  // src/components/ErrorPage/ErrorPage.400.tsx
11505
- var import_jsx_runtime79 = require("react/jsx-runtime");
12101
+ var import_jsx_runtime81 = require("react/jsx-runtime");
11506
12102
  var ErrorPage400 = (props) => {
11507
- return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
12103
+ return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
11508
12104
  ErrorPageBase,
11509
12105
  {
11510
12106
  statusCode: 400,
@@ -11558,6 +12154,8 @@ var ErrorPage = Object.assign(ErrorPageBase, {
11558
12154
  Guard,
11559
12155
  InfoGrid,
11560
12156
  Input,
12157
+ JournalForm,
12158
+ Journals,
11561
12159
  LinkUser,
11562
12160
  LoadingBox,
11563
12161
  LoadingSpin,
@@ -11610,6 +12208,7 @@ var ErrorPage = Object.assign(ErrorPageBase, {
11610
12208
  createUserSchema,
11611
12209
  createWalletSchema,
11612
12210
  generatePdf,
12211
+ journalSchema,
11613
12212
  linkUserSchema,
11614
12213
  packProductItemSchema,
11615
12214
  packTypes,