@@ -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,28 @@ 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+ } catch ( error ) {
38+ showNotification ( {
39+ message : 'Something went wrong' ,
40+ type : TopNotificationType . WARNING ,
41+ durationMs : 5000 ,
42+ } ) ;
43+ }
3444 } ;
3545
3646 const handleOpenReportAbuseModal = ( ) => {
@@ -90,7 +100,7 @@ export function MoreButton({ job, isDisabled }: MoreButtonProps) {
90100 } }
91101 >
92102 < MenuList >
93- < ListItemButton onClick = { handleCancelTask } >
103+ < ListItemButton onClick = { ( ) => void handleCancelTask ( ) } >
94104 { t ( 'worker.reportAbuse.cancel' ) }
95105 </ ListItemButton >
96106 < ListItemButton onClick = { handleOpenReportAbuseModal } >
0 commit comments