28 lines
740 B
TypeScript
28 lines
740 B
TypeScript
import { useEffect, useState } from "react";
|
|
import { getStatisticSchild } from "@root/api/quizStatistics";
|
|
|
|
import type { Moment } from "moment";
|
|
|
|
import type { QuizStatisticsItem } from "@root/api/quizStatistics/types";
|
|
|
|
export const useSchildStatistics = (from: Moment | null, to: Moment | null) => {
|
|
const formatTo = to?.unix();
|
|
const formatFrom = from?.unix();
|
|
const [statistics, setStatistics] = useState<QuizStatisticsItem[]>([]);
|
|
|
|
useEffect(() => {
|
|
const StatisticsShild = async () => {
|
|
const gottenData = await getStatisticSchild(
|
|
Number(formatFrom),
|
|
Number(formatTo)
|
|
);
|
|
|
|
setStatistics(gottenData);
|
|
};
|
|
|
|
StatisticsShild();
|
|
}, [formatTo, formatFrom]);
|
|
|
|
return statistics;
|
|
};
|