|
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";
|
@@ -53,6 +53,12 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
|
53 | 53 | const [chosenOption, setChosenOption] = useState(BigInt(-1));
|
54 | 54 | const [isSending, setIsSending] = useState(false);
|
55 | 55 |
|
| 56 | + // if RTA not found in dispute.answers, show RTA. shows RTA in case of invalid dispute too |
| 57 | + const showRTA = useMemo( |
| 58 | + () => isUndefined(disputeDetails?.answers.find((answer) => BigInt(answer.id) === BigInt(0))), |
| 59 | + [disputeDetails] |
| 60 | + ); |
| 61 | + |
56 | 62 | const onClick = useCallback(
|
57 | 63 | async (id: bigint) => {
|
58 | 64 | setIsSending(true);
|
@@ -86,17 +92,19 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
|
86 | 92 | })}
|
87 | 93 | </OptionsContainer>
|
88 | 94 | </MainContainer>
|
89 |
| - <RefuseToArbitrateContainer> |
90 |
| - <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 |
| - /> |
98 |
| - </EnsureChain> |
99 |
| - </RefuseToArbitrateContainer> |
| 95 | + {showRTA ? ( |
| 96 | + <RefuseToArbitrateContainer> |
| 97 | + <EnsureChain> |
| 98 | + <Button |
| 99 | + variant="secondary" |
| 100 | + text="Refuse to Arbitrate" |
| 101 | + disabled={isSending} |
| 102 | + isLoading={chosenOption === BigInt(0)} |
| 103 | + onClick={() => onClick(BigInt(0))} |
| 104 | + /> |
| 105 | + </EnsureChain> |
| 106 | + </RefuseToArbitrateContainer> |
| 107 | + ) : null} |
100 | 108 | </>
|
101 | 109 | ) : null;
|
102 | 110 | };
|
|
0 commit comments