30 lines
734 B
TypeScript
30 lines
734 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
import type { Moment } from "moment";
|
|
import {getStatisticPromocode} from "@root/api/quizStatistic";
|
|
|
|
interface useStatisticProps {
|
|
to: Moment | null;
|
|
from: Moment | null;
|
|
}
|
|
|
|
export function usePromocodeStatistic({ to, from }: useStatisticProps) {
|
|
const formatTo = to?.unix();
|
|
const formatFrom = from?.unix();
|
|
|
|
const [statisticPromo, setStatisticPromo] = useState<any>([])
|
|
|
|
useEffect(() => {
|
|
|
|
const requestStatistics = async () => {
|
|
|
|
const gottenData = await getStatisticPromocode(Number(formatFrom), Number(formatTo));
|
|
setStatisticPromo(gottenData)
|
|
}
|
|
|
|
requestStatistics();
|
|
}, []);
|
|
|
|
return statisticPromo;
|
|
}
|