From a2b7dc8f23e84f5e1c66614c4047ac08f6fa6ab9 Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 24 Apr 2024 02:26:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=BE=D0=B4=D0=B0=D0=BB=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D1=8F=20=D1=82=D0=B8?= =?UTF-8?q?=D0=BA=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/Content/QuizStatistic/index.tsx | 6 +- .../Support/TicketList/CloseTicketModal.tsx | 84 +++++++++++++++++++ .../Content/Support/TicketList/TicketList.tsx | 24 ++---- 3 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 src/pages/dashboard/Content/Support/TicketList/CloseTicketModal.tsx diff --git a/src/pages/dashboard/Content/QuizStatistic/index.tsx b/src/pages/dashboard/Content/QuizStatistic/index.tsx index 0a18d45..9e93461 100644 --- a/src/pages/dashboard/Content/QuizStatistic/index.tsx +++ b/src/pages/dashboard/Content/QuizStatistic/index.tsx @@ -66,10 +66,10 @@ export default () => { method: "post", useToken: true, body: { - "to": to, - "from": from, + "to": to.unix(), + "from": from.unix(), "page": 0, - "limit": 0 + "limit": 100 }, }); diff --git a/src/pages/dashboard/Content/Support/TicketList/CloseTicketModal.tsx b/src/pages/dashboard/Content/Support/TicketList/CloseTicketModal.tsx new file mode 100644 index 0000000..450d49c --- /dev/null +++ b/src/pages/dashboard/Content/Support/TicketList/CloseTicketModal.tsx @@ -0,0 +1,84 @@ +import Modal from "@mui/material/Modal"; +import {closeDeleteTariffDialog} from "@stores/tariffs"; +import Box from "@mui/material/Box"; +import Typography from "@mui/material/Typography"; +import Button from "@mui/material/Button"; +import makeRequest from "@root/api/makeRequest"; +import {parseAxiosError} from "@root/utils/parse-error"; +interface Props{ + ticketId: string | undefined, + openModal: boolean, + setOpenModal: (a: boolean) => 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 d4c712b..433a7ac 100644 --- a/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx +++ b/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx @@ -3,12 +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; @@ -25,6 +26,7 @@ export default function TicketList({ const ticketsFetchState = useTicketStore((state) => state.ticketsFetchState); const ticketsBoxRef = useRef(null); const ticketId = useParams().ticketId; + const [openModal, setOpenModal] = useState(false) useEffect( function updateCurrentPageOnScroll() { @@ -95,24 +97,7 @@ export default function TicketList({ +