@@ -10,6 +10,7 @@ import { klerosCoreAbi, klerosCoreAddress } from "hooks/contracts/generated";
10
10
import useTransactionBatcher , { type TransactionBatcherConfig } from "hooks/useTransactionBatcher" ;
11
11
import { wrapWithToast } from "utils/wrapWithToast" ;
12
12
13
+ import { Period } from "src/graphql/graphql" ;
13
14
import { isUndefined } from "src/utils" ;
14
15
15
16
import { IBaseMaintenanceButton } from "." ;
@@ -21,9 +22,10 @@ const StyledButton = styled(Button)`
21
22
interface IDistributeRewards extends IBaseMaintenanceButton {
22
23
numberOfVotes ?: string ;
23
24
roundIndex ?: string ;
25
+ period ?: string ;
24
26
}
25
27
26
- const DistributeRewards : React . FC < IDistributeRewards > = ( { id, numberOfVotes, roundIndex, setIsOpen } ) => {
28
+ const DistributeRewards : React . FC < IDistributeRewards > = ( { id, numberOfVotes, roundIndex, setIsOpen, period } ) => {
27
29
const [ isSending , setIsSending ] = useState ( false ) ;
28
30
const [ contractConfigs , setContractConfigs ] = useState < TransactionBatcherConfig > ( ) ;
29
31
const publicClient = usePublicClient ( ) ;
@@ -51,12 +53,18 @@ const DistributeRewards: React.FC<IDistributeRewards> = ({ id, numberOfVotes, ro
51
53
setContractConfigs ( argsArr ) ;
52
54
} , [ id , roundIndex , numberOfVotes , chainId ] ) ;
53
55
54
- const { executeBatch, isLoading : isLoadingConfig , isError } = useTransactionBatcher ( contractConfigs ) ;
56
+ const {
57
+ executeBatch,
58
+ isLoading : isLoadingConfig ,
59
+ isError,
60
+ } = useTransactionBatcher ( contractConfigs , {
61
+ enabled : ! isUndefined ( period ) && period === Period . Execution ,
62
+ } ) ;
55
63
56
64
const isLoading = useMemo ( ( ) => isLoadingConfig || isSending , [ isLoadingConfig , isSending ] ) ;
57
65
const isDisabled = useMemo (
58
- ( ) => isUndefined ( id ) || isUndefined ( numberOfVotes ) || isError || isLoading ,
59
- [ id , numberOfVotes , isError , isLoading ]
66
+ ( ) => isUndefined ( id ) || isUndefined ( numberOfVotes ) || isError || isLoading || period !== Period . Execution ,
67
+ [ id , numberOfVotes , isError , isLoading , period ]
60
68
) ;
61
69
62
70
const handleClick = ( ) => {
0 commit comments