88 useMaterialReactTable ,
99 type MRT_ColumnDef ,
1010} from 'material-react-table' ;
11- import { Box , Button , Typography } from '@mui/material' ;
11+ import { Box , Typography } from '@mui/material' ;
1212import RefreshIcon from '@mui/icons-material/Refresh' ;
1313import { TableHeaderCell } from '@/components/ui/table/table-header-cell' ;
1414import {
@@ -18,6 +18,7 @@ import {
1818import { useMyJobsFilterStore } from '@/hooks/use-my-jobs-filter-store' ;
1919import { getNetworkName } from '@/smart-contracts/get-network-name' ;
2020import { RewardAmount } from '@/pages/worker/jobs/components/reward-amount' ;
21+ import { Button } from '@/components/ui/button' ;
2122import { Chip } from '@/components/ui/chip' ;
2223import { formatDate } from '@/shared/helpers/format-date' ;
2324import { EvmAddress } from '@/pages/worker/jobs/components/evm-address' ;
@@ -36,10 +37,15 @@ import type { JobType } from '@/smart-contracts/EthKVStore/config';
3637import { EscrowAddressSearchForm } from '@/pages/worker/jobs/components/escrow-address-search-form' ;
3738import { useRefreshTasksMutation } from '@/api/services/worker/refresh-tasks' ;
3839
39- const getColumnsDefinition = (
40- resignJob : ( assignment_id : string ) => void ,
41- refreshData : ( ) => void
42- ) : MRT_ColumnDef < MyJob > [ ] => [
40+ const getColumnsDefinition = ( {
41+ resignJob,
42+ refreshData,
43+ isRefreshTasksPending,
44+ } : {
45+ resignJob : ( assignment_id : string ) => void ;
46+ refreshData : ( ) => void ;
47+ isRefreshTasksPending : boolean ;
48+ } ) : MRT_ColumnDef < MyJob > [ ] => [
4349 {
4450 accessorKey : 'escrow_address' ,
4551 header : t ( 'worker.jobs.escrowAddress' ) ,
@@ -226,6 +232,7 @@ const getColumnsDefinition = (
226232 paddingInline : '1rem' ,
227233 fontSize : '13px' ,
228234 } }
235+ loading = { isRefreshTasksPending }
229236 type = "button"
230237 variant = "outlined"
231238 onClick = { refreshData }
@@ -256,7 +263,8 @@ export function MyJobsTable() {
256263 ) ;
257264
258265 const { mutate : rejectTaskMutation } = useRejectTaskMutation ( ) ;
259- const { mutate : refreshTasksMutation } = useRefreshTasksMutation ( ) ;
266+ const { mutate : refreshTasksMutation , isPending : isRefreshTasksPending } =
267+ useRefreshTasksMutation ( ) ;
260268 const { address : oracle_address } = useParams < { address : string } > ( ) ;
261269
262270 const [ paginationState , setPaginationState ] = useState ( {
@@ -294,10 +302,11 @@ export function MyJobsTable() {
294302 } , [ resetFilterParams ] ) ;
295303
296304 const table = useMaterialReactTable ( {
297- columns : getColumnsDefinition (
298- rejectTask ( oracle_address ?? '' ) ,
299- refreshTasks ( oracle_address ?? '' )
300- ) ,
305+ columns : getColumnsDefinition ( {
306+ resignJob : rejectTask ( oracle_address ?? '' ) ,
307+ refreshData : refreshTasks ( oracle_address ?? '' ) ,
308+ isRefreshTasksPending,
309+ } ) ,
301310 data : memoizedTableDataResults ,
302311 state : {
303312 isLoading : tableStatus === 'pending' ,
0 commit comments