complete transactions page
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
import { ShieldCross, ShieldTick } from "iconsax-react";
|
||||
|
||||
type ColumnConfig = {
|
||||
accessor: any;
|
||||
header: string;
|
||||
enableSorting?: boolean;
|
||||
cellRenderer?: (info: any) => JSX.Element;
|
||||
};
|
||||
|
||||
|
||||
export const createColumns = <T,>(columnConfigs: ColumnConfig[]) => {
|
||||
const columnHelper = createColumnHelper<T>();
|
||||
return columnConfigs.map(config =>
|
||||
columnHelper.accessor(config.accessor, {
|
||||
header: () => config.header,
|
||||
cell: (info) => config.header === "وضعیت" ? info.getValue() ? <ShieldTick color="#11212D" className="flex w-full"/> : <ShieldCross color="#E51717" className="flex w-full"/> : info.getValue(),
|
||||
cell: (info) => config.cellRenderer ? config.cellRenderer(info) : info.getValue(),
|
||||
enableSorting: config.enableSorting ?? true,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { installationReportsCol } from "../../utility/reports"
|
||||
import { Table } from "../common/table"
|
||||
import { getReportsList } from "../../services/api"
|
||||
import { getReportsList } from "../../services/api/reports"
|
||||
import { useState } from "react"
|
||||
import { SortingState } from "@tanstack/react-table"
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useState } from "react"
|
||||
import { Table } from "../common/table"
|
||||
import { SortingState } from "@tanstack/react-table"
|
||||
import { transactionsCol } from "../../utility/transactions"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { getTransactionsList } from "../../services/api/transactions"
|
||||
|
||||
export const Transactions = () => {
|
||||
const [sorting, setSorting] = useState<SortingState>([])
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ["transactions-list"],
|
||||
queryFn: getTransactionsList
|
||||
})
|
||||
|
||||
if (isLoading) return <p>LOADING ....</p>
|
||||
return (
|
||||
<Table sorting={sorting} setSorting={setSorting} columns={transactionsCol} data={data?.data} />
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user