Skip to content

Commit 6d752f3

Browse files
committed
refactor(web): hide-default-rta-option-if-alrd-shown-in-options
1 parent 31df995 commit 6d752f3

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

web/src/pages/Cases/CaseDetails/Voting/Classic/OptionsContainer.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useState } from "react";
1+
import React, { useCallback, useMemo, useState } from "react";
22
import styled from "styled-components";
33

44
import ReactMarkdown from "react-markdown";
@@ -53,6 +53,12 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
5353
const [chosenOption, setChosenOption] = useState(BigInt(-1));
5454
const [isSending, setIsSending] = useState(false);
5555

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+
5662
const onClick = useCallback(
5763
async (id: bigint) => {
5864
setIsSending(true);
@@ -86,17 +92,19 @@ const Options: React.FC<IOptions> = ({ arbitrable, handleSelection, justificatio
8692
})}
8793
</OptionsContainer>
8894
</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}
100108
</>
101109
) : null;
102110
};

0 commit comments

Comments
 (0)