1
- import React , { useCallback , useState } from "react" ;
1
+ import React , { useCallback , useMemo , useState } from "react" ;
2
2
import styled from "styled-components" ;
3
3
4
4
import ReactMarkdown from "react-markdown" ;
5
5
import { useParams } from "react-router-dom" ;
6
6
7
- import { Button } from "@kleros/ui-components-library" ;
7
+ import { Button , Tooltip } from "@kleros/ui-components-library" ;
8
8
9
9
import { usePopulatedDisputeData } from "hooks/queries/usePopulatedDisputeData" ;
10
10
import { isUndefined } from "utils/index" ;
@@ -13,10 +13,13 @@ 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%;
19
20
height: auto;
21
+ display: flex;
22
+ flex-direction: column;
20
23
` ;
21
24
22
25
const OptionsContainer = styled . div `
@@ -40,6 +43,9 @@ const RefuseToArbitrateContainer = styled.div`
40
43
justify-content: center;
41
44
` ;
42
45
46
+ const StyledEnsureChain = styled ( EnsureChain ) `
47
+ align-self: center;
48
+ ` ;
43
49
interface IOptions {
44
50
arbitrable : `0x${string } `;
45
51
handleSelection : ( arg0 : bigint ) => Promise < void > ;
@@ -53,6 +59,12 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
53
59
const [ chosenOption , setChosenOption ] = useState ( BigInt ( - 1 ) ) ;
54
60
const [ isSending , setIsSending ] = useState ( false ) ;
55
61
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 ] ) ;
67
+
56
68
const onClick = useCallback (
57
69
async ( id : bigint ) => {
58
70
setIsSending ( true ) ;
@@ -71,30 +83,36 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
71
83
{ ! isUndefined ( justification ) && ! isUndefined ( setJustification ) ? (
72
84
< JustificationArea { ...{ justification, setJustification } } />
73
85
) : null }
74
- < OptionsContainer >
75
- { disputeDetails ?. answers ?. map ( ( answer : Answer ) => {
76
- return (
77
- < EnsureChain key = { answer . title } >
78
- < Button
79
- text = { answer . title }
80
- disabled = { isSending }
81
- isLoading = { chosenOption === BigInt ( answer . id ) }
82
- onClick = { ( ) => onClick ( BigInt ( answer . id ) ) }
83
- />
84
- </ EnsureChain >
85
- ) ;
86
- } ) }
87
- </ OptionsContainer >
86
+ { isUndefined ( disputeDetails ?. answers ) ? null : (
87
+ < StyledEnsureChain >
88
+ < OptionsContainer >
89
+ { disputeDetails ?. answers ?. map ( ( answer : Answer ) => {
90
+ return BigInt ( answer . id ) !== BigInt ( 0 ) ? (
91
+ < Tooltip text = { answer . description } key = { answer . title } >
92
+ < Button
93
+ text = { answer . title }
94
+ disabled = { isSending }
95
+ isLoading = { chosenOption === BigInt ( answer . id ) }
96
+ onClick = { ( ) => onClick ( BigInt ( answer . id ) ) }
97
+ />
98
+ </ Tooltip >
99
+ ) : null ;
100
+ } ) }
101
+ </ OptionsContainer >
102
+ </ StyledEnsureChain >
103
+ ) }
88
104
</ MainContainer >
89
105
< RefuseToArbitrateContainer >
90
106
< EnsureChain >
91
- < Button
92
- variant = "secondary"
93
- text = "Refuse to Arbitrate"
94
- disabled = { isSending }
95
- isLoading = { chosenOption === BigInt ( 0 ) }
96
- onClick = { ( ) => onClick ( BigInt ( 0 ) ) }
97
- />
107
+ < Tooltip text = { updatedRTA . description } >
108
+ < Button
109
+ variant = "secondary"
110
+ text = { updatedRTA . title }
111
+ disabled = { isSending }
112
+ isLoading = { chosenOption === BigInt ( 0 ) }
113
+ onClick = { ( ) => onClick ( BigInt ( 0 ) ) }
114
+ />
115
+ </ Tooltip >
98
116
</ EnsureChain >
99
117
</ RefuseToArbitrateContainer >
100
118
</ >
0 commit comments