add dashboard statistic
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchIncomeGeneralStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface IncomePerUser {
|
||||
p5: number;
|
||||
p50: number;
|
||||
p95: number;
|
||||
}
|
||||
|
||||
interface IncomeGeneralStatistic {
|
||||
total_income: number;
|
||||
total_available: number;
|
||||
total_hold: number;
|
||||
income_per_user: IncomePerUser;
|
||||
}
|
||||
|
||||
export const useIncomeGeneralStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['incomeGeneralStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchIncomeGeneralStatistic()
|
||||
},
|
||||
select: (data: IncomeGeneralStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchProtectedContentGeneralStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface FilesPerUserPercentiles {
|
||||
p5: number;
|
||||
p50: number;
|
||||
p95: number;
|
||||
}
|
||||
|
||||
interface SizePerUserPercentiles {
|
||||
p5_bytes: number;
|
||||
p50_bytes: number;
|
||||
p95_bytes: number;
|
||||
p5_mb: number;
|
||||
p50_mb: number;
|
||||
p95_mb: number;
|
||||
}
|
||||
|
||||
interface ProtectedContentGeneralStatistic {
|
||||
total_files: number;
|
||||
total_size_bytes: number;
|
||||
total_size_gb: number;
|
||||
files_per_user_percentiles: FilesPerUserPercentiles;
|
||||
size_per_user_percentiles: SizePerUserPercentiles;
|
||||
}
|
||||
|
||||
export const useProtectedContentGeneralStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['protectedContentGeneralStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchProtectedContentGeneralStatistic()
|
||||
},
|
||||
select: (data: ProtectedContentGeneralStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchSubscribeGeneralStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface SubscriptionStats {
|
||||
current_active_subscriptions: number;
|
||||
first_time_subscriptions: number;
|
||||
renewals: number;
|
||||
upgrades: number;
|
||||
downgrades: number;
|
||||
}
|
||||
|
||||
interface SubscribeGeneralStatistic {
|
||||
monthly: SubscriptionStats;
|
||||
yearly: SubscriptionStats;
|
||||
}
|
||||
|
||||
export const useSubscribeGeneralStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['subscribeGeneralStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchSubscribeGeneralStatistic()
|
||||
},
|
||||
select: (data: SubscribeGeneralStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchTariffStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface TariffItem {
|
||||
tariff_name: string;
|
||||
user_count: number;
|
||||
usage_percent: number;
|
||||
}
|
||||
|
||||
interface TariffStatistic {
|
||||
tariffs: TariffItem[];
|
||||
}
|
||||
|
||||
export const useMonitoringStats = () => {
|
||||
return useQuery({
|
||||
queryKey: ['tariffStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchTariffStatistic()
|
||||
},
|
||||
select: (data: TariffStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchTokensGeneralStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface BoughtPerUser {
|
||||
p5: number;
|
||||
p50: number;
|
||||
p95: number;
|
||||
}
|
||||
|
||||
interface SpentPerUser {
|
||||
p5: number;
|
||||
p50: number;
|
||||
p95: number;
|
||||
}
|
||||
|
||||
interface TokensGeneralStatistic {
|
||||
total_bought: number;
|
||||
total_spent: number;
|
||||
bought_per_user: BoughtPerUser;
|
||||
spent_per_user: SpentPerUser;
|
||||
}
|
||||
|
||||
export const useTokensGeneralStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['tokensGeneralStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchTokensGeneralStatistic()
|
||||
},
|
||||
select: (data: TokensGeneralStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchUserFilesTopStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface UserItem {
|
||||
full_name: string;
|
||||
user_id: number;
|
||||
count: number;
|
||||
files_size: number;
|
||||
}
|
||||
|
||||
interface UserFilesTopStatistic {
|
||||
tariffs: UserItem[];
|
||||
}
|
||||
|
||||
export const useUserFilesTopStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['userFilesTopStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchUserFilesTopStatistic()
|
||||
},
|
||||
select: (data: UserFilesTopStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchUserGeneralStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
|
||||
interface UserGeneralStatistic {
|
||||
total_users: number;
|
||||
new_last_30_days: number;
|
||||
new_previous_30_days: number;
|
||||
growth_percent: number;
|
||||
new_current_month: number;
|
||||
new_previous_month: number;
|
||||
month_growth_percent: number;
|
||||
}
|
||||
|
||||
export const useUserGeneralStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['userGeneralStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchUserGeneralStatistic()
|
||||
},
|
||||
select: (data: UserGeneralStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { fetchViolationGeneralStatistic } from '@/app/actions/statisticActions';
|
||||
|
||||
interface ViolationGeneralStatistic {
|
||||
total_violations: number;
|
||||
total_complaints: number;
|
||||
total_law_cases: number;
|
||||
complaints_without_case: number;
|
||||
violations_with_complaint: number;
|
||||
violations_without_complaint: number;
|
||||
}
|
||||
|
||||
export const useViolationGeneralStatistic = () => {
|
||||
return useQuery({
|
||||
queryKey: ['violationGeneralStatistic'],
|
||||
queryFn: () => {
|
||||
return fetchViolationGeneralStatistic()
|
||||
},
|
||||
select: (data: ViolationGeneralStatistic | null) => {
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data;
|
||||
},
|
||||
retry: false
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user