parent
472d9ab92f
commit
147901540a
@ -1,43 +1,52 @@
|
|||||||
import { useQuery } from "react-query";
|
import { useQuery } from "react-query";
|
||||||
import { TStatGetParams, statController } from "../../API/LayoutApi/statistic";
|
import { TStatGetParams, statController } from "../../API/LayoutApi/statistic";
|
||||||
|
|
||||||
export const useStatsData = ({search, team, start_date, end_date}: TStatGetParams) => {
|
export const useStatsData = ({
|
||||||
return useQuery(
|
search,
|
||||||
[`stats/all-users/`, search, team, start_date, end_date],
|
team,
|
||||||
() => statController.read({search, team, start_date, end_date}),
|
start_date,
|
||||||
{ refetchOnWindowFocus: false }
|
end_date,
|
||||||
);
|
for_salary,
|
||||||
|
}: TStatGetParams) => {
|
||||||
|
return useQuery(
|
||||||
|
[`stats/all-users/`, search, team, start_date, end_date, for_salary],
|
||||||
|
() =>
|
||||||
|
statController.read({ search, team, start_date, end_date, for_salary }),
|
||||||
|
{ refetchOnWindowFocus: false }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
export const useStatTeamData = ({search, start_date, end_date}: TStatGetParams) => {
|
export const useStatTeamData = ({
|
||||||
return useQuery(
|
search,
|
||||||
[`stats/all-teams/`, search, start_date, end_date],
|
start_date,
|
||||||
() => statController.team({search, start_date, end_date}),
|
end_date,
|
||||||
{ refetchOnWindowFocus: false }
|
}: TStatGetParams) => {
|
||||||
);
|
return useQuery(
|
||||||
|
[`stats/all-teams/`, search, start_date, end_date],
|
||||||
|
() => statController.team({ search, start_date, end_date }),
|
||||||
|
{ refetchOnWindowFocus: false }
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCreatorsData = ({ start_date, end_date}: TStatGetParams) => {
|
export const useCreatorsData = ({ start_date, end_date }: TStatGetParams) => {
|
||||||
return useQuery(
|
return useQuery(
|
||||||
[`stats/task-creators/`, start_date, end_date],
|
[`stats/task-creators/`, start_date, end_date],
|
||||||
() => statController.creators({ start_date, end_date}),
|
() => statController.creators({ start_date, end_date }),
|
||||||
{ refetchOnWindowFocus: false }
|
{ refetchOnWindowFocus: false }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCardData = ({ start_date, end_date}: TStatGetParams) => {
|
export const useCardData = ({ start_date, end_date }: TStatGetParams) => {
|
||||||
return useQuery(
|
return useQuery(
|
||||||
[`stats/tasks-comparison/`, start_date, end_date],
|
[`stats/tasks-comparison/`, start_date, end_date],
|
||||||
() => statController.cards({ start_date, end_date}),
|
() => statController.cards({ start_date, end_date }),
|
||||||
{ refetchOnWindowFocus: false }
|
{ refetchOnWindowFocus: false }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useStatOne = (
|
export const useStatOne = (statId: number | string | undefined): any => {
|
||||||
statId: number | string | undefined
|
return useQuery(
|
||||||
): any => {
|
[`stat/${statId || "all"}`, statId],
|
||||||
return useQuery(
|
() => statController.statOne(statId),
|
||||||
[`stat/${statId || "all"}`, statId],
|
{ refetchOnWindowFocus: false }
|
||||||
() => statController.statOne(statId),
|
);
|
||||||
{ refetchOnWindowFocus: false }
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
export type TStat = {
|
export type TStat = {
|
||||||
id: number;
|
id: number;
|
||||||
full_name: string;
|
full_name: string;
|
||||||
username: string;
|
username: string;
|
||||||
team_id: number | null;
|
team_id: number | null;
|
||||||
total_points: number;
|
total_points: number;
|
||||||
}
|
for_salary: boolean;
|
||||||
|
};
|
||||||
export type TStatTeam = {
|
export type TStatTeam = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
total_points: number;
|
total_points: number;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type TCard = {
|
export type TCard = {
|
||||||
all_tasks: number;
|
all_tasks: number;
|
||||||
active_tasks: number;
|
active_tasks: number;
|
||||||
active_tasks_percentage: number;
|
active_tasks_percentage: number;
|
||||||
inactive_tasks: number;
|
inactive_tasks: number;
|
||||||
inactive_tasks_percentage: number;
|
inactive_tasks_percentage: number;
|
||||||
}
|
};
|
||||||
|
Loading…
Reference in new issue