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.mjs CHANGED
@@ -299,12 +299,21 @@ var useTheme = () => {
299
299
  var Enums = {
300
300
  roles: ["admin", "staff"],
301
301
  sex: ["male", "female"],
302
- accountTypes: ["employee", "supplier", "customer", "amaanah"],
302
+ accountTypes: [
303
+ "employee",
304
+ "supplier",
305
+ "customer",
306
+ "amaanah",
307
+ "account"
308
+ ],
303
309
  verificationTypes: ["email_verification", "password_reset"],
304
310
  auditActions: ["create", "update", "delete", "login", "logout"],
305
311
  walletTypes: ["bank", "cash", "mobile"],
306
312
  currencies: ["USD", "TZS", "KES", "CNY"],
307
- packTypes: ["pressure", "bag", "boxes"]
313
+ packTypes: ["pressure", "bag", "boxes"],
314
+ journalTypes: ["journal"],
315
+ viaTypes: ["direct", "via account"],
316
+ actionTypes: ["credit", "debit"]
308
317
  };
309
318
  var Enums_default = Enums;
310
319
 
@@ -1331,13 +1340,13 @@ var Input = forwardRef(
1331
1340
  }
1332
1341
  }
1333
1342
  }, [props.value, name, form]);
1334
- let message24 = error;
1343
+ let message26 = error;
1335
1344
  if (form && name) {
1336
1345
  const {
1337
1346
  formState: { errors }
1338
1347
  } = form;
1339
1348
  const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
1340
- message24 = errorObj?.message;
1349
+ message26 = errorObj?.message;
1341
1350
  }
1342
1351
  const watchedValue = form?.watch(name);
1343
1352
  useEffect7(() => {
@@ -1406,7 +1415,7 @@ var Input = forwardRef(
1406
1415
  }
1407
1416
  )
1408
1417
  ] }),
1409
- message24 && /* @__PURE__ */ jsx16("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
1418
+ message26 && /* @__PURE__ */ jsx16("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
1410
1419
  ]
1411
1420
  }
1412
1421
  );
@@ -1731,7 +1740,7 @@ var PhoneInput = forwardRef2(
1731
1740
  const [isFocused, setIsFocused] = useState12(false);
1732
1741
  const { theme } = useWarqadConfig();
1733
1742
  const primaryColor = theme?.primaryColor;
1734
- let message24 = error;
1743
+ let message26 = error;
1735
1744
  if (form && name) {
1736
1745
  const {
1737
1746
  formState: { errors }
@@ -1741,7 +1750,7 @@ var PhoneInput = forwardRef2(
1741
1750
  for (const part of nameParts) {
1742
1751
  currentError = currentError?.[part];
1743
1752
  }
1744
- message24 = currentError?.message || message24;
1753
+ message26 = currentError?.message || message26;
1745
1754
  }
1746
1755
  const renderInput = (onChangeHandler, currentValue) => /* @__PURE__ */ jsxs15("div", { className: `space-y-2 group relative ${containerClassName}`, children: [
1747
1756
  /* @__PURE__ */ jsxs15(
@@ -1792,7 +1801,7 @@ var PhoneInput = forwardRef2(
1792
1801
  }
1793
1802
  )
1794
1803
  ] }),
1795
- message24 && /* @__PURE__ */ jsx20("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
1804
+ message26 && /* @__PURE__ */ jsx20("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
1796
1805
  ] });
1797
1806
  if (form && name) {
1798
1807
  return /* @__PURE__ */ jsx20(
@@ -1844,7 +1853,8 @@ var Select = forwardRef3((props, ref) => {
1844
1853
  children,
1845
1854
  options: initialOptions = [],
1846
1855
  enum: enumData,
1847
- enumName
1856
+ enumName,
1857
+ ...rest
1848
1858
  } = props;
1849
1859
  const options = useMemo4(() => {
1850
1860
  if (initialOptions.length > 0) return initialOptions;
@@ -1881,7 +1891,7 @@ var Select = forwardRef3((props, ref) => {
1881
1891
  }) => /* @__PURE__ */ jsx21(
1882
1892
  SelectRoot,
1883
1893
  {
1884
- ...props,
1894
+ ...rest,
1885
1895
  options,
1886
1896
  currentValue: formValue,
1887
1897
  onChangeHandler: (val) => {
@@ -1898,7 +1908,7 @@ var Select = forwardRef3((props, ref) => {
1898
1908
  return /* @__PURE__ */ jsx21(
1899
1909
  SelectRoot,
1900
1910
  {
1901
- ...props,
1911
+ ...rest,
1902
1912
  options,
1903
1913
  currentValue: value,
1904
1914
  onChangeHandler: onChange || (() => {
@@ -1926,6 +1936,8 @@ var SelectRoot = ({
1926
1936
  disabled,
1927
1937
  id,
1928
1938
  className = "",
1939
+ enum: enumData,
1940
+ enumName,
1929
1941
  ...props
1930
1942
  }) => {
1931
1943
  const [isOpen, setIsOpen] = useState13(false);
@@ -1970,7 +1982,7 @@ var SelectRoot = ({
1970
1982
  document.addEventListener("mousedown", handleClickOutside);
1971
1983
  return () => document.removeEventListener("mousedown", handleClickOutside);
1972
1984
  }, [fieldInternalProps]);
1973
- let message24 = error;
1985
+ let message26 = error;
1974
1986
  if (form && name) {
1975
1987
  const {
1976
1988
  formState: { errors }
@@ -1980,7 +1992,7 @@ var SelectRoot = ({
1980
1992
  for (const part of nameParts) {
1981
1993
  currentError = currentError?.[part];
1982
1994
  }
1983
- message24 = currentError?.message || message24;
1995
+ message26 = currentError?.message || message26;
1984
1996
  }
1985
1997
  const allOptions = initialOptions?.length ? initialOptions : registeredOptions;
1986
1998
  const valueCtx = {
@@ -2041,7 +2053,7 @@ var SelectRoot = ({
2041
2053
  String(opt.value) || index
2042
2054
  )) })
2043
2055
  ] }),
2044
- message24 && /* @__PURE__ */ jsx21("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
2056
+ message26 && /* @__PURE__ */ jsx21("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
2045
2057
  ]
2046
2058
  }
2047
2059
  ) });
@@ -2279,13 +2291,13 @@ var Textarea = forwardRef4(
2279
2291
  const [isFocused, setIsFocused] = useState14(false);
2280
2292
  const { theme } = useWarqadConfig();
2281
2293
  const primaryColor = theme?.primaryColor;
2282
- let message24 = error;
2294
+ let message26 = error;
2283
2295
  if (form && name) {
2284
2296
  const {
2285
2297
  formState: { errors }
2286
2298
  } = form;
2287
2299
  const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
2288
- message24 = errorObj?.message;
2300
+ message26 = errorObj?.message;
2289
2301
  }
2290
2302
  const renderInput = (inputProps, ref2) => /* @__PURE__ */ jsxs17("div", { className: `space-y-2 group w-full! relative ${containerClassName}`, children: [
2291
2303
  /* @__PURE__ */ jsxs17(
@@ -2323,7 +2335,7 @@ var Textarea = forwardRef4(
2323
2335
  }
2324
2336
  }
2325
2337
  ) }),
2326
- message24 && /* @__PURE__ */ jsx22("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
2338
+ message26 && /* @__PURE__ */ jsx22("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
2327
2339
  ] });
2328
2340
  useEffect9(() => {
2329
2341
  if (form && name && props.value !== void 0 && props.value !== null && props.value !== "") {
@@ -2649,7 +2661,7 @@ var SearchApiRoot = ({
2649
2661
  const filteredOptions = options.filter(
2650
2662
  (option) => !filter.includes(getOptionValue(option))
2651
2663
  );
2652
- let message24 = error || errorMessage;
2664
+ let message26 = error || errorMessage;
2653
2665
  if (form && name) {
2654
2666
  const {
2655
2667
  formState: { errors }
@@ -2659,7 +2671,7 @@ var SearchApiRoot = ({
2659
2671
  for (const part of nameParts) {
2660
2672
  currentError = currentError?.[part];
2661
2673
  }
2662
- message24 = currentError?.message || message24;
2674
+ message26 = currentError?.message || message26;
2663
2675
  }
2664
2676
  const valueCtx = {
2665
2677
  isOpen,
@@ -2693,7 +2705,7 @@ var SearchApiRoot = ({
2693
2705
  form,
2694
2706
  name,
2695
2707
  obj,
2696
- error: message24,
2708
+ error: message26,
2697
2709
  onSelect,
2698
2710
  onClear
2699
2711
  };
@@ -3062,19 +3074,19 @@ var DateInput = forwardRef6(
3062
3074
  const { theme } = useWarqadConfig();
3063
3075
  const primaryColor = theme?.primaryColor;
3064
3076
  const [isFocused, setIsFocused] = useState16(false);
3065
- let message24 = error;
3077
+ let message26 = error;
3066
3078
  if (form && name) {
3067
3079
  const {
3068
3080
  formState: { errors }
3069
3081
  } = form;
3070
3082
  const errorObj = name.split(".").reduce((acc, current) => acc?.[current], errors);
3071
- message24 = errorObj?.message;
3083
+ message26 = errorObj?.message;
3072
3084
  }
3073
3085
  const inputStyles = `w-full px-2.5 py-1 rounded-md border! shadow-none transition-all! duration-200! outline-none!
3074
3086
  bg-white! dark:bg-zinc-900!
3075
3087
  text-gray-900! dark:text-zinc-100!
3076
3088
  hover:bg-white! dark:hover:bg-zinc-900!
3077
- ${message24 ? "border-red-500 hover:border-red-500 [&.ant-picker-focused]:border-red-500 [&.ant-picker-focused]:ring-red-500/20" : "border-gray-200 dark:border-zinc-700 hover:border-gray-200 dark:hover:border-zinc-700 [&.ant-picker-focused]:ring-2"}
3089
+ ${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"}
3078
3090
  [&.ant-picker-focused]:bg-white dark:[&.ant-picker-focused]:bg-zinc-900
3079
3091
  ${className}`;
3080
3092
  const renderDatePicker = (val, changeHandler, blurHandler, refProps) => {
@@ -3097,8 +3109,8 @@ var DateInput = forwardRef6(
3097
3109
  needConfirm: false,
3098
3110
  style: {
3099
3111
  height: "var(--input-height, 40px)",
3100
- borderColor: isFocused && !message24 ? primaryColor : void 0,
3101
- boxShadow: isFocused && !message24 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
3112
+ borderColor: isFocused && !message26 ? primaryColor : void 0,
3113
+ boxShadow: isFocused && !message26 ? `${primaryColor}33 0px 0px 0px 2px` : void 0
3102
3114
  },
3103
3115
  classNames: { popup: { root: "z-50" } },
3104
3116
  suffixIcon: /* @__PURE__ */ jsx24(
@@ -3128,7 +3140,7 @@ var DateInput = forwardRef6(
3128
3140
  {
3129
3141
  className: "block text-xs font-medium transition-colors duration-200",
3130
3142
  style: {
3131
- color: message24 ? "#ef4444" : isFocused ? primaryColor : void 0
3143
+ color: message26 ? "#ef4444" : isFocused ? primaryColor : void 0
3132
3144
  },
3133
3145
  children: [
3134
3146
  label,
@@ -3149,7 +3161,7 @@ var DateInput = forwardRef6(
3149
3161
  )
3150
3162
  }
3151
3163
  ) : renderDatePicker(value, onChange, onBlur, ref),
3152
- message24 && /* @__PURE__ */ jsx24("p", { className: "text-sm text-red-600 dark:text-red-400", children: message24 })
3164
+ message26 && /* @__PURE__ */ jsx24("p", { className: "text-sm text-red-600 dark:text-red-400", children: message26 })
3153
3165
  ] });
3154
3166
  }
3155
3167
  );
@@ -3173,7 +3185,8 @@ var Fields = {
3173
3185
  var Fields_default = Fields;
3174
3186
 
3175
3187
  // src/components/tables/DataTable.tsx
3176
- import React10, { useState as useState17, useMemo as useMemo5, useEffect as useEffect11 } from "react";
3188
+ import React10, { useState as useState17, useMemo as useMemo5, useEffect as useEffect11, useRef as useRef5 } from "react";
3189
+ import { createPortal as createPortal4 } from "react-dom";
3177
3190
  import {
3178
3191
  useReactTable,
3179
3192
  getCoreRowModel,
@@ -3233,6 +3246,43 @@ function DataTable({
3233
3246
  setPagination((prev) => ({ ...prev, pageSize: pageRows }));
3234
3247
  }
3235
3248
  }, [pageRows]);
3249
+ const [isVisibilityOpen, setIsVisibilityOpen] = useState17(false);
3250
+ const visibilityAnchorRef = useRef5(null);
3251
+ const visibilityContentRef = useRef5(null);
3252
+ const [visibilityCoords, setVisibilityCoords] = useState17({
3253
+ top: 0,
3254
+ left: 0,
3255
+ width: 0
3256
+ });
3257
+ const updateVisibilityPosition = () => {
3258
+ if (visibilityAnchorRef.current) {
3259
+ const rect = visibilityAnchorRef.current.getBoundingClientRect();
3260
+ setVisibilityCoords({
3261
+ top: rect.bottom,
3262
+ left: rect.left,
3263
+ width: rect.width
3264
+ });
3265
+ }
3266
+ };
3267
+ useEffect11(() => {
3268
+ if (isVisibilityOpen) {
3269
+ updateVisibilityPosition();
3270
+ const handleScroll = () => updateVisibilityPosition();
3271
+ window.addEventListener("scroll", handleScroll, true);
3272
+ window.addEventListener("resize", handleScroll);
3273
+ const handleClickOutside = (event) => {
3274
+ if (visibilityAnchorRef.current && !visibilityAnchorRef.current.contains(event.target) && visibilityContentRef.current && !visibilityContentRef.current.contains(event.target)) {
3275
+ setIsVisibilityOpen(false);
3276
+ }
3277
+ };
3278
+ document.addEventListener("mousedown", handleClickOutside);
3279
+ return () => {
3280
+ window.removeEventListener("scroll", handleScroll, true);
3281
+ window.removeEventListener("resize", handleScroll);
3282
+ document.removeEventListener("mousedown", handleClickOutside);
3283
+ };
3284
+ }
3285
+ }, [isVisibilityOpen]);
3236
3286
  const [expanded, setExpanded] = useState17(() => {
3237
3287
  const initialState = {};
3238
3288
  if (defaultExpanded && renderSubComponent && data) {
@@ -3331,31 +3381,59 @@ function DataTable({
3331
3381
  className: "h-9!"
3332
3382
  }
3333
3383
  ) }),
3334
- /* @__PURE__ */ jsx25("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxs20("div", { className: "relative group", children: [
3335
- /* @__PURE__ */ jsxs20("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: [
3336
- "Columns",
3337
- /* @__PURE__ */ jsx25(ChevronDown4, { size: 14, className: "text-gray-400" })
3338
- ] }),
3339
- /* @__PURE__ */ jsx25("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__ */ jsxs20(
3340
- "label",
3384
+ /* @__PURE__ */ jsx25("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxs20("div", { className: "relative", ref: visibilityAnchorRef, children: [
3385
+ /* @__PURE__ */ jsxs20(
3386
+ "button",
3341
3387
  {
3342
- 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",
3388
+ onClick: () => setIsVisibilityOpen(!isVisibilityOpen),
3389
+ 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",
3343
3390
  children: [
3391
+ "Columns",
3344
3392
  /* @__PURE__ */ jsx25(
3345
- "input",
3393
+ ChevronDown4,
3346
3394
  {
3347
- type: "checkbox",
3348
- checked: column.getIsVisible(),
3349
- onChange: (e) => column.toggleVisibility(!!e.target.checked),
3350
- className: "rounded border-gray-300 text-blue-600 focus:ring-blue-500",
3351
- style: { accentColor: primaryColor }
3395
+ size: 14,
3396
+ className: `text-gray-400 transition-transform ${isVisibilityOpen ? "rotate-180" : ""}`
3352
3397
  }
3353
- ),
3354
- column.id
3398
+ )
3355
3399
  ]
3356
- },
3357
- column.id
3358
- )) })
3400
+ }
3401
+ ),
3402
+ isVisibilityOpen && createPortal4(
3403
+ /* @__PURE__ */ jsx25(
3404
+ "div",
3405
+ {
3406
+ ref: visibilityContentRef,
3407
+ 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]",
3408
+ style: {
3409
+ top: `${visibilityCoords.top}px`,
3410
+ left: `${visibilityCoords.left + visibilityCoords.width - 192}px`
3411
+ // 192px is w-48
3412
+ },
3413
+ children: /* @__PURE__ */ jsx25("div", { className: "max-h-64 overflow-y-auto", children: table.getAllColumns().filter((column) => column.getCanHide()).map((column) => /* @__PURE__ */ jsxs20(
3414
+ "label",
3415
+ {
3416
+ 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",
3417
+ children: [
3418
+ /* @__PURE__ */ jsx25(
3419
+ "input",
3420
+ {
3421
+ type: "checkbox",
3422
+ checked: column.getIsVisible(),
3423
+ onChange: (e) => column.toggleVisibility(!!e.target.checked),
3424
+ className: "rounded border-gray-300 text-blue-600 focus:ring-blue-500",
3425
+ style: { accentColor: primaryColor }
3426
+ }
3427
+ ),
3428
+ column.id
3429
+ ]
3430
+ },
3431
+ column.id
3432
+ )) })
3433
+ }
3434
+ ),
3435
+ document.body
3436
+ )
3359
3437
  ] }) })
3360
3438
  ] }),
3361
3439
  /* @__PURE__ */ jsx25("div", { className: "rounded-lg border border-gray-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 overflow-hidden relative", children: /* @__PURE__ */ jsx25("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs20(
@@ -3496,7 +3574,7 @@ import React11, {
3496
3574
  useState as useState18,
3497
3575
  useMemo as useMemo6,
3498
3576
  useEffect as useEffect12,
3499
- useRef as useRef5,
3577
+ useRef as useRef6,
3500
3578
  useCallback as useCallback3
3501
3579
  } from "react";
3502
3580
  import {
@@ -3628,7 +3706,7 @@ function PostTable({
3628
3706
  const [internalData, setInternalData] = useState18(controlledData || []);
3629
3707
  const isControlled = controlledData !== void 0;
3630
3708
  const data = isControlled ? controlledData : internalData;
3631
- const entryRowRef = useRef5(null);
3709
+ const entryRowRef = useRef6(null);
3632
3710
  useEffect12(() => {
3633
3711
  if (defaultExpanded && renderSubComponent && (data || []).length > 0) {
3634
3712
  setExpanded((prev) => {
@@ -3670,7 +3748,7 @@ function PostTable({
3670
3748
  const [editingIndex, setEditingIndex] = useState18(null);
3671
3749
  const [isSavingAsync, setIsSavingAsync] = useState18(false);
3672
3750
  const [fieldErrors, setFieldErrors] = useState18({});
3673
- const latestStateRef = useRef5({
3751
+ const latestStateRef = useRef6({
3674
3752
  data,
3675
3753
  entryData,
3676
3754
  editingIndex,
@@ -5051,8 +5129,8 @@ var useLogin = (props) => {
5051
5129
  import { useState as useState21 } from "react";
5052
5130
 
5053
5131
  // src/components/Dropdown.tsx
5054
- import { useState as useState20, useRef as useRef6, useEffect as useEffect13, useLayoutEffect } from "react";
5055
- import { createPortal as createPortal4 } from "react-dom";
5132
+ import { useState as useState20, useRef as useRef7, useEffect as useEffect13, useLayoutEffect } from "react";
5133
+ import { createPortal as createPortal5 } from "react-dom";
5056
5134
  import { jsx as jsx34, jsxs as jsxs26 } from "react/jsx-runtime";
5057
5135
  var Dropdown = ({
5058
5136
  children,
@@ -5065,7 +5143,7 @@ var Dropdown = ({
5065
5143
  onOpenChange
5066
5144
  }) => {
5067
5145
  const [isOpen, setIsOpen] = useState20(false);
5068
- const triggerRef = useRef6(null);
5146
+ const triggerRef = useRef7(null);
5069
5147
  const [coords, setCoords] = useState20({ top: 0, left: 0, right: 0 });
5070
5148
  const [loadingItems, setLoadingItems] = useState20({});
5071
5149
  const updateCoords = () => {
@@ -5152,7 +5230,7 @@ var Dropdown = ({
5152
5230
  children
5153
5231
  }
5154
5232
  ),
5155
- isOpen && createPortal4(
5233
+ isOpen && createPortal5(
5156
5234
  /* @__PURE__ */ jsx34(
5157
5235
  "div",
5158
5236
  {
@@ -5337,7 +5415,7 @@ var ProfileDropdown = ({
5337
5415
  };
5338
5416
 
5339
5417
  // src/hooks/Fetches/useA4DataView.tsx
5340
- import { useEffect as useEffect14, useRef as useRef7, useState as useState22 } from "react";
5418
+ import { useEffect as useEffect14, useRef as useRef8, useState as useState22 } from "react";
5341
5419
  import { useReactToPrint } from "react-to-print";
5342
5420
  import {
5343
5421
  RefreshCw,
@@ -5356,7 +5434,7 @@ var useA4StatementView = ({
5356
5434
  startPage = 1
5357
5435
  } = {}) => {
5358
5436
  const { data: apiData, isLoading, get, error: apiError } = useApis_default();
5359
- const contentRef = useRef7(null);
5437
+ const contentRef = useRef8(null);
5360
5438
  const reactToPrintFn = useReactToPrint({
5361
5439
  contentRef
5362
5440
  });
@@ -5397,7 +5475,7 @@ var useA4StatementView = ({
5397
5475
  }) => {
5398
5476
  const { store } = useWarqadConfig();
5399
5477
  const isActuallyLoading = externalLoading ?? isLoading;
5400
- const measureContainerRef = useRef7(null);
5478
+ const measureContainerRef = useRef8(null);
5401
5479
  const [pages, setPages] = useState22([]);
5402
5480
  const [isMeasuring, setIsMeasuring] = useState22(true);
5403
5481
  const [globalFilter, setGlobalFilter] = useState22("");
@@ -5765,7 +5843,7 @@ var useA4StatementView = ({
5765
5843
  var useA4DataView_default = useA4StatementView;
5766
5844
 
5767
5845
  // src/hooks/Fetches/useA4CategoryView.tsx
5768
- import { useEffect as useEffect15, useRef as useRef8, useState as useState23 } from "react";
5846
+ import { useEffect as useEffect15, useRef as useRef9, useState as useState23 } from "react";
5769
5847
  import { useReactToPrint as useReactToPrint2 } from "react-to-print";
5770
5848
  import {
5771
5849
  RefreshCw as RefreshCw2,
@@ -5784,7 +5862,7 @@ var useA4CategoryView = ({
5784
5862
  startPage = 1
5785
5863
  } = {}) => {
5786
5864
  const { data: apiData, isLoading, get, error: apiError } = useApis_default();
5787
- const contentRef = useRef8(null);
5865
+ const contentRef = useRef9(null);
5788
5866
  const reactToPrintFn = useReactToPrint2({
5789
5867
  contentRef
5790
5868
  });
@@ -5812,7 +5890,7 @@ var useA4CategoryView = ({
5812
5890
  }) => {
5813
5891
  const { store } = useWarqadConfig();
5814
5892
  const isActuallyLoading = externalLoading ?? isLoading;
5815
- const measureContainerRef = useRef8(null);
5893
+ const measureContainerRef = useRef9(null);
5816
5894
  const [pages, setPages] = useState23([]);
5817
5895
  const [isMeasuring, setIsMeasuring] = useState23(true);
5818
5896
  const [globalFilter, setGlobalFilter] = useState23("");
@@ -7474,17 +7552,17 @@ var preWarningFns = [];
7474
7552
  var preMessage = (fn) => {
7475
7553
  preWarningFns.push(fn);
7476
7554
  };
7477
- function warning(valid, message24) {
7555
+ function warning(valid, message26) {
7478
7556
  if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
7479
- const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message24);
7557
+ const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "warning"), message26);
7480
7558
  if (finalMessage) {
7481
7559
  console.error(`Warning: ${finalMessage}`);
7482
7560
  }
7483
7561
  }
7484
7562
  }
7485
- function note(valid, message24) {
7563
+ function note(valid, message26) {
7486
7564
  if (process.env.NODE_ENV !== "production" && !valid && console !== void 0) {
7487
- const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message24);
7565
+ const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? "", "note"), message26);
7488
7566
  if (finalMessage) {
7489
7567
  console.warn(`Note: ${finalMessage}`);
7490
7568
  }
@@ -7493,17 +7571,17 @@ function note(valid, message24) {
7493
7571
  function resetWarned() {
7494
7572
  warned = {};
7495
7573
  }
7496
- function call(method, valid, message24) {
7497
- if (!valid && !warned[message24]) {
7498
- method(false, message24);
7499
- warned[message24] = true;
7574
+ function call(method, valid, message26) {
7575
+ if (!valid && !warned[message26]) {
7576
+ method(false, message26);
7577
+ warned[message26] = true;
7500
7578
  }
7501
7579
  }
7502
- function warningOnce(valid, message24) {
7503
- call(warning, valid, message24);
7580
+ function warningOnce(valid, message26) {
7581
+ call(warning, valid, message26);
7504
7582
  }
7505
- function noteOnce(valid, message24) {
7506
- call(note, valid, message24);
7583
+ function noteOnce(valid, message26) {
7584
+ call(note, valid, message26);
7507
7585
  }
7508
7586
  warningOnce.preMessage = preMessage;
7509
7587
  warningOnce.resetWarned = resetWarned;
@@ -7514,8 +7592,8 @@ import React19, { useContext as useContext5, useEffect as useEffect17 } from "re
7514
7592
  function camelCase(input) {
7515
7593
  return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
7516
7594
  }
7517
- function warning2(valid, message24) {
7518
- warningOnce(valid, `[@ant-design/icons] ${message24}`);
7595
+ function warning2(valid, message26) {
7596
+ warningOnce(valid, `[@ant-design/icons] ${message26}`);
7519
7597
  }
7520
7598
  function isIconDefinition(target) {
7521
7599
  return typeof target === "object" && typeof target.name === "string" && typeof target.theme === "string" && (typeof target.icon === "object" || typeof target.icon === "function");
@@ -8254,7 +8332,8 @@ var createAccountSchema = z2.object({
8254
8332
  }).transform((val) => val?.toLowerCase()),
8255
8333
  phoneNumber: z2.string().optional(),
8256
8334
  sex: z2.enum(Enums_default.sex),
8257
- branch: z2.string().optional()
8335
+ branch: z2.string().optional(),
8336
+ currency: z2.string().optional()
8258
8337
  });
8259
8338
 
8260
8339
  // src/components/accounts/AccountForm.tsx
@@ -8311,10 +8390,10 @@ var useAccountbalance = ({
8311
8390
  try {
8312
8391
  const res = await get({
8313
8392
  url,
8314
- v: 2
8393
+ v: 1
8315
8394
  });
8316
- const data = res;
8317
- setBalance(Formats_default.Price(data?.balance, data?.currency));
8395
+ const data = res?.data;
8396
+ setBalance(Formats_default.Price(data?.balance ?? 0, data?.currency ?? "N/A"));
8318
8397
  } catch (error2) {
8319
8398
  setError(error2.message);
8320
8399
  }
@@ -8368,7 +8447,8 @@ function Account({
8368
8447
  v = 1,
8369
8448
  showBalance,
8370
8449
  required,
8371
- disabled
8450
+ disabled,
8451
+ obj
8372
8452
  }) {
8373
8453
  const { branchId } = useParams3();
8374
8454
  const accountId = form?.watch(name);
@@ -8392,7 +8472,8 @@ function Account({
8392
8472
  labelKey: "name",
8393
8473
  valueKey: "_id",
8394
8474
  required,
8395
- disabled
8475
+ disabled,
8476
+ obj
8396
8477
  }
8397
8478
  ),
8398
8479
  /* @__PURE__ */ jsx45(BalanceView, {})
@@ -8412,7 +8493,8 @@ function Customer({
8412
8493
  showBalance,
8413
8494
  required,
8414
8495
  disabled,
8415
- v
8496
+ v,
8497
+ obj
8416
8498
  }) {
8417
8499
  return /* @__PURE__ */ jsx46(
8418
8500
  Account_default,
@@ -8426,7 +8508,8 @@ function Customer({
8426
8508
  filter,
8427
8509
  showBalance,
8428
8510
  required,
8429
- disabled
8511
+ disabled,
8512
+ obj
8430
8513
  }
8431
8514
  );
8432
8515
  }
@@ -8444,6 +8527,7 @@ function Employee({
8444
8527
  showBalance,
8445
8528
  required,
8446
8529
  disabled,
8530
+ obj,
8447
8531
  v
8448
8532
  }) {
8449
8533
  return /* @__PURE__ */ jsx47(
@@ -8458,7 +8542,8 @@ function Employee({
8458
8542
  filter,
8459
8543
  required,
8460
8544
  disabled,
8461
- showBalance
8545
+ showBalance,
8546
+ obj
8462
8547
  }
8463
8548
  );
8464
8549
  }
@@ -8526,7 +8611,8 @@ function AccountForm() {
8526
8611
  name: "",
8527
8612
  email: "",
8528
8613
  phoneNumber: "",
8529
- sex: "male"
8614
+ sex: "male",
8615
+ currency: ""
8530
8616
  },
8531
8617
  shouldUnregister: false
8532
8618
  });
@@ -8636,6 +8722,15 @@ function AccountForm() {
8636
8722
  placeholder: "Select Branch",
8637
8723
  api: "/branches/get?noStore=true"
8638
8724
  }
8725
+ ),
8726
+ /* @__PURE__ */ jsx49(
8727
+ Fields_default.Select,
8728
+ {
8729
+ label: "Currency",
8730
+ form: methods,
8731
+ name: "currency",
8732
+ enumName: "currencies"
8733
+ }
8639
8734
  )
8640
8735
  ] }),
8641
8736
  /* @__PURE__ */ jsx49("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ jsx49(
@@ -11362,29 +11457,527 @@ function Pack({
11362
11457
  }
11363
11458
  var Pack_default = { Pack };
11364
11459
 
11460
+ // src/components/journals/Journals.tsx
11461
+ import { useNavigate as useNavigate15, useParams as useParams16 } from "react-router-dom";
11462
+ import { EllipsisVertical as EllipsisVertical8, FilePenLine as FilePenLine7, Trash2 as Trash29 } from "lucide-react";
11463
+ import { useState as useState38 } from "react";
11464
+ import { message as message24 } from "antd";
11465
+ import { Fragment as Fragment18, jsx as jsx75, jsxs as jsxs57 } from "react/jsx-runtime";
11466
+ function Journals({ url }) {
11467
+ const { branchId } = useParams16();
11468
+ const navigate = useNavigate15();
11469
+ const [deleteJournal, setDeleteJournal] = useState38(null);
11470
+ const { isLoading, remove } = useApis_default();
11471
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
11472
+ url: url || `/transactions/get?type=journal${branchId ? `&branch=${branchId}` : ""}`,
11473
+ dateFilter: true
11474
+ });
11475
+ const { Modal: Modal2 } = useModal();
11476
+ const items = (data2) => [
11477
+ {
11478
+ label: `Edit Journal`,
11479
+ icon: /* @__PURE__ */ jsx75(FilePenLine7, { size: 16 }),
11480
+ onClick: () => navigate(`update?id=${data2?._id}`)
11481
+ },
11482
+ {
11483
+ label: `Delete Journal`,
11484
+ icon: /* @__PURE__ */ jsx75(Trash29, { className: "text-red-500", size: 16 }),
11485
+ onClick: () => setDeleteJournal(data2)
11486
+ }
11487
+ ].filter(Boolean);
11488
+ const columns = [
11489
+ {
11490
+ accessorKey: "date",
11491
+ header: "Date",
11492
+ cell: ({ row }) => {
11493
+ const journal = row.original;
11494
+ return /* @__PURE__ */ jsx75("span", { children: journal?.date });
11495
+ }
11496
+ },
11497
+ {
11498
+ accessorKey: "account",
11499
+ header: "Account",
11500
+ cell: ({ row }) => {
11501
+ const journal = row.original;
11502
+ return /* @__PURE__ */ jsx75("span", { children: journal?.accountData?.name || "N/A" });
11503
+ }
11504
+ },
11505
+ {
11506
+ accessorKey: "amount",
11507
+ header: "Amount",
11508
+ cell: ({ row }) => {
11509
+ const journal = row.original;
11510
+ return /* @__PURE__ */ jsxs57("div", { className: "flex flex-col", children: [
11511
+ /* @__PURE__ */ jsx75("span", { children: Formats_default.Price(journal?.amount, journal?.currency) }),
11512
+ journal?.fee && /* @__PURE__ */ jsxs57("span", { className: "text-xs text-green-600", children: [
11513
+ "with fee: ",
11514
+ Formats_default.Price(journal?.feeAmount, journal?.currency)
11515
+ ] }),
11516
+ journal?.exchange?.rate && /* @__PURE__ */ jsxs57("span", { className: "text-xs text-green-600", children: [
11517
+ "Exchanged:",
11518
+ " ",
11519
+ Formats_default.Price(
11520
+ journal?.exchange?.amount,
11521
+ journal?.exchange?.currency
11522
+ )
11523
+ ] })
11524
+ ] });
11525
+ }
11526
+ },
11527
+ {
11528
+ accessorKey: "journal",
11529
+ header: "Type",
11530
+ cell: ({ row }) => {
11531
+ const journal = row.original;
11532
+ return /* @__PURE__ */ jsx75("span", { className: "capitalize", children: journal?.journal });
11533
+ }
11534
+ },
11535
+ {
11536
+ accessorKey: "journalVia",
11537
+ header: "Via",
11538
+ cell: ({ row }) => {
11539
+ const journal = row.original;
11540
+ return /* @__PURE__ */ jsxs57("div", { className: "", children: [
11541
+ /* @__PURE__ */ jsx75("p", { className: "capitalize", children: journal?.journalVia }),
11542
+ journal?.journalVia === "via account" && /* @__PURE__ */ jsx75("p", { className: "capitalize text-xs text-gray-600", children: journal?.viaAccountData?.name })
11543
+ ] });
11544
+ }
11545
+ },
11546
+ {
11547
+ accessorKey: "action",
11548
+ header: "Action",
11549
+ cell: ({ row }) => {
11550
+ const journal = row.original;
11551
+ return /* @__PURE__ */ jsx75("span", { className: "capitalize", children: journal?.action });
11552
+ }
11553
+ },
11554
+ {
11555
+ accessorKey: "actions",
11556
+ header: "Actions",
11557
+ cell: ({ row }) => {
11558
+ const data2 = row.original;
11559
+ return /* @__PURE__ */ jsx75(
11560
+ Dropdown,
11561
+ {
11562
+ className: "cursor-pointer w-[150px]",
11563
+ items: items(data2),
11564
+ triggerMode: "hover",
11565
+ children: /* @__PURE__ */ jsx75(EllipsisVertical8, {})
11566
+ }
11567
+ );
11568
+ }
11569
+ }
11570
+ ];
11571
+ const journals = data?.data || [];
11572
+ const onDelete = async (id) => {
11573
+ try {
11574
+ await remove({ url: `/journals/delete/${id}` });
11575
+ message24.success("Journal deleted successfully");
11576
+ reload();
11577
+ setDeleteJournal(null);
11578
+ } catch (error) {
11579
+ message24.error(error.message || "Something went wrong");
11580
+ return error;
11581
+ }
11582
+ };
11583
+ return /* @__PURE__ */ jsxs57(Fragment18, { children: [
11584
+ /* @__PURE__ */ jsx75(Modal2, {}),
11585
+ /* @__PURE__ */ jsx75(
11586
+ ConfirmModal,
11587
+ {
11588
+ isOpen: !!deleteJournal,
11589
+ isLoading,
11590
+ onClose: () => setDeleteJournal(null),
11591
+ title: `Delete Journal`,
11592
+ description: `Are you sure you want to delete this journal entry of "${deleteJournal?.amount}"? This action cannot be undone.`,
11593
+ confirmationWord: "delete",
11594
+ onSubmit: () => onDelete(deleteJournal?._id),
11595
+ children: null
11596
+ }
11597
+ ),
11598
+ /* @__PURE__ */ jsx75(
11599
+ TransactionViewComponent,
11600
+ {
11601
+ columns,
11602
+ data: journals,
11603
+ title: "Journals",
11604
+ description: "Manage your journal entries",
11605
+ index: true,
11606
+ createTitle: "Add Journal",
11607
+ onCreate: () => {
11608
+ navigate("create");
11609
+ }
11610
+ }
11611
+ )
11612
+ ] });
11613
+ }
11614
+ var Journals_default = Journals;
11615
+
11616
+ // src/utils/zod.ts
11617
+ import moment2 from "moment";
11618
+ import { z as z10 } from "zod";
11619
+ var zodFields = {
11620
+ date: z10.string().regex(
11621
+ /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/\d{4}$/,
11622
+ "Date must be in format DD/MM/YYYY"
11623
+ ).refine((val) => moment2(val, "DD/MM/YYYY", true).isValid(), {
11624
+ message: "Date is not a valid calendar date"
11625
+ })
11626
+ };
11627
+
11628
+ // src/components/journals/schema.ts
11629
+ import { z as z11 } from "zod";
11630
+ var journalSchema = z11.object({
11631
+ date: zodFields.date,
11632
+ amount: z11.number().gt(0, "Amount must be greater than 0"),
11633
+ account: z11.string(),
11634
+ description: z11.string(),
11635
+ journalVia: z11.enum(Enums_default.viaTypes),
11636
+ action: z11.enum(Enums_default.actionTypes).optional(),
11637
+ viaAccount: z11.string().optional(),
11638
+ viaAccountObject: z11.any().optional(),
11639
+ accountObject: z11.any().optional(),
11640
+ //exchange
11641
+ rate: z11.coerce.number().gte(0).optional(),
11642
+ exchangedAmount: z11.coerce.number().gte(0).optional(),
11643
+ fee: z11.coerce.number().gte(0)
11644
+ });
11645
+
11646
+ // src/components/journals/JournalForm.tsx
11647
+ import { useForm as useForm14 } from "react-hook-form";
11648
+ import { zodResolver as zodResolver13 } from "@hookform/resolvers/zod";
11649
+ import { message as message25 } from "antd";
11650
+ import { useEffect as useEffect30, useMemo as useMemo10, useState as useState39 } from "react";
11651
+ import { useParams as useParams17 } from "react-router-dom";
11652
+
11653
+ // src/utils/forex.ts
11654
+ function exchangedAmount({
11655
+ accountCurrency,
11656
+ amount,
11657
+ exchangeRate,
11658
+ transactionCurrency,
11659
+ trunc = false
11660
+ }) {
11661
+ if (!Enums_default.currencies.includes(accountCurrency)) {
11662
+ throw new Error("Invalid account currency");
11663
+ }
11664
+ if (!Enums_default.currencies.includes(transactionCurrency)) {
11665
+ throw new Error("Invalid transaction currency");
11666
+ }
11667
+ let result;
11668
+ if (accountCurrency === transactionCurrency) {
11669
+ result = amount;
11670
+ } else if (accountCurrency === "USD") {
11671
+ result = amount / exchangeRate;
11672
+ } else if (accountCurrency === "CNY") {
11673
+ result = transactionCurrency === "USD" ? amount * exchangeRate : amount / exchangeRate;
11674
+ } else if (accountCurrency === "KES") {
11675
+ result = transactionCurrency === "TZS" ? amount / exchangeRate : amount * exchangeRate;
11676
+ } else if (accountCurrency === "TZS") {
11677
+ result = amount * exchangeRate;
11678
+ } else {
11679
+ throw new Error("Unsupported currency conversion");
11680
+ }
11681
+ return trunc ? Math.trunc(result) : result;
11682
+ }
11683
+ var Forex = {
11684
+ exchangedAmount
11685
+ };
11686
+ var forex_default = Forex;
11687
+
11688
+ // src/components/journals/JournalForm.tsx
11689
+ import { Fragment as Fragment19, jsx as jsx76, jsxs as jsxs58 } from "react/jsx-runtime";
11690
+ function JournalForm({
11691
+ isFee = true,
11692
+ accountType = "all"
11693
+ }) {
11694
+ const { branchId } = useParams17();
11695
+ const { getQuery, navigate } = useApp_default();
11696
+ const id = getQuery("id");
11697
+ const isEdit = !!id;
11698
+ const [ref, setRef] = useState39("");
11699
+ const { post, isLoading } = useApis_default();
11700
+ const { isLoading: isLoadingGet, get } = useApis_default();
11701
+ const methods = useForm14({
11702
+ resolver: zodResolver13(journalSchema),
11703
+ defaultValues: {
11704
+ date: (/* @__PURE__ */ new Date()).toLocaleDateString("en-GB"),
11705
+ amount: 0,
11706
+ account: "",
11707
+ fee: 0,
11708
+ action: "debit",
11709
+ journalVia: "direct"
11710
+ }
11711
+ });
11712
+ const { handleSubmit } = methods;
11713
+ const journalVia = methods.watch("journalVia");
11714
+ const account = methods.watch("account");
11715
+ const viaAccount = methods.watch("viaAccount");
11716
+ const viaAccountObj = methods.watch("viaAccountObject");
11717
+ const accountObj = methods.watch("accountObject");
11718
+ const amount = methods.watch("amount");
11719
+ const fee = methods.watch("fee");
11720
+ const rate = methods.watch("rate");
11721
+ const isRate = accountObj?.currency && viaAccountObj?.currency && accountObj?.currency !== viaAccountObj?.currency;
11722
+ const onSubmit = async (data) => {
11723
+ try {
11724
+ const payload = {
11725
+ ...data,
11726
+ journal: "journal",
11727
+ type: "journal",
11728
+ action: data.journalVia === "via account" ? "debit" : data.action,
11729
+ branch: branchId ?? void 0
11730
+ };
11731
+ await post({
11732
+ url: `/transactions/add${isEdit ? `?ref=${ref}` : ""}`,
11733
+ body: payload
11734
+ });
11735
+ message25.success(`Journal saved successfully`);
11736
+ navigate(-1);
11737
+ } catch (error) {
11738
+ message25.error(error?.message || "Something went wrong");
11739
+ }
11740
+ };
11741
+ const fetches = async () => {
11742
+ try {
11743
+ const res = await get({
11744
+ url: `/transactions/get?id=${id}${branchId ? `&fromBranch=${branchId}` : ""}`
11745
+ });
11746
+ const data = res.data;
11747
+ console.log(data);
11748
+ methods.reset({
11749
+ ...data,
11750
+ rate: data?.exchange?.rate
11751
+ });
11752
+ setRef(data?.ref);
11753
+ } catch (error) {
11754
+ message25.error(error?.message || "Something went wrong");
11755
+ navigate(-1);
11756
+ }
11757
+ };
11758
+ const exchangedAmount2 = useMemo10(() => {
11759
+ if (isRate) {
11760
+ const am = forex_default.exchangedAmount({
11761
+ accountCurrency: accountObj?.currency,
11762
+ amount,
11763
+ exchangeRate: rate ?? 1,
11764
+ transactionCurrency: viaAccountObj?.currency
11765
+ });
11766
+ return Formats_default.Price(am, accountObj?.currency ?? "N/A");
11767
+ }
11768
+ }, [
11769
+ amount,
11770
+ viaAccountObj?.rate,
11771
+ accountObj?.currency,
11772
+ viaAccountObj?.currency,
11773
+ rate
11774
+ ]);
11775
+ const viaAccountAmount = useMemo10(() => {
11776
+ if (fee) {
11777
+ const am = amount + fee / 100 * amount;
11778
+ return Formats_default.Price(
11779
+ am,
11780
+ viaAccountObj?.currency ?? accountObj?.currency ?? "N/A"
11781
+ );
11782
+ } else {
11783
+ return Formats_default.Price(
11784
+ amount,
11785
+ viaAccountObj?.currency ?? accountObj?.currency ?? "N/A"
11786
+ );
11787
+ }
11788
+ }, [fee, amount, viaAccountObj?.currency, accountObj?.currency]);
11789
+ useEffect30(() => {
11790
+ if (isEdit) {
11791
+ fetches();
11792
+ }
11793
+ }, [id]);
11794
+ return /* @__PURE__ */ jsxs58(
11795
+ Card,
11796
+ {
11797
+ className: "max-w-4xl mx-auto mt-10 relative",
11798
+ isLoading: isLoadingGet,
11799
+ loadingText: "Processing...",
11800
+ children: [
11801
+ /* @__PURE__ */ jsxs58(Card.Header, { children: [
11802
+ /* @__PURE__ */ jsx76(Card.Title, { children: `${isEdit ? "Edit" : "Add"} Journal` }),
11803
+ /* @__PURE__ */ jsx76(Card.Description, { children: isEdit ? `Update the details for this journal entry` : `Create a new journal entry` })
11804
+ ] }),
11805
+ /* @__PURE__ */ jsx76(Card.Content, { children: /* @__PURE__ */ jsxs58(
11806
+ "form",
11807
+ {
11808
+ className: "space-y-4",
11809
+ onSubmit: handleSubmit(onSubmit, (errors) => console.log(errors)),
11810
+ children: [
11811
+ /* @__PURE__ */ jsxs58("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
11812
+ /* @__PURE__ */ jsx76(
11813
+ Fields_default.Input,
11814
+ {
11815
+ label: "Description",
11816
+ form: methods,
11817
+ name: "description",
11818
+ placeholder: "Enter description",
11819
+ required: true
11820
+ }
11821
+ ),
11822
+ /* @__PURE__ */ jsx76(
11823
+ Fields_default.Select,
11824
+ {
11825
+ label: "Journal Via",
11826
+ form: methods,
11827
+ name: "journalVia",
11828
+ enumName: "viaTypes",
11829
+ required: true
11830
+ }
11831
+ )
11832
+ ] }),
11833
+ /* @__PURE__ */ jsxs58("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
11834
+ /* @__PURE__ */ jsx76(
11835
+ Fields_default.DateInput,
11836
+ {
11837
+ label: "Date",
11838
+ form: methods,
11839
+ name: "date",
11840
+ required: true
11841
+ }
11842
+ ),
11843
+ journalVia === "via account" && /* @__PURE__ */ jsx76(
11844
+ Feilds_default.Account,
11845
+ {
11846
+ label: "Via Account",
11847
+ form: methods,
11848
+ name: "viaAccount",
11849
+ api: "/accounts/get/all",
11850
+ placeholder: "Search for account...",
11851
+ filter: [account],
11852
+ required: true,
11853
+ obj: "viaAccountObject",
11854
+ showBalance: true
11855
+ }
11856
+ ),
11857
+ /* @__PURE__ */ jsx76(
11858
+ Feilds_default.Account,
11859
+ {
11860
+ label: accountType === "all" ? "Account" : accountType,
11861
+ form: methods,
11862
+ name: "account",
11863
+ api: `/accounts/get/${accountType}`,
11864
+ placeholder: "Search for account...",
11865
+ filter: [viaAccount],
11866
+ required: true,
11867
+ showBalance: true,
11868
+ obj: "accountObject"
11869
+ }
11870
+ ),
11871
+ /* @__PURE__ */ jsx76(
11872
+ Fields_default.Input,
11873
+ {
11874
+ label: "Amount",
11875
+ form: methods,
11876
+ name: "amount",
11877
+ type: "number",
11878
+ placeholder: "0.00",
11879
+ required: true
11880
+ }
11881
+ ),
11882
+ journalVia !== "via account" && /* @__PURE__ */ jsx76(
11883
+ Fields_default.Select,
11884
+ {
11885
+ label: "Action",
11886
+ form: methods,
11887
+ name: "action",
11888
+ enumName: "actionTypes",
11889
+ required: true
11890
+ }
11891
+ ),
11892
+ isRate && /* @__PURE__ */ jsxs58(Fragment19, { children: [
11893
+ /* @__PURE__ */ jsx76(
11894
+ Fields_default.Input,
11895
+ {
11896
+ label: "Rate",
11897
+ type: "number",
11898
+ name: "rate",
11899
+ form: methods,
11900
+ required: true
11901
+ }
11902
+ ),
11903
+ /* @__PURE__ */ jsx76(
11904
+ Fields_default.Input,
11905
+ {
11906
+ label: "Exchanged Amount",
11907
+ type: "text",
11908
+ readOnly: true,
11909
+ disabled: true,
11910
+ value: exchangedAmount2
11911
+ }
11912
+ ),
11913
+ " "
11914
+ ] }),
11915
+ isFee && /* @__PURE__ */ jsxs58(Fragment19, { children: [
11916
+ /* @__PURE__ */ jsx76(
11917
+ Fields_default.Input,
11918
+ {
11919
+ label: "Fee",
11920
+ type: "number",
11921
+ name: "fee",
11922
+ form: methods,
11923
+ required: true
11924
+ }
11925
+ ),
11926
+ /* @__PURE__ */ jsx76(
11927
+ Fields_default.Input,
11928
+ {
11929
+ label: "Amount After Fee",
11930
+ type: "text",
11931
+ readOnly: true,
11932
+ disabled: true,
11933
+ value: viaAccountAmount
11934
+ }
11935
+ )
11936
+ ] })
11937
+ ] }),
11938
+ /* @__PURE__ */ jsx76("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ jsx76(
11939
+ Button,
11940
+ {
11941
+ isLoading,
11942
+ disabled: isLoading,
11943
+ type: "submit",
11944
+ className: "min-w-[100px]",
11945
+ variant: !isEdit ? "primary" : "warning",
11946
+ children: isEdit ? "Update" : "Add"
11947
+ }
11948
+ ) })
11949
+ ]
11950
+ }
11951
+ ) })
11952
+ ]
11953
+ }
11954
+ );
11955
+ }
11956
+ var JournalForm_default = JournalForm;
11957
+
11365
11958
  // src/components/ErrorPage/ErrorPage.tsx
11366
- import { jsx as jsx75, jsxs as jsxs57 } from "react/jsx-runtime";
11959
+ import { jsx as jsx77, jsxs as jsxs59 } from "react/jsx-runtime";
11367
11960
  var ErrorPageBase = ({
11368
11961
  title,
11369
- message: message24,
11962
+ message: message26,
11370
11963
  statusCode,
11371
11964
  action,
11372
11965
  className = ""
11373
11966
  }) => {
11374
- return /* @__PURE__ */ jsx75(
11967
+ return /* @__PURE__ */ jsx77(
11375
11968
  "div",
11376
11969
  {
11377
11970
  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}`,
11378
- children: /* @__PURE__ */ jsxs57("div", { className: "relative flex flex-col items-center justify-center w-full max-w-2xl text-center", children: [
11379
- statusCode && /* @__PURE__ */ jsx75("div", { className: "absolute inset-0 flex items-center justify-center z-0 select-none pointer-events-none opacity-[0.03] dark:opacity-5", children: /* @__PURE__ */ jsx75("span", { className: "text-[12rem] sm:text-[16rem] md:text-[20rem] font-bold leading-none tracking-tighter", children: statusCode }) }),
11380
- /* @__PURE__ */ jsxs57("div", { className: "relative z-10 space-y-6", children: [
11381
- statusCode && /* @__PURE__ */ jsxs57("h2", { className: "text-xl md:text-2xl font-semibold text-zinc-500 dark:text-zinc-400", children: [
11971
+ children: /* @__PURE__ */ jsxs59("div", { className: "relative flex flex-col items-center justify-center w-full max-w-2xl text-center", children: [
11972
+ statusCode && /* @__PURE__ */ jsx77("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__ */ jsx77("span", { className: "text-[12rem] sm:text-[16rem] md:text-[20rem] font-bold leading-none tracking-tighter", children: statusCode }) }),
11973
+ /* @__PURE__ */ jsxs59("div", { className: "relative z-10 space-y-6", children: [
11974
+ statusCode && /* @__PURE__ */ jsxs59("h2", { className: "text-xl md:text-2xl font-semibold text-zinc-500 dark:text-zinc-400", children: [
11382
11975
  "Error ",
11383
11976
  statusCode
11384
11977
  ] }),
11385
- title && /* @__PURE__ */ jsx75("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
11386
- message24 && /* @__PURE__ */ jsx75("p", { className: "text-lg md:text-xl text-zinc-600 dark:text-zinc-400 max-w-md mx-auto", children: message24 }),
11387
- action && /* @__PURE__ */ jsx75("div", { className: "pt-8", children: /* @__PURE__ */ jsx75(
11978
+ title && /* @__PURE__ */ jsx77("h1", { className: "text-4xl md:text-5xl font-extrabold tracking-tight drop-shadow-sm", children: title }),
11979
+ message26 && /* @__PURE__ */ jsx77("p", { className: "text-lg md:text-xl text-zinc-600 dark:text-zinc-400 max-w-md mx-auto", children: message26 }),
11980
+ action && /* @__PURE__ */ jsx77("div", { className: "pt-8", children: /* @__PURE__ */ jsx77(
11388
11981
  "button",
11389
11982
  {
11390
11983
  onClick: action.onClick,
@@ -11400,9 +11993,9 @@ var ErrorPageBase = ({
11400
11993
  };
11401
11994
 
11402
11995
  // src/components/ErrorPage/ErrorPage.500.tsx
11403
- import { jsx as jsx76 } from "react/jsx-runtime";
11996
+ import { jsx as jsx78 } from "react/jsx-runtime";
11404
11997
  var ErrorPage500 = (props) => {
11405
- return /* @__PURE__ */ jsx76(
11998
+ return /* @__PURE__ */ jsx78(
11406
11999
  ErrorPageBase,
11407
12000
  {
11408
12001
  statusCode: 500,
@@ -11415,9 +12008,9 @@ var ErrorPage500 = (props) => {
11415
12008
  };
11416
12009
 
11417
12010
  // src/components/ErrorPage/ErrorPage.404.tsx
11418
- import { jsx as jsx77 } from "react/jsx-runtime";
12011
+ import { jsx as jsx79 } from "react/jsx-runtime";
11419
12012
  var ErrorPage404 = (props) => {
11420
- return /* @__PURE__ */ jsx77(
12013
+ return /* @__PURE__ */ jsx79(
11421
12014
  ErrorPageBase,
11422
12015
  {
11423
12016
  statusCode: 404,
@@ -11430,9 +12023,9 @@ var ErrorPage404 = (props) => {
11430
12023
  };
11431
12024
 
11432
12025
  // src/components/ErrorPage/ErrorPage.401.tsx
11433
- import { jsx as jsx78 } from "react/jsx-runtime";
12026
+ import { jsx as jsx80 } from "react/jsx-runtime";
11434
12027
  var ErrorPage401 = (props) => {
11435
- return /* @__PURE__ */ jsx78(
12028
+ return /* @__PURE__ */ jsx80(
11436
12029
  ErrorPageBase,
11437
12030
  {
11438
12031
  statusCode: 401,
@@ -11445,9 +12038,9 @@ var ErrorPage401 = (props) => {
11445
12038
  };
11446
12039
 
11447
12040
  // src/components/ErrorPage/ErrorPage.400.tsx
11448
- import { jsx as jsx79 } from "react/jsx-runtime";
12041
+ import { jsx as jsx81 } from "react/jsx-runtime";
11449
12042
  var ErrorPage400 = (props) => {
11450
- return /* @__PURE__ */ jsx79(
12043
+ return /* @__PURE__ */ jsx81(
11451
12044
  ErrorPageBase,
11452
12045
  {
11453
12046
  statusCode: 400,
@@ -11500,6 +12093,8 @@ export {
11500
12093
  Guard,
11501
12094
  InfoGrid,
11502
12095
  Input,
12096
+ JournalForm_default as JournalForm,
12097
+ Journals_default as Journals,
11503
12098
  linkUser_default as LinkUser,
11504
12099
  LoadingBox,
11505
12100
  LoadingSpin,
@@ -11552,6 +12147,7 @@ export {
11552
12147
  createUserSchema,
11553
12148
  createWalletSchema,
11554
12149
  generatePdf,
12150
+ journalSchema,
11555
12151
  linkUserSchema,
11556
12152
  packProductItemSchema,
11557
12153
  packTypes,