статистика промокода(без кодвордов)
This commit is contained in:
parent
ddd345b0d1
commit
56f1a2f7ab
@ -1,21 +1,34 @@
|
||||
import {Table, TableBody, TableCell, TableHead, TableRow, Typography, useTheme} from "@mui/material";
|
||||
import {Button, Table, TableBody, TableCell, TableHead, TableRow, Typography, useTheme} from "@mui/material";
|
||||
import {AdapterMoment} from "@mui/x-date-pickers/AdapterMoment";
|
||||
import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
||||
import DateFilter from "@pages/dashboard/Content/QuizStatistic/dateFilter";
|
||||
import {useState} from "react";
|
||||
import {useEffect, useState} from "react";
|
||||
import moment, {Moment} from "moment";
|
||||
import {usePromocodeStatistic} from "@root/utils/hooks/usePromocodeStatistic";
|
||||
import {promocodeApi} from "@root/api/promocode/requests";
|
||||
import {useAllPromocodes} from "@root/api/promocode/swr";
|
||||
|
||||
export default function StstisticPromocode() {
|
||||
const theme = useTheme()
|
||||
const [from, setFrom] = useState<Moment | null>(moment("01.01.2023"));
|
||||
const [to, setTo] = useState<Moment | null>(moment(Date.now()));
|
||||
const promocodes = useAllPromocodes();
|
||||
|
||||
const statisticPromo = usePromocodeStatistic({to, from})
|
||||
|
||||
for (statisticPromo.key in statisticPromo) {
|
||||
const codewordSearch = promocodes.find(obj => obj.id === statisticPromo.key)
|
||||
let codeword = codewordSearch?.codeword
|
||||
console.log( "xnj 'nj", codeword)
|
||||
}
|
||||
|
||||
|
||||
return(
|
||||
<LocalizationProvider dateAdapter={AdapterMoment}>
|
||||
<Typography>Статистика промокодов</Typography>
|
||||
<Button
|
||||
onClick={async()=> promocodeApi.getAllPromocodes()}
|
||||
>promocodeList</Button>
|
||||
<DateFilter from={from} to={to} setFrom={setFrom} setTo={setTo}/>
|
||||
<Table
|
||||
sx={{
|
||||
@ -39,11 +52,28 @@ export default function StstisticPromocode() {
|
||||
<TableCell sx={{color: "inherit"}} align="center">Внесено</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{/*<TableCell sx={{color: "inherit"}} align="center">{Registrations}</TableCell>*/}
|
||||
{/*<TableCell sx={{color: "inherit"}} align="center">{Quizes}</TableCell>*/}
|
||||
{/*<TableCell sx={{color: "inherit"}} align="center">{Results}</TableCell>*/}
|
||||
</TableBody>
|
||||
|
||||
{Object.values(statisticPromo).map((sPromo:any)=> {
|
||||
let codeword
|
||||
let listPromo = promocodes
|
||||
let statisticP = statisticPromo
|
||||
console.log("in map", sPromo.key)
|
||||
|
||||
for (statisticP.key in statisticP) {
|
||||
const codewordSearch = listPromo.find(obj => obj.id === statisticP.key)
|
||||
codeword = codewordSearch?.codeword
|
||||
console.log(codeword)
|
||||
}
|
||||
|
||||
return(
|
||||
<TableBody>
|
||||
<TableCell sx={{color: "inherit"}} align="center">{codeword}</TableCell>
|
||||
<TableCell sx={{color: "inherit"}} align="center">{sPromo.Regs}</TableCell>
|
||||
<TableCell sx={{color: "inherit"}} align="center">{sPromo.Money}</TableCell>
|
||||
</TableBody>
|
||||
)
|
||||
})
|
||||
}
|
||||
</Table>
|
||||
</LocalizationProvider>
|
||||
)
|
||||
|
||||
@ -18,7 +18,7 @@ export function usePromocodeStatistic({ to, from }: useStatisticProps) {
|
||||
|
||||
const requestStatistics = async () => {
|
||||
|
||||
const gottenData = await getStatisticPromocode(Number(formatTo), Number(formatFrom));
|
||||
const gottenData = await getStatisticPromocode(Number(formatFrom), Number(formatTo));
|
||||
setStatisticPromo(gottenData)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user