diff --git a/src/pages/ticket/TicketList.tsx b/src/pages/ticket/TicketList.tsx index 427c711..472b771 100644 --- a/src/pages/ticket/TicketList.tsx +++ b/src/pages/ticket/TicketList.tsx @@ -8,6 +8,7 @@ import { Pages } from '../../config/Pages' import { useGetTickets } from './hooks/useTicketData' import moment from 'moment-jalaali' import { TicketItemType } from './types/TicketTypes' +import OpenTicket from './components/OpenTicket' const TicketList: FC = () => { @@ -111,9 +112,17 @@ const TicketList: FC = () => { - - - +
+ + + + + { + item.status === 'CLOSED' && ( + + ) + } +
diff --git a/src/pages/ticket/components/OpenTicket.tsx b/src/pages/ticket/components/OpenTicket.tsx new file mode 100644 index 0000000..a9e5e65 --- /dev/null +++ b/src/pages/ticket/components/OpenTicket.tsx @@ -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 = ({ id, refetch }) => { + + const { mutate: openTicket, isPending } = useOpenTicket() + + const handleOpenTicket = () => { + openTicket(id, { + onSuccess: () => { + refetch() + } + }) + } + + return ( +
+
+ ) +} + +export default OpenTicket \ No newline at end of file diff --git a/src/pages/ticket/hooks/useTicketData.ts b/src/pages/ticket/hooks/useTicketData.ts index 60776cb..39f3d53 100644 --- a/src/pages/ticket/hooks/useTicketData.ts +++ b/src/pages/ticket/hooks/useTicketData.ts @@ -57,3 +57,9 @@ export const useReferTicket = () => { api.referTicket(variables.id, variables.userId), }); }; + +export const useOpenTicket = () => { + return useMutation({ + mutationFn: (id: string) => api.openTicket(id), + }); +}; diff --git a/src/pages/ticket/service/TicketServiec.ts b/src/pages/ticket/service/TicketServiec.ts index 017d0d5..7bf80cc 100644 --- a/src/pages/ticket/service/TicketServiec.ts +++ b/src/pages/ticket/service/TicketServiec.ts @@ -44,3 +44,8 @@ export const referTicket = async (id: string, userId: string) => { }); return data; }; + +export const openTicket = async (id: string) => { + const { data } = await axios.post(`/tickets/${id}/open`); + return data; +};