add two tanstack tables for claims and complaints
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchLastCase, ComplaintsCaseQueryParams } from '@/app/actions/violationActions';
|
||||
|
||||
interface Case {
|
||||
export interface Case {
|
||||
amount: number;
|
||||
content: null | string;
|
||||
created_at: string;
|
||||
@@ -21,15 +21,15 @@ interface Case {
|
||||
}
|
||||
export interface useLastCase {
|
||||
content: Case[],
|
||||
page: 1,
|
||||
size: 5,
|
||||
totalElements: 10,
|
||||
totalPages: 2,
|
||||
page: number,
|
||||
size: number,
|
||||
totalElements: number,
|
||||
totalPages: number,
|
||||
}
|
||||
|
||||
export const useLastCases = (params: ComplaintsCaseQueryParams) => {
|
||||
return useQuery({
|
||||
queryKey: ['lastCases'],
|
||||
queryKey: ['lastCases', params.page, params.size, params.sort_by, params.sort_direction],
|
||||
queryFn: () => {
|
||||
return fetchLastCase(params)
|
||||
},
|
||||
@@ -39,6 +39,7 @@ export const useLastCases = (params: ComplaintsCaseQueryParams) => {
|
||||
}
|
||||
return data;
|
||||
},
|
||||
placeholderData: (previousData) => previousData,
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchLastComplaint, ComplaintsCaseQueryParams } from '@/app/actions/violationActions';
|
||||
|
||||
interface Complaint {
|
||||
export interface Complaint {
|
||||
complaint_text: string;
|
||||
created_at: string;
|
||||
email: string;
|
||||
@@ -14,15 +14,15 @@ interface Complaint {
|
||||
}
|
||||
export interface useLastComplaint {
|
||||
content: Complaint[],
|
||||
page: 1,
|
||||
size: 5,
|
||||
totalElements: 10,
|
||||
totalPages: 2,
|
||||
page: number,
|
||||
size: number,
|
||||
totalElements: number,
|
||||
totalPages: number,
|
||||
}
|
||||
|
||||
export const useLastComplaints = (params: ComplaintsCaseQueryParams) => {
|
||||
return useQuery({
|
||||
queryKey: ['lastComplaints'],
|
||||
queryKey: ['lastComplaints', params.page, params.size, params.sort_by, params.sort_direction],
|
||||
queryFn: () => {
|
||||
return fetchLastComplaint(params)
|
||||
},
|
||||
@@ -32,6 +32,7 @@ export const useLastComplaints = (params: ComplaintsCaseQueryParams) => {
|
||||
}
|
||||
return data;
|
||||
},
|
||||
placeholderData: (previousData) => previousData,
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user