diff --git a/src/pages/dashboard/Content/QuizStatistic/index.tsx b/src/pages/dashboard/Content/QuizStatistic/index.tsx index 4c2b5e2..9e93461 100644 --- a/src/pages/dashboard/Content/QuizStatistic/index.tsx +++ b/src/pages/dashboard/Content/QuizStatistic/index.tsx @@ -5,6 +5,9 @@ import type { Moment } from "moment"; import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers'; import { useQuizStatistic } from '@root/utils/hooks/useQuizStatistic'; import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment' +import makeRequest from "@root/api/makeRequest"; +import {Discount} from "@frontend/kitui"; +import {parseAxiosError} from "@root/utils/parse-error"; export default () => { const theme = useTheme() @@ -56,6 +59,28 @@ export default () => { } }; + const StatisticsShild = async (from: any, to: any) => { + try { + const StatisticResponse = await makeRequest({ + url: process.env.REACT_APP_DOMAIN + "/customer/quizlogo/stat" , + method: "post", + useToken: true, + body: { + "to": to.unix(), + "from": from.unix(), + "page": 0, + "limit": 100 + }, + }); + + return [StatisticResponse]; + } catch (nativeError) { + const [error] = parseAxiosError(nativeError); + + return [null, `Ошибка запроса статистики. ${error}`]; + } + } + return <> @@ -135,6 +160,14 @@ export default () => { > Сбросить даты + void +} + +export default function CloseTicketModal({ticketId, openModal, setOpenModal}: Props) { + + const CloseTicket = async () => { + try { + const ticketCloseResponse = await makeRequest({ + url: process.env.REACT_APP_DOMAIN + "/heruvym/close" , + method: "post", + useToken: true, + body: { + "ticket": ticketId + }, + }); + + return [ticketCloseResponse]; + } catch (nativeError) { + const [error] = parseAxiosError(nativeError); + + return [null, `Не удалось закрыть тикет. ${error}`]; + } + } + + return ( + setOpenModal(false)} + aria-labelledby="modal-modal-title" + aria-describedby="modal-modal-description" + > + + + Вы уверены, что хотите закрыть тикет? + + + + + + + + ) +} \ No newline at end of file diff --git a/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx b/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx index 0dcfcdf..433a7ac 100644 --- a/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx +++ b/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx @@ -3,9 +3,13 @@ import SearchOutlinedIcon from "@mui/icons-material/SearchOutlined"; import { Box, Button, useMediaQuery, useTheme } from "@mui/material"; import { Ticket } from "@root/model/ticket"; import { incrementTicketsApiPage, useTicketStore } from "@root/stores/tickets"; -import { useEffect, useRef } from "react"; +import {useEffect, useRef, useState} from "react"; import TicketItem from "./TicketItem"; import { throttle } from "@frontend/kitui"; +import makeRequest from "@root/api/makeRequest"; +import {parseAxiosError} from "@root/utils/parse-error"; +import {useParams} from "react-router-dom"; +import CloseTicketModal from "@pages/dashboard/Content/Support/TicketList/CloseTicketModal"; type TicketListProps = { closeCollapse?: () => void; @@ -21,6 +25,8 @@ export default function TicketList({ const tickets = useTicketStore((state) => state.tickets); const ticketsFetchState = useTicketStore((state) => state.ticketsFetchState); const ticketsBoxRef = useRef(null); + const ticketId = useParams().ticketId; + const [openModal, setOpenModal] = useState(false) useEffect( function updateCurrentPageOnScroll() { @@ -91,6 +97,7 @@ export default function TicketList({ +