36 lines
775 B
TypeScript
36 lines
775 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { fetchLastComplaint, ComplaintsCaseQueryParams } from '@/app/actions/violationActions';
|
|
|
|
interface Complaint {
|
|
complaint_text: string,
|
|
created_at: string,
|
|
email: string,
|
|
id: number,
|
|
not_moderated: boolean,
|
|
status: "CREATED" | string,
|
|
updated_at: string,
|
|
violation_id: number,
|
|
}
|
|
export interface useLastComplaint {
|
|
content: Complaint[],
|
|
page: 1,
|
|
size: 5,
|
|
totalElements: 10,
|
|
totalPages: 2,
|
|
}
|
|
|
|
export const useLastComplaints = (params: ComplaintsCaseQueryParams) => {
|
|
return useQuery({
|
|
queryKey: ['lastComplaints'],
|
|
queryFn: () => {
|
|
return fetchLastComplaint(params)
|
|
},
|
|
select: (data: useLastComplaint | null) => {
|
|
if (!data) {
|
|
return null
|
|
}
|
|
return data;
|
|
},
|
|
retry: false
|
|
});
|
|
}; |