@@ -13,6 +13,7 @@ import { EnsureChain } from "components/EnsureChain";
13
13
14
14
import JustificationArea from "./JustificationArea" ;
15
15
import { Answer } from "@kleros/kleros-sdk" ;
16
+ import { RefuseToArbitrateAnswer } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsSchema" ;
16
17
17
18
const MainContainer = styled . div `
18
19
width: 100%;
@@ -58,11 +59,11 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
58
59
const [ chosenOption , setChosenOption ] = useState ( BigInt ( - 1 ) ) ;
59
60
const [ isSending , setIsSending ] = useState ( false ) ;
60
61
61
- // if RTA not found in dispute.answers, show RTA. shows RTA in case of invalid dispute too
62
- const showRTA = useMemo (
63
- ( ) => isUndefined ( disputeDetails ?. answers ?. find ( ( answer ) => BigInt ( answer . id ) === BigInt ( 0 ) ) ) ,
64
- [ disputeDetails ]
65
- ) ;
62
+ const updatedRTA = useMemo ( ( ) => {
63
+ const RTAFromTemplate = disputeDetails ?. answers ?. find ( ( answer ) => BigInt ( answer . id ) === BigInt ( 0 ) ) ;
64
+ if ( ! RTAFromTemplate ) return RefuseToArbitrateAnswer ;
65
+ return RTAFromTemplate ;
66
+ } , [ disputeDetails ] ) ;
66
67
67
68
const onClick = useCallback (
68
69
async ( id : bigint ) => {
@@ -86,7 +87,7 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
86
87
< StyledEnsureChain >
87
88
< OptionsContainer >
88
89
{ disputeDetails ?. answers ?. map ( ( answer : Answer ) => {
89
- return (
90
+ return BigInt ( answer . id ) !== BigInt ( 0 ) ? (
90
91
< Tooltip text = { answer . description } key = { answer . title } >
91
92
< Button
92
93
text = { answer . title }
@@ -95,25 +96,25 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
95
96
onClick = { ( ) => onClick ( BigInt ( answer . id ) ) }
96
97
/>
97
98
</ Tooltip >
98
- ) ;
99
+ ) : null ;
99
100
} ) }
100
101
</ OptionsContainer >
101
102
</ StyledEnsureChain >
102
103
) }
103
104
</ MainContainer >
104
- { showRTA ? (
105
- < RefuseToArbitrateContainer >
106
- < EnsureChain >
105
+ < RefuseToArbitrateContainer >
106
+ < EnsureChain >
107
+ < Tooltip text = { updatedRTA . description } >
107
108
< Button
108
109
variant = "secondary"
109
- text = "Refuse to Arbitrate"
110
+ text = { updatedRTA . title }
110
111
disabled = { isSending }
111
112
isLoading = { chosenOption === BigInt ( 0 ) }
112
113
onClick = { ( ) => onClick ( BigInt ( 0 ) ) }
113
114
/>
114
- </ EnsureChain >
115
- </ RefuseToArbitrateContainer >
116
- ) : null }
115
+ </ Tooltip >
116
+ </ EnsureChain >
117
+ </ RefuseToArbitrateContainer >
117
118
</ >
118
119
) : null ;
119
120
} ;
0 commit comments