open ticket

This commit is contained in:
hamid zarghami
2025-05-07 10:58:37 +03:30
parent d3ca7b2b71
commit 5852dd8fc4
4 changed files with 57 additions and 3 deletions
+9
View File
@@ -8,6 +8,7 @@ import { Pages } from '../../config/Pages'
import { useGetTickets } from './hooks/useTicketData' import { useGetTickets } from './hooks/useTicketData'
import moment from 'moment-jalaali' import moment from 'moment-jalaali'
import { TicketItemType } from './types/TicketTypes' import { TicketItemType } from './types/TicketTypes'
import OpenTicket from './components/OpenTicket'
const TicketList: FC = () => { const TicketList: FC = () => {
@@ -111,9 +112,17 @@ const TicketList: FC = () => {
<Td text={t(`ticket.${item.status}`)} /> <Td text={t(`ticket.${item.status}`)} />
<Td text={t(`ticket.${item.priority}`)} /> <Td text={t(`ticket.${item.priority}`)} />
<Td text={''}> <Td text={''}>
<div className='flex items-center gap-2'>
<Link to={Pages.ticket.detail + item.id}> <Link to={Pages.ticket.detail + item.id}>
<Eye size={20} color='#8C90A3' /> <Eye size={20} color='#8C90A3' />
</Link> </Link>
{
item.status === 'CLOSED' && (
<OpenTicket refetch={getTicket.refetch} id={item.id} />
)
}
</div>
</Td> </Td>
<Td text={''} /> <Td text={''} />
</tr> </tr>
@@ -0,0 +1,34 @@
import { FC } from 'react'
import Button from '../../../components/Button'
import { useOpenTicket } from '../hooks/useTicketData'
type Props = {
id: string,
refetch: () => void
}
const OpenTicket: FC<Props> = ({ id, refetch }) => {
const { mutate: openTicket, isPending } = useOpenTicket()
const handleOpenTicket = () => {
openTicket(id, {
onSuccess: () => {
refetch()
}
})
}
return (
<div>
<Button
label={'باز کردن تیکت'}
onClick={handleOpenTicket}
className='px-4 h-8 text-xs'
isLoading={isPending}
/>
</div>
)
}
export default OpenTicket
+6
View File
@@ -57,3 +57,9 @@ export const useReferTicket = () => {
api.referTicket(variables.id, variables.userId), api.referTicket(variables.id, variables.userId),
}); });
}; };
export const useOpenTicket = () => {
return useMutation({
mutationFn: (id: string) => api.openTicket(id),
});
};
@@ -44,3 +44,8 @@ export const referTicket = async (id: string, userId: string) => {
}); });
return data; return data;
}; };
export const openTicket = async (id: string) => {
const { data } = await axios.post(`/tickets/${id}/open`);
return data;
};