This commit is contained in:
@@ -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<Props> = ({ refetch }) => {
|
||||
|
||||
const { t } = useTranslation('global')
|
||||
const { id } = useParams()
|
||||
const [userId, setUserId] = useState<string>('')
|
||||
const getUsers = useGetUsers('', 'tickets')
|
||||
const referTicket = useReferTicket()
|
||||
const { t } = useTranslation("global");
|
||||
const { id } = useParams();
|
||||
const [userId, setUserId] = useState<string>("");
|
||||
const getUsers = useGetAdminsListAll();
|
||||
const referTicket = useReferTicket();
|
||||
|
||||
const handleReferTicket = () => {
|
||||
referTicket.mutate({ id: id as string, userId }, {
|
||||
referTicket.mutate(
|
||||
{ id: id as string, userId },
|
||||
{
|
||||
onSuccess: () => {
|
||||
refetch()
|
||||
toast(t('ticket.refer_ticket_success'), 'success')
|
||||
refetch();
|
||||
toast(t("ticket.refer_ticket_success"), "success");
|
||||
},
|
||||
onError: (error: ErrorType) => {
|
||||
toast(error.response?.data?.error.message[0], 'error')
|
||||
}
|
||||
})
|
||||
}
|
||||
toast(error.response?.data?.error.message[0], "error");
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={'bg-white p-6 rounded-3xl mt-8'}>
|
||||
<div className='flex justify-between'>
|
||||
<div className='text-sm'>
|
||||
{t('ticket.refer_ticket')}
|
||||
</div>
|
||||
<div className={"bg-white p-6 rounded-3xl mt-8"}>
|
||||
<div className="flex justify-between">
|
||||
<div className="text-sm">{t("ticket.refer_ticket")}</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4">
|
||||
{
|
||||
getUsers.data?.data?.users?.map((item: UserItemType) => (
|
||||
<div key={item.id} className='flex gap-2 items-center'>
|
||||
{getUsers.data?.data?.map((item: UserItemType) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className="flex gap-2 items-center"
|
||||
>
|
||||
<div>
|
||||
<CheckBoxComponent
|
||||
checked={userId === item.id}
|
||||
onChange={(e) => setUserId(e.target.checked ? item.id : '')}
|
||||
onChange={(e) => setUserId(e.target.checked ? item.id : "")}
|
||||
/>
|
||||
</div>
|
||||
<div className='text-xs leading-5'>
|
||||
{item.firstName + ' ' + item.lastName}
|
||||
<div className="text-xs leading-5">{item.firstName + " " + item.lastName}</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
))}
|
||||
|
||||
<div className='flex justify-end mt-4'>
|
||||
<div className="flex justify-end mt-4">
|
||||
<Button
|
||||
label={t('ticket.refer_ticket')}
|
||||
label={t("ticket.refer_ticket")}
|
||||
onClick={handleReferTicket}
|
||||
isLoading={referTicket.isPending}
|
||||
className='w-fit px-7'
|
||||
className="w-fit px-7"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default ReferTicket
|
||||
export default ReferTicket;
|
||||
|
||||
Reference in New Issue
Block a user