Files
no-copy-frontend/src/app/hooks/react-query/useLastComplaints.ts
T

36 lines
775 B
TypeScript
Raw Normal View History

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