56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
"use client";
|
|
import React, { useEffect, useState } from "react";
|
|
import RequestList from "@/components/RecentRequest/RequestList";
|
|
import RequestCard from "@/components/Requests/RequestCard";
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { ThreeDots } from "react-loader-spinner";
|
|
import { getCitizenReportMine } from "@/utils/CitizenReport";
|
|
export default function page() {
|
|
const [reportData, setReportData] = useState<any | null>(null);
|
|
const { data, isLoading, isError, isSuccess, refetch } = useQuery({
|
|
queryKey: ["CitizenReportMine"],
|
|
queryFn: () => getCitizenReportMine({ PageNumber: 1, PageSize: 10 }),
|
|
// 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="no-scrollbar flex w-full md:grid md:grid-cols-2 md:gap-4 h-full items-start flex-col overflow-y-auto p-5 scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white scrollbar-thumb-rounded-lg ">
|
|
{isSuccess &&
|
|
data?.data?.map((item: any) => (
|
|
<RequestCard key={item.id} item={item} isSelfRequest={true} />
|
|
))}
|
|
</section>
|
|
);
|
|
}
|