complete installation device pagination

This commit is contained in:
Alihaghighattalab
2024-08-22 17:07:33 +03:30
parent 1b96b0dc2c
commit 4b4c546aaa
11 changed files with 176 additions and 41 deletions
+25 -9
View File
@@ -1,18 +1,34 @@
import { installationReportsCol } from "../../utility/reports"
import { Table } from "../common/table"
import { useState } from "react"
import { SortingState } from "@tanstack/react-table"
import { useQuery } from "@tanstack/react-query"
import { useEffect, useState } from "react"
import { useMutation } from "@tanstack/react-query"
import { getRegisterDeviceList } from "../../services/api/register-device"
import { RegisterDeviceResponse } from "../../types"
import { useParamsStore } from "../../store/params"
export const InstallationReports = () => {
const [sorting, setSorting] = useState<SortingState>([])
const { data, isLoading } = useQuery({
queryKey: ["register-device"],
queryFn: getRegisterDeviceList
const { params } = useParamsStore()
const [data, setData] = useState<RegisterDeviceResponse>({
data: [],
total: 0
})
const { mutate, isPending } = useMutation({
mutationFn: getRegisterDeviceList
})
useEffect(() => {
mutate({
...params
},
{
onSuccess: (res: any) => {
setData({
data: res?.data?.data,
total: res?.data?.total
})
}
})
}, [mutate, params])
return (
<Table columns={installationReportsCol} data={data?.data?.data} sorting={sorting} setSorting={setSorting} isLoading={isLoading} />
<Table columns={installationReportsCol} data={data?.data} totalData={data?.total} isLoading={isPending} />
)
}