update general statistic and analytic
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchViolationAnalyticStatistic } from '@/app/actions/violationActions';
|
||||
|
||||
export interface UseViolationStatistic {
|
||||
[key: string]: number
|
||||
}
|
||||
|
||||
export const useViolationAnalyticStatistic = (group: 'domain' | 'tld') => {
|
||||
return useQuery({
|
||||
queryKey: ['violationAnalyticStatistic', group],
|
||||
queryFn: () => {
|
||||
return fetchViolationAnalyticStatistic(group)
|
||||
},
|
||||
select: (data: UseViolationStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchViolationGeography } from '@/app/actions/violationActions';
|
||||
|
||||
export interface UseViolationGeography {
|
||||
ru: number;
|
||||
usa: number;
|
||||
uk: number;
|
||||
ge: number;
|
||||
}
|
||||
|
||||
export const useViolationGeography = () => {
|
||||
return useQuery({
|
||||
queryKey: ['violationGeography'],
|
||||
queryFn: fetchViolationGeography,
|
||||
select: (data): any | null => {
|
||||
if (!data) {
|
||||
return []
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchViolationStatistic } from '@/app/actions/violationActions';
|
||||
|
||||
export interface UseViolationStatistic {
|
||||
total_violations: 2565,
|
||||
new_violations: 2565,
|
||||
in_progress_violations: 0,
|
||||
resolved_violations: 0
|
||||
}
|
||||
|
||||
export const useViolationStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['violationStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchViolationStatistic()
|
||||
},
|
||||
select: (data: UseViolationStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user