модалка закрытия тикета
This commit is contained in:
parent
9fcadcfe59
commit
a2b7dc8f23
@ -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
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -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<unknown, unknown>({
|
||||
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 (
|
||||
<Modal
|
||||
open={openModal}
|
||||
onClose={() => setOpenModal(false)}
|
||||
aria-labelledby="modal-modal-title"
|
||||
aria-describedby="modal-modal-description"
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
position: "absolute",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
width: 400,
|
||||
bgcolor: "background.paper",
|
||||
border: "2px solid gray",
|
||||
borderRadius: "6px",
|
||||
boxShadow: 24,
|
||||
p: 4,
|
||||
}}
|
||||
>
|
||||
<Typography id="modal-modal-title" variant="h6" component="h2">
|
||||
Вы уверены, что хотите закрыть тикет?
|
||||
</Typography>
|
||||
<Box
|
||||
sx={{
|
||||
mt: "20px",
|
||||
display: "flex",
|
||||
width: "332px",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
onClick={CloseTicket}
|
||||
sx={{width: "40px", height: "25px"}}
|
||||
>
|
||||
Да
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => setOpenModal(false)}
|
||||
sx={{width: "40px", height: "25px"}}
|
||||
>
|
||||
Нет
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
@ -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<HTMLDivElement>(null);
|
||||
const ticketId = useParams().ticketId;
|
||||
const [openModal, setOpenModal] = useState(false)
|
||||
|
||||
useEffect(
|
||||
function updateCurrentPageOnScroll() {
|
||||
@ -95,24 +97,7 @@ export default function TicketList({
|
||||
<SearchOutlinedIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
try {
|
||||
const ticketCloseResponse = await makeRequest<unknown, unknown>({
|
||||
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}`];
|
||||
}
|
||||
}}
|
||||
onClick={()=> setOpenModal(true)}
|
||||
variant="text"
|
||||
sx={{
|
||||
width: "100%",
|
||||
@ -131,6 +116,7 @@ export default function TicketList({
|
||||
ЗАКРЫТЬ ТИКЕТ
|
||||
<HighlightOffOutlinedIcon />
|
||||
</Button>
|
||||
<CloseTicketModal openModal={openModal} setOpenModal={setOpenModal} ticketId={ticketId}/>
|
||||
</Box>
|
||||
<Box
|
||||
ref={ticketsBoxRef}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user