@@ -13,6 +13,7 @@ import { EnsureChain } from "components/EnsureChain";
1313
1414import JustificationArea from "./JustificationArea" ;
1515import { Answer } from "@kleros/kleros-sdk" ;
16+ import { RefuseToArbitrateAnswer } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsSchema" ;
1617
1718const MainContainer = styled . div `
1819 width: 100%;
@@ -58,11 +59,11 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
5859 const [ chosenOption , setChosenOption ] = useState ( BigInt ( - 1 ) ) ;
5960 const [ isSending , setIsSending ] = useState ( false ) ;
6061
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 ] ) ;
6667
6768 const onClick = useCallback (
6869 async ( id : bigint ) => {
@@ -86,7 +87,7 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
8687 < StyledEnsureChain >
8788 < OptionsContainer >
8889 { disputeDetails ?. answers ?. map ( ( answer : Answer ) => {
89- return (
90+ return BigInt ( answer . id ) !== BigInt ( 0 ) ? (
9091 < Tooltip text = { answer . description } key = { answer . title } >
9192 < Button
9293 text = { answer . title }
@@ -95,25 +96,25 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
9596 onClick = { ( ) => onClick ( BigInt ( answer . id ) ) }
9697 />
9798 </ Tooltip >
98- ) ;
99+ ) : null ;
99100 } ) }
100101 </ OptionsContainer >
101102 </ StyledEnsureChain >
102103 ) }
103104 </ MainContainer >
104- { showRTA ? (
105- < RefuseToArbitrateContainer >
106- < EnsureChain >
105+ < RefuseToArbitrateContainer >
106+ < EnsureChain >
107+ < Tooltip text = { updatedRTA . description } >
107108 < Button
108109 variant = "secondary"
109- text = "Refuse to Arbitrate"
110+ text = { updatedRTA . title }
110111 disabled = { isSending }
111112 isLoading = { chosenOption === BigInt ( 0 ) }
112113 onClick = { ( ) => onClick ( BigInt ( 0 ) ) }
113114 />
114- </ EnsureChain >
115- </ RefuseToArbitrateContainer >
116- ) : null }
115+ </ Tooltip >
116+ </ EnsureChain >
117+ </ RefuseToArbitrateContainer >
117118 </ >
118119 ) : null ;
119120} ;
0 commit comments