diff --git a/src/pages/ticket/components/ReferTicket.tsx b/src/pages/ticket/components/ReferTicket.tsx index de17453..ff1472f 100644 --- a/src/pages/ticket/components/ReferTicket.tsx +++ b/src/pages/ticket/components/ReferTicket.tsx @@ -1,75 +1,73 @@ -import { FC, useState } from 'react' -import { useGetUsers } from '../../users/hooks/useUserData' -import { useTranslation } from 'react-i18next' -import { UserItemType } from '../../users/types/UserTypes' -import CheckBoxComponent from '../../../components/CheckBoxComponent' -import { useParams } from 'react-router-dom' -import { useReferTicket } from '../hooks/useTicketData' -import Button from '../../../components/Button' -import { toast } from '../../../components/Toast'; -import { ErrorType } from '../../../helpers/types' +import { FC, useState } from "react"; +import { useTranslation } from "react-i18next"; +import { useParams } from "react-router-dom"; +import Button from "../../../components/Button"; +import CheckBoxComponent from "../../../components/CheckBoxComponent"; +import { toast } from "../../../components/Toast"; +import { ErrorType } from "../../../helpers/types"; +import { useGetAdminsListAll } from "../../users/hooks/useUserData"; +import { UserItemType } from "../../users/types/UserTypes"; +import { useReferTicket } from "../hooks/useTicketData"; type Props = { - refetch: () => void -} + refetch: () => void; +}; const ReferTicket: FC = ({ refetch }) => { + const { t } = useTranslation("global"); + const { id } = useParams(); + const [userId, setUserId] = useState(""); + const getUsers = useGetAdminsListAll(); + const referTicket = useReferTicket(); - const { t } = useTranslation('global') - const { id } = useParams() - const [userId, setUserId] = useState('') - const getUsers = useGetUsers('', 'tickets') - const referTicket = useReferTicket() + const handleReferTicket = () => { + referTicket.mutate( + { id: id as string, userId }, + { + onSuccess: () => { + refetch(); + toast(t("ticket.refer_ticket_success"), "success"); + }, + onError: (error: ErrorType) => { + toast(error.response?.data?.error.message[0], "error"); + }, + }, + ); + }; - const handleReferTicket = () => { - referTicket.mutate({ id: id as string, userId }, { - onSuccess: () => { - refetch() - toast(t('ticket.refer_ticket_success'), 'success') - }, - onError: (error: ErrorType) => { - toast(error.response?.data?.error.message[0], 'error') - } - }) - } + return ( +
+
+
{t("ticket.refer_ticket")}
+
- return ( -
-
-
- {t('ticket.refer_ticket')} -
-
- -
- { - getUsers.data?.data?.users?.map((item: UserItemType) => ( -
-
- setUserId(e.target.checked ? item.id : '')} - /> -
-
- {item.firstName + ' ' + item.lastName} -
-
- )) - } - -
-
+
+ {getUsers.data?.data?.map((item: UserItemType) => ( +
+
+ setUserId(e.target.checked ? item.id : "")} + />
+
{item.firstName + " " + item.lastName}
+
+ ))} +
+
- ) -} +
+
+ ); +}; -export default ReferTicket \ No newline at end of file +export default ReferTicket;