warqadui 0.0.48 → 0.0.50

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
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  CardFooter: () => CardFooter,
40
40
  CardHeader: () => CardHeader,
41
41
  CardTitle: () => CardTitle,
42
+ CategoryCard: () => CategoryCard,
42
43
  ClassicSpin: () => ClassicSpin,
43
44
  CodeBlock: () => CodeBlock,
44
45
  DashboardLayout: () => DashboardLayout,
@@ -68,9 +69,11 @@ __export(index_exports, {
68
69
  Textarea: () => Textarea,
69
70
  ThemeProvider: () => ThemeProvider,
70
71
  ThemeToggle: () => ThemeToggle,
72
+ Views: () => Views_default,
71
73
  WarqadProvider: () => WarqadProvider,
72
74
  generatePdf: () => generatePdf,
73
75
  storage: () => storage,
76
+ useA4CategoryView: () => useA4CategoryView_default,
74
77
  useA4StatementView: () => useA4DataView_default,
75
78
  useAntdImageUpload: () => useAntdImageUpload_default,
76
79
  useApi: () => useApis_default,
@@ -4515,11 +4518,364 @@ var useA4StatementView = ({
4515
4518
  };
4516
4519
  var useA4DataView_default = useA4StatementView;
4517
4520
 
4518
- // src/hooks/Fetches/useTransaction.tsx
4521
+ // src/hooks/Fetches/useA4CategoryView.tsx
4519
4522
  var import_react20 = require("react");
4523
+ var import_react_to_print2 = require("react-to-print");
4520
4524
  var import_lucide_react13 = require("lucide-react");
4521
- var import_moment = __toESM(require("moment"));
4522
4525
  var import_jsx_runtime29 = require("react/jsx-runtime");
4526
+ var useA4CategoryView = ({
4527
+ url,
4528
+ v = 1,
4529
+ delay,
4530
+ params,
4531
+ startPage = 1
4532
+ } = {}) => {
4533
+ const { data: apiData, isLoading, get, error: apiError } = useApis_default();
4534
+ const contentRef = (0, import_react20.useRef)(null);
4535
+ const reactToPrintFn = (0, import_react_to_print2.useReactToPrint)({
4536
+ contentRef
4537
+ });
4538
+ const getData = async () => {
4539
+ if (url) {
4540
+ await get({ url, v, params, delay });
4541
+ }
4542
+ };
4543
+ (0, import_react20.useEffect)(() => {
4544
+ getData();
4545
+ }, [url, v, JSON.stringify(params), delay]);
4546
+ const A4CategoryView = ({
4547
+ data,
4548
+ groups: incomingGroups,
4549
+ error = apiError,
4550
+ info,
4551
+ title = "Inventory Report",
4552
+ subtitle = "Official Category List",
4553
+ printable = true,
4554
+ gridTitle = "Items List",
4555
+ startPage: componentStartPage = startPage,
4556
+ isLoading: externalLoading,
4557
+ renderItem,
4558
+ gridColumns = 4
4559
+ }) => {
4560
+ const { store } = useWarqadConfig();
4561
+ const isActuallyLoading = externalLoading ?? isLoading;
4562
+ const measureContainerRef = (0, import_react20.useRef)(null);
4563
+ const [pages, setPages] = (0, import_react20.useState)([]);
4564
+ const [isMeasuring, setIsMeasuring] = (0, import_react20.useState)(true);
4565
+ const [globalFilter, setGlobalFilter] = (0, import_react20.useState)("");
4566
+ const [currentPageIndex, setCurrentPageIndex] = (0, import_react20.useState)(0);
4567
+ const [pageSearch, setPageSearch] = (0, import_react20.useState)("");
4568
+ const groups = incomingGroups ? [...incomingGroups].sort(
4569
+ (a, b) => a.title.localeCompare(b.title)
4570
+ ) : data ? [{ title: gridTitle, items: data }] : [];
4571
+ const flattenedNodes = groups.map((group) => {
4572
+ const sortedItems = [...group.items].sort(
4573
+ (a, b) => String(a.name).localeCompare(String(b.name))
4574
+ );
4575
+ const filteredItems = sortedItems.filter((row) => {
4576
+ if (!globalFilter) return true;
4577
+ const lowerFilter = globalFilter.toLowerCase();
4578
+ return Object.values(row).some(
4579
+ (val) => String(val).toLowerCase().includes(lowerFilter)
4580
+ );
4581
+ });
4582
+ if (filteredItems.length === 0) return [];
4583
+ const nodes = [{ type: "header", title: group.title }];
4584
+ const rows = Array.from(
4585
+ { length: Math.ceil(filteredItems.length / gridColumns) },
4586
+ (_, i) => filteredItems.slice(i * gridColumns, i * gridColumns + gridColumns)
4587
+ );
4588
+ rows.forEach((rowItems) => {
4589
+ nodes.push({ type: "row", items: rowItems });
4590
+ });
4591
+ return nodes;
4592
+ }).flat();
4593
+ const depsString = JSON.stringify({
4594
+ nodeCount: flattenedNodes.length,
4595
+ gridColumns,
4596
+ globalFilter
4597
+ });
4598
+ (0, import_react20.useEffect)(() => {
4599
+ if (flattenedNodes.length > 0) {
4600
+ setIsMeasuring(true);
4601
+ setPages((prev) => prev.length === 0 ? [[]] : prev);
4602
+ if (componentStartPage !== -1) {
4603
+ setCurrentPageIndex(Math.max(0, componentStartPage - 1));
4604
+ }
4605
+ } else {
4606
+ setIsMeasuring(false);
4607
+ setPages([[]]);
4608
+ setCurrentPageIndex(0);
4609
+ }
4610
+ }, [depsString]);
4611
+ (0, import_react20.useEffect)(() => {
4612
+ if (!isMeasuring || flattenedNodes.length === 0) return;
4613
+ const timer = setTimeout(() => {
4614
+ if (!measureContainerRef.current) return;
4615
+ const container = measureContainerRef.current;
4616
+ const headerEl = container.querySelector("#a4-header-section");
4617
+ const infoGridEl = container.querySelector("#a4-info-grid");
4618
+ const nodeEls = container.querySelectorAll(".a4-measure-node");
4619
+ const getH = (el) => el ? el.offsetHeight : 0;
4620
+ const headerHeight = getH(headerEl);
4621
+ const infoGridHeight = getH(infoGridEl);
4622
+ let currentChunks = [];
4623
+ let currentChunk = [];
4624
+ let currentHeight = headerHeight + infoGridHeight + 20;
4625
+ Array.from(nodeEls).forEach((node, i) => {
4626
+ const nodeHeight = getH(node);
4627
+ const currentPageLimit = currentChunks.length === 0 ? 940 : 980;
4628
+ if (currentHeight + nodeHeight > currentPageLimit) {
4629
+ if (currentChunk.length > 0) {
4630
+ currentChunks.push([...currentChunk]);
4631
+ currentChunk = [];
4632
+ currentHeight = 80;
4633
+ }
4634
+ }
4635
+ currentChunk.push(flattenedNodes[i]);
4636
+ currentHeight += nodeHeight + 4;
4637
+ });
4638
+ if (currentChunk.length > 0) {
4639
+ currentChunks.push([...currentChunk]);
4640
+ }
4641
+ const finalPages = currentChunks.length > 0 ? currentChunks : [[]];
4642
+ setPages(finalPages);
4643
+ if (componentStartPage === -1) {
4644
+ setCurrentPageIndex(finalPages.length - 1);
4645
+ }
4646
+ setIsMeasuring(false);
4647
+ }, 150);
4648
+ return () => clearTimeout(timer);
4649
+ }, [isMeasuring, depsString]);
4650
+ const HeaderEl = /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4651
+ "div",
4652
+ {
4653
+ className: "flex justify-between items-start mb-5 px-8 pt-8",
4654
+ id: "a4-header-section",
4655
+ children: [
4656
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex items-center gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("section", { children: [
4657
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h1", { className: "text-4xl font-black text-black dark:text-white print:text-black tracking-tighter uppercase", children: title }),
4658
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-gray-600 dark:text-gray-400 print:text-gray-600 mt-1 uppercase text-xs font-bold tracking-widest", children: subtitle })
4659
+ ] }) }) }),
4660
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "text-right", children: [
4661
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h2", { className: "text-lg font-black text-black dark:text-white print:text-black uppercase tracking-tight", children: store?.name }),
4662
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "text-sm text-gray-600 dark:text-gray-400 print:text-gray-600 leading-relaxed text-right flex flex-col items-end font-medium", children: [
4663
+ store?.address && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "whitespace-pre-line", children: store.address }),
4664
+ store?.phone && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: store.phone }),
4665
+ store?.email && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: store.email })
4666
+ ] })
4667
+ ] })
4668
+ ]
4669
+ }
4670
+ );
4671
+ const DisplayInfoGridEl = Array.isArray(info) && info.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { id: "a4-info-grid", className: "px-8", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4672
+ InfoGrid,
4673
+ {
4674
+ className: "mb-4",
4675
+ items: info,
4676
+ isLoading: isActuallyLoading
4677
+ }
4678
+ ) }) : null;
4679
+ const renderNode = (node) => {
4680
+ if (node.type === "header") {
4681
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mb-4 border-b border-black print:border-black pb-2 flex items-center gap-2 justify-between px-2 mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-sm font-black text-black dark:text-white print:text-black uppercase tracking-[0.2em]", children: node.title }) });
4682
+ }
4683
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4684
+ "div",
4685
+ {
4686
+ className: "grid gap-4 px-2",
4687
+ style: { gridTemplateColumns: `repeat(${gridColumns}, 1fr)` },
4688
+ children: node.items.map((item, j) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: renderItem(item) }, j))
4689
+ }
4690
+ );
4691
+ };
4692
+ const statusOverlay = isActuallyLoading || error || flattenedNodes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[400px]", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
4693
+ isActuallyLoading ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ClassicSpin, {}) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
4694
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: isActuallyLoading ? "Loading data..." : error ? "Failed to Load Report" : "No Records Found" }),
4695
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: isActuallyLoading ? "Please wait while we prepare your report." : error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the data." : "There are no items available in this requested report." }),
4696
+ url && !isActuallyLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4697
+ "button",
4698
+ {
4699
+ onClick: () => getData(),
4700
+ className: "flex items-center gap-2 px-5 py-2 bg-black dark:bg-white text-white dark:text-black font-semibold rounded-lg shadow-md hover:bg-gray-800 dark:hover:bg-gray-100 transition-all active:scale-95 text-sm",
4701
+ children: [
4702
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.RefreshCw, { size: 14 }),
4703
+ "Try Again"
4704
+ ]
4705
+ }
4706
+ )
4707
+ ] }) }) : null;
4708
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col relative w-full items-center", children: [
4709
+ isMeasuring && flattenedNodes.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "absolute top-0 opacity-0 pointer-events-none -left-full", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4710
+ "div",
4711
+ {
4712
+ style: { width: "210mm", boxSizing: "border-box" },
4713
+ className: "bg-white",
4714
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4715
+ "div",
4716
+ {
4717
+ ref: measureContainerRef,
4718
+ className: "flex flex-col w-full h-full",
4719
+ children: [
4720
+ HeaderEl,
4721
+ DisplayInfoGridEl,
4722
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "grow w-full px-8 pb-8", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-2", children: flattenedNodes.map((node, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "a4-measure-node", children: renderNode(node) }, i)) }) })
4723
+ ]
4724
+ }
4725
+ )
4726
+ }
4727
+ ) }),
4728
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "py-2 px-0 md:px-4 w-full", ref: contentRef, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-8 print:block print:gap-0 w-full items-center", children: pages.map((pageNodes, pageIndex) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4729
+ "div",
4730
+ {
4731
+ className: pageIndex === currentPageIndex ? "w-full" : "hidden print:block w-full",
4732
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4733
+ PageA4,
4734
+ {
4735
+ className: "w-full",
4736
+ pageNumber: pageIndex + 1,
4737
+ totalPages: pages.length,
4738
+ isLastPage: pageIndex === pages.length - 1,
4739
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col h-full grow w-full", children: [
4740
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("header", { className: "flex justify-between gap-2 items-center px-8 pt-4 print:hidden", children: printable && pageIndex === currentPageIndex && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
4741
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4742
+ "button",
4743
+ {
4744
+ onClick: async () => await getData(),
4745
+ disabled: isLoading,
4746
+ className: "flex items-center gap-2 px-3 py-1.5 text-gray-600 dark:text-gray-300 hover:text-black dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-all disabled:opacity-50",
4747
+ children: [
4748
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4749
+ import_lucide_react13.RefreshCw,
4750
+ {
4751
+ size: 16,
4752
+ className: isLoading ? "animate-spin" : ""
4753
+ }
4754
+ ),
4755
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-xs font-semibold", children: "Reload" })
4756
+ ]
4757
+ }
4758
+ ),
4759
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4760
+ "button",
4761
+ {
4762
+ onClick: () => reactToPrintFn(),
4763
+ className: "flex items-center gap-2 px-4 py-1.5 bg-black dark:bg-zinc-800 text-white rounded-md text-xs font-bold shadow-sm hover:bg-zinc-800 dark:hover:bg-zinc-700 transition-all active:scale-95",
4764
+ children: [
4765
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.Printer, { size: 16 }),
4766
+ "Print"
4767
+ ]
4768
+ }
4769
+ ),
4770
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1.5 ml-2 pl-2 border-l border-gray-200 dark:border-zinc-700", children: [
4771
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4772
+ "button",
4773
+ {
4774
+ onClick: (e) => {
4775
+ e.stopPropagation();
4776
+ setCurrentPageIndex(
4777
+ (p) => Math.max(0, p - 1)
4778
+ );
4779
+ },
4780
+ disabled: currentPageIndex === 0,
4781
+ className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-zinc-800 disabled:opacity-30 transition-colors text-gray-600 dark:text-gray-400",
4782
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.ChevronLeft, { size: 18 })
4783
+ }
4784
+ ),
4785
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-1 text-[11px] font-bold tabular-nums", children: [
4786
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4787
+ Select,
4788
+ {
4789
+ value: currentPageIndex + 1,
4790
+ onChange: (val) => {
4791
+ const num = Number(val);
4792
+ if (!isNaN(num)) {
4793
+ setCurrentPageIndex(num - 1);
4794
+ }
4795
+ },
4796
+ variant: "ghost",
4797
+ containerClassName: "inline-block",
4798
+ children: [
4799
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SelectTrigger, { className: "h-7 px-2 min-w-[40px] border border-gray-200 dark:border-zinc-700 rounded flex items-center justify-center bg-white dark:bg-zinc-900 hover:bg-gray-100 dark:hover:bg-zinc-800 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-gray-900 dark:text-white", children: currentPageIndex + 1 }) }),
4800
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(SelectContent, { className: "min-w-[100px] max-h-64 overflow-y-auto p-0", children: [
4801
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "p-2 border-b border-gray-100 dark:border-zinc-800 sticky top-0 bg-white dark:bg-zinc-950 z-10", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4802
+ "input",
4803
+ {
4804
+ type: "text",
4805
+ placeholder: "Page...",
4806
+ className: "w-full px-2 py-1 text-[11px] border rounded bg-gray-50 dark:bg-zinc-900 border-gray-200 dark:border-zinc-800 outline-none focus:ring-1 focus:ring-blue-500 text-gray-900 dark:text-white",
4807
+ value: pageSearch,
4808
+ onChange: (e) => setPageSearch(e.target.value),
4809
+ onKeyDown: (e) => e.stopPropagation(),
4810
+ autoFocus: true
4811
+ }
4812
+ ) }),
4813
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "p-1", children: pages.map((_, i) => i + 1).filter(
4814
+ (p) => String(p).includes(pageSearch)
4815
+ ).map((p) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SelectItem, { value: p, children: p }, p)) })
4816
+ ] })
4817
+ ]
4818
+ }
4819
+ ),
4820
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-gray-400 mx-0.5", children: "/" }),
4821
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "text-gray-600 dark:text-gray-400", children: pages.length })
4822
+ ] }),
4823
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4824
+ "button",
4825
+ {
4826
+ onClick: (e) => {
4827
+ e.stopPropagation();
4828
+ setCurrentPageIndex(
4829
+ (p) => Math.min(pages.length - 1, p + 1)
4830
+ );
4831
+ },
4832
+ disabled: currentPageIndex === pages.length - 1,
4833
+ className: "p-1 rounded hover:bg-gray-100 dark:hover:bg-zinc-800 disabled:opacity-30 transition-colors text-gray-600 dark:text-gray-400",
4834
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.ChevronRight, { size: 18 })
4835
+ }
4836
+ )
4837
+ ] })
4838
+ ] }) }) }),
4839
+ pageIndex === 0 && HeaderEl,
4840
+ pageIndex === 0 && DisplayInfoGridEl,
4841
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "grow w-full px-8 pb-8", children: [
4842
+ pageIndex === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex items-center justify-end px-2 mt-2 print:hidden mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4843
+ "input",
4844
+ {
4845
+ type: "text",
4846
+ value: globalFilter,
4847
+ onChange: (e) => setGlobalFilter(e.target.value),
4848
+ placeholder: "Global Search...",
4849
+ className: "block w-full max-w-xs px-3 py-2 border border-gray-300 rounded-md text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 dark:bg-zinc-900 dark:border-zinc-700 dark:text-white"
4850
+ }
4851
+ ) }),
4852
+ pageIndex > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "h-14 print:h-14" }),
4853
+ statusOverlay ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "px-8 pb-8", children: statusOverlay }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex flex-col gap-2", children: pageNodes.map((node, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: renderNode(node) }, i)) })
4854
+ ] })
4855
+ ] })
4856
+ },
4857
+ pageIndex
4858
+ )
4859
+ },
4860
+ pageIndex
4861
+ )) }) })
4862
+ ] });
4863
+ };
4864
+ return {
4865
+ A4CategoryView,
4866
+ data: apiData,
4867
+ isLoading,
4868
+ get,
4869
+ reactToPrintFn
4870
+ };
4871
+ };
4872
+ var useA4CategoryView_default = useA4CategoryView;
4873
+
4874
+ // src/hooks/Fetches/useTransaction.tsx
4875
+ var import_react21 = require("react");
4876
+ var import_lucide_react14 = require("lucide-react");
4877
+ var import_moment = __toESM(require("moment"));
4878
+ var import_jsx_runtime30 = require("react/jsx-runtime");
4523
4879
  var useTransaction = ({
4524
4880
  url,
4525
4881
  v = 1,
@@ -4527,14 +4883,13 @@ var useTransaction = ({
4527
4883
  params = {},
4528
4884
  dateFilter = true
4529
4885
  }) => {
4530
- const [date, setDate] = (0, import_react20.useState)(
4886
+ const [date, setDate] = (0, import_react21.useState)(
4531
4887
  (0, import_moment.default)().format("DD/MM/YYYY")
4532
4888
  );
4533
4889
  const dateObj = {};
4534
4890
  if (date && dateFilter) dateObj.date = date;
4535
4891
  const { data: apiData, isLoading, get, error: apiError } = useApis_default();
4536
4892
  const getData = () => {
4537
- console.log(dateObj);
4538
4893
  get({
4539
4894
  url,
4540
4895
  v,
@@ -4545,7 +4900,7 @@ var useTransaction = ({
4545
4900
  delay
4546
4901
  });
4547
4902
  };
4548
- (0, import_react20.useEffect)(() => {
4903
+ (0, import_react21.useEffect)(() => {
4549
4904
  getData();
4550
4905
  }, [url, v, JSON.stringify(params), delay, date]);
4551
4906
  const TransactionViewComponent = ({
@@ -4572,21 +4927,21 @@ var useTransaction = ({
4572
4927
  createTitle = "Add New",
4573
4928
  ...rest
4574
4929
  }) => {
4575
- const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4930
+ const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4576
4931
  "div",
4577
4932
  {
4578
4933
  className: `flex flex-col relative w-full items-center justify-center py-12 min-h-[300px] ${className}`,
4579
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
4580
- error ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
4581
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: error ? "Failed to Load Data" : "No Records Found" }),
4582
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the data." : "There are no transactions or records available to display here." }),
4583
- url && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
4934
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
4935
+ error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react14.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react14.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
4936
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: error ? "Failed to Load Data" : "No Records Found" }),
4937
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the data." : "There are no transactions or records available to display here." }),
4938
+ url && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
4584
4939
  "button",
4585
4940
  {
4586
4941
  onClick: () => getData(),
4587
4942
  className: "flex items-center gap-2 px-5 py-2 bg-black dark:bg-white text-white dark:text-black font-semibold rounded-lg shadow-md hover:bg-gray-800 dark:hover:bg-gray-100 transition-all active:scale-95 text-sm",
4588
4943
  children: [
4589
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.RefreshCw, { size: 14 }),
4944
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react14.RefreshCw, { size: 14 }),
4590
4945
  "Try Again"
4591
4946
  ]
4592
4947
  }
@@ -4594,14 +4949,14 @@ var useTransaction = ({
4594
4949
  ] })
4595
4950
  }
4596
4951
  ) : void 0;
4597
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Card, { children: [
4598
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Card.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("header", { className: "flex items-center justify-between gap-4 py-2", children: [
4599
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "space-y-1", children: [
4600
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Card.Title, { children: title }),
4601
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Card.Description, { children: description })
4952
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Card, { children: [
4953
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("header", { className: "flex items-center justify-between gap-4 py-2", children: [
4954
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "space-y-1", children: [
4955
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Title, { children: title }),
4956
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Description, { children: description })
4602
4957
  ] }),
4603
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("section", { className: "flex gap-2 items-center", children: [
4604
- dateFilter && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4958
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("section", { className: "flex gap-2 items-center", children: [
4959
+ dateFilter && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4605
4960
  Fields_default.DateInput,
4606
4961
  {
4607
4962
  value: date,
@@ -4611,20 +4966,20 @@ var useTransaction = ({
4611
4966
  }
4612
4967
  }
4613
4968
  ),
4614
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4969
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4615
4970
  Button,
4616
4971
  {
4617
4972
  size: "sm",
4618
4973
  className: "rounded-md!",
4619
4974
  onClick: onCreate,
4620
4975
  variant: "primary",
4621
- icon: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react13.Plus, {}),
4976
+ icon: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_lucide_react14.Plus, {}),
4622
4977
  children: createTitle
4623
4978
  }
4624
4979
  )
4625
4980
  ] })
4626
4981
  ] }) }),
4627
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Card.Content, { className: "space-y-6", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: `w-full ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
4982
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Card.Content, { className: "space-y-6", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: `w-full ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
4628
4983
  DataTable,
4629
4984
  {
4630
4985
  columns,
@@ -4841,11 +5196,11 @@ var storage = {
4841
5196
  };
4842
5197
 
4843
5198
  // src/hooks/uploads/useAntdImageUpload.tsx
4844
- var import_react23 = require("react");
5199
+ var import_react24 = require("react");
4845
5200
 
4846
5201
  // ../../node_modules/@ant-design/icons/es/components/Context.js
4847
- var import_react21 = require("react");
4848
- var IconContext = /* @__PURE__ */ (0, import_react21.createContext)({});
5202
+ var import_react22 = require("react");
5203
+ var IconContext = /* @__PURE__ */ (0, import_react22.createContext)({});
4849
5204
  var Context_default = IconContext;
4850
5205
 
4851
5206
  // ../../node_modules/@ant-design/icons/es/components/AntdIcon.js
@@ -5888,7 +6243,7 @@ warningOnce.resetWarned = resetWarned;
5888
6243
  warningOnce.noteOnce = noteOnce;
5889
6244
 
5890
6245
  // ../../node_modules/@ant-design/icons/es/utils.js
5891
- var import_react22 = __toESM(require("react"));
6246
+ var import_react23 = __toESM(require("react"));
5892
6247
  function camelCase(input) {
5893
6248
  return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
5894
6249
  }
@@ -5915,12 +6270,12 @@ function normalizeAttrs(attrs = {}) {
5915
6270
  }
5916
6271
  function generate2(node, key, rootProps) {
5917
6272
  if (!rootProps) {
5918
- return /* @__PURE__ */ import_react22.default.createElement(node.tag, {
6273
+ return /* @__PURE__ */ import_react23.default.createElement(node.tag, {
5919
6274
  key,
5920
6275
  ...normalizeAttrs(node.attrs)
5921
6276
  }, (node.children || []).map((child, index) => generate2(child, `${key}-${node.tag}-${index}`)));
5922
6277
  }
5923
- return /* @__PURE__ */ import_react22.default.createElement(node.tag, {
6278
+ return /* @__PURE__ */ import_react23.default.createElement(node.tag, {
5924
6279
  key,
5925
6280
  ...normalizeAttrs(node.attrs),
5926
6281
  ...rootProps
@@ -5997,7 +6352,7 @@ var useInsertStyles = (eleRef) => {
5997
6352
  csp,
5998
6353
  prefixCls,
5999
6354
  layer
6000
- } = (0, import_react22.useContext)(Context_default);
6355
+ } = (0, import_react23.useContext)(Context_default);
6001
6356
  let mergedStyleStr = iconStyles;
6002
6357
  if (prefixCls) {
6003
6358
  mergedStyleStr = mergedStyleStr.replace(/anticon/g, prefixCls);
@@ -6007,7 +6362,7 @@ var useInsertStyles = (eleRef) => {
6007
6362
  ${mergedStyleStr}
6008
6363
  }`;
6009
6364
  }
6010
- (0, import_react22.useEffect)(() => {
6365
+ (0, import_react23.useEffect)(() => {
6011
6366
  const ele = eleRef.current;
6012
6367
  const shadowRoot = getShadowRoot(ele);
6013
6368
  updateCSS(mergedStyleStr, "@ant-design-icons", {
@@ -6204,7 +6559,7 @@ var PlusOutlined_default2 = RefIcon;
6204
6559
 
6205
6560
  // src/hooks/uploads/useAntdImageUpload.tsx
6206
6561
  var import_antd2 = require("antd");
6207
- var import_jsx_runtime30 = require("react/jsx-runtime");
6562
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6208
6563
  var getBase64 = (file) => new Promise((resolve, reject) => {
6209
6564
  const reader = new FileReader();
6210
6565
  reader.readAsDataURL(file);
@@ -6212,9 +6567,9 @@ var getBase64 = (file) => new Promise((resolve, reject) => {
6212
6567
  reader.onerror = (error) => reject(error);
6213
6568
  });
6214
6569
  var useAntdImageUpload = ({ length = 1 }) => {
6215
- const [fileList, setFileList] = (0, import_react23.useState)([]);
6216
- const [previewOpen, setPreviewOpen] = (0, import_react23.useState)(false);
6217
- const [previewImage, setPreviewImage] = (0, import_react23.useState)("");
6570
+ const [fileList, setFileList] = (0, import_react24.useState)([]);
6571
+ const [previewOpen, setPreviewOpen] = (0, import_react24.useState)(false);
6572
+ const [previewImage, setPreviewImage] = (0, import_react24.useState)("");
6218
6573
  const handlePreview = async (file) => {
6219
6574
  if (!file.url && !file.preview) {
6220
6575
  file.preview = await getBase64(file.originFileObj);
@@ -6231,8 +6586,8 @@ var useAntdImageUpload = ({ length = 1 }) => {
6231
6586
  }))
6232
6587
  );
6233
6588
  };
6234
- const ImageBox = () => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
6235
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6589
+ const ImageBox = () => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
6590
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6236
6591
  import_antd2.Upload,
6237
6592
  {
6238
6593
  listType: "picture-card",
@@ -6240,13 +6595,13 @@ var useAntdImageUpload = ({ length = 1 }) => {
6240
6595
  onPreview: handlePreview,
6241
6596
  onChange: handleChange,
6242
6597
  beforeUpload: () => false,
6243
- children: fileList.length >= length ? null : /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("button", { style: { border: 0, background: "none" }, type: "button", children: [
6244
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(PlusOutlined_default2, {}),
6245
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { style: { marginTop: 8 }, children: "Upload" })
6598
+ children: fileList.length >= length ? null : /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", { style: { border: 0, background: "none" }, type: "button", children: [
6599
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PlusOutlined_default2, {}),
6600
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { style: { marginTop: 8 }, children: "Upload" })
6246
6601
  ] })
6247
6602
  }
6248
6603
  ),
6249
- previewImage && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6604
+ previewImage && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
6250
6605
  import_antd2.Image,
6251
6606
  {
6252
6607
  style: { display: "none" },
@@ -6262,6 +6617,51 @@ var useAntdImageUpload = ({ length = 1 }) => {
6262
6617
  return { ImageBox, fileList, setFileList };
6263
6618
  };
6264
6619
  var useAntdImageUpload_default = useAntdImageUpload;
6620
+
6621
+ // src/components/Views/CategoryView.tsx
6622
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6623
+ var CategoryCard = ({ item }) => {
6624
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "group bg-white rounded-md overflow-hidden border border-black/80 flex flex-col h-full print:border-black transition-all duration-300", children: [
6625
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "relative aspect-square w-full overflow-hidden bg-gray-50 flex-shrink-0 border-b border-black/10", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6626
+ "img",
6627
+ {
6628
+ src: item.image,
6629
+ alt: item.name,
6630
+ className: "w-full h-full object-cover"
6631
+ }
6632
+ ) }),
6633
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "p-1.5 flex flex-col justify-center flex-grow", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("h3", { className: "text-[10px] font-bold text-black line-clamp-2 leading-tight text-center", children: item.name }) })
6634
+ ] });
6635
+ };
6636
+ var CategoryView = ({
6637
+ categoryName,
6638
+ items,
6639
+ className
6640
+ }) => {
6641
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: cn("p-6 bg-gray-50 min-h-full", className), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "max-w-7xl mx-auto", children: [
6642
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "mb-8", children: [
6643
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("h2", { className: "text-2xl md:text-3xl font-bold text-gray-900 tracking-tight", children: categoryName }),
6644
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "mt-2 h-1.5 w-16 bg-green-500 rounded-full" })
6645
+ ] }),
6646
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 md:gap-6", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(CategoryCard, { item }, item.id)) })
6647
+ ] }) });
6648
+ };
6649
+ var CategoryView_default = CategoryView;
6650
+
6651
+ // src/components/Views/Transaction.tsx
6652
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6653
+ var Transaction = () => {
6654
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { children: "Transaction" });
6655
+ };
6656
+ var Transaction_default = Transaction;
6657
+
6658
+ // src/components/Views/index.tsx
6659
+ var Views = {
6660
+ Transaction: Transaction_default,
6661
+ CategoryView: CategoryView_default,
6662
+ CategoryCard
6663
+ };
6664
+ var Views_default = Views;
6265
6665
  // Annotate the CommonJS export names for ESM import in node:
6266
6666
  0 && (module.exports = {
6267
6667
  Badge,
@@ -6273,6 +6673,7 @@ var useAntdImageUpload_default = useAntdImageUpload;
6273
6673
  CardFooter,
6274
6674
  CardHeader,
6275
6675
  CardTitle,
6676
+ CategoryCard,
6276
6677
  ClassicSpin,
6277
6678
  CodeBlock,
6278
6679
  DashboardLayout,
@@ -6302,9 +6703,11 @@ var useAntdImageUpload_default = useAntdImageUpload;
6302
6703
  Textarea,
6303
6704
  ThemeProvider,
6304
6705
  ThemeToggle,
6706
+ Views,
6305
6707
  WarqadProvider,
6306
6708
  generatePdf,
6307
6709
  storage,
6710
+ useA4CategoryView,
6308
6711
  useA4StatementView,
6309
6712
  useAntdImageUpload,
6310
6713
  useApi,