@@ -6,6 +6,7 @@ import { useParams } from 'react-router-dom';
66import { useTranslation } from 'react-i18next' ;
77import { useModal } from '@/shared/contexts/modal-context' ;
88import { useIsMobile } from '@/shared/hooks/use-is-mobile' ;
9+ import { TopNotificationType , useNotification } from '@/shared/hooks' ;
910import { useResignJobMutation } from '../my-jobs/hooks' ;
1011import { type MyJob } from '../schemas' ;
1112import { ReportAbuseModal } from './report-abuse-modal' ;
@@ -18,19 +19,33 @@ interface MoreButtonProps {
1819export function MoreButton ( { job, isDisabled } : MoreButtonProps ) {
1920 const [ anchorEl , setAnchorEl ] = useState < HTMLButtonElement | null > ( null ) ;
2021 const { address : oracleAddress } = useParams < { address : string } > ( ) ;
21- const { mutate : rejectTaskMutation } = useResignJobMutation ( ) ;
22+ const { mutateAsync : rejectTaskMutation } = useResignJobMutation ( ) ;
2223 const { openModal, closeModal } = useModal ( ) ;
2324 const isMobile = useIsMobile ( ) ;
2425 const { t } = useTranslation ( ) ;
26+ const { showNotification } = useNotification ( ) ;
2527
2628 const isOpen = Boolean ( anchorEl ) ;
2729
28- const handleCancelTask = ( ) => {
30+ const handleCancelTask = async ( ) => {
2931 setAnchorEl ( null ) ;
30- rejectTaskMutation ( {
31- oracle_address : oracleAddress ?? '' ,
32- assignment_id : job . assignment_id ,
33- } ) ;
32+ try {
33+ await rejectTaskMutation ( {
34+ oracle_address : oracleAddress ?? '' ,
35+ assignment_id : job . assignment_id ,
36+ } ) ;
37+ showNotification ( {
38+ message : 'Task cancelled. Press Refresh button to see the changes' ,
39+ type : TopNotificationType . SUCCESS ,
40+ durationMs : 5000 ,
41+ } ) ;
42+ } catch ( error ) {
43+ showNotification ( {
44+ message : 'Something went wrong' ,
45+ type : TopNotificationType . WARNING ,
46+ durationMs : 5000 ,
47+ } ) ;
48+ }
3449 } ;
3550
3651 const handleOpenReportAbuseModal = ( ) => {
@@ -90,7 +105,7 @@ export function MoreButton({ job, isDisabled }: MoreButtonProps) {
90105 } }
91106 >
92107 < MenuList >
93- < ListItemButton onClick = { handleCancelTask } >
108+ < ListItemButton onClick = { ( ) => void handleCancelTask ( ) } >
94109 { t ( 'worker.reportAbuse.cancel' ) }
95110 </ ListItemButton >
96111 < ListItemButton onClick = { handleOpenReportAbuseModal } >
0 commit comments