61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
"use client";
|
|
import React, { useEffect, useState } from "react";
|
|
import RequestCard from "../Requests/RequestCard";
|
|
import { getCitizenReport } from "@/utils/CitizenReport";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { ThreeDots } from "react-loader-spinner";
|
|
|
|
const RequestList = () => {
|
|
const [reportData, setReportData] = useState<any | null>(null);
|
|
const { data, isLoading, isError, isSuccess, refetch } = useQuery({
|
|
queryKey: ["CitizenReport"],
|
|
queryFn: () =>
|
|
getCitizenReport({ PageNumber: 1, PageSize: 10, instanceId: 1 }),
|
|
// refetchOnWindowFocus: false,
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (data) {
|
|
console.log(data);
|
|
console.log(data.data);
|
|
console.log(data.data[0]);
|
|
setReportData(data.data);
|
|
}
|
|
}, [data]);
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="flex justify-center items-center text-center w-full h-full ">
|
|
<ThreeDots
|
|
visible={true}
|
|
height="50"
|
|
width="50"
|
|
color="#003778"
|
|
radius="9"
|
|
ariaLabel="three-dots-loading"
|
|
wrapperStyle={{}}
|
|
wrapperClass=""
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (isError) {
|
|
return <div>Error loading data</div>;
|
|
}
|
|
|
|
return (
|
|
<section
|
|
className="flex flex-1 w-full h-[28rem] items-center flex-col overflow-y-scroll pl-5 scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white scrollbar-thumb-rounded-lg"
|
|
style={{ direction: "rtl" }}
|
|
>
|
|
{isSuccess &&
|
|
data?.data?.map((item: any) => (
|
|
<RequestCard key={item.id} item={item} />
|
|
))}
|
|
</section>
|
|
);
|
|
};
|
|
|
|
export default RequestList;
|