From 31df995d6a786e2b0e7e56c1bebab89448ffc865 Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Thu, 13 Feb 2025 12:03:34 +0530 Subject: [PATCH 01/10] refactor(sdk): allow-custom-description-for-rta --- .../src/dataMappings/utils/populateTemplate.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kleros-sdk/src/dataMappings/utils/populateTemplate.ts b/kleros-sdk/src/dataMappings/utils/populateTemplate.ts index a70668ab7..7797f0ff9 100644 --- a/kleros-sdk/src/dataMappings/utils/populateTemplate.ts +++ b/kleros-sdk/src/dataMappings/utils/populateTemplate.ts @@ -11,9 +11,18 @@ export const populateTemplate = (mustacheTemplate: string, data: any): DisputeDe throw validation.error; } - // Filter out any existing answer with id 0 and add our standard Refuse to Arbitrate option + const templateRTAAnswer = (dispute as DisputeDetails).answers.find( + (answer) => answer.id && BigInt(answer.id) === BigInt(0) + ); + + const CustomRTA: DisputeDetails["answers"][number] = { + ...RefuseToArbitrateAnswer, + description: templateRTAAnswer?.description ?? RefuseToArbitrateAnswer.description, + }; + + // Filter out any existing answer with id 0 and add customised Refuse to Arbitrate option (dispute as DisputeDetails).answers = [ - RefuseToArbitrateAnswer, + CustomRTA, ...((dispute as DisputeDetails).answers.filter((answer) => answer.id && BigInt(answer.id) !== BigInt(0)) || []), ]; From 6d752f3dd0f958ddb3526a58e9b610afd8cd91a1 Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Thu, 13 Feb 2025 12:15:36 +0530 Subject: [PATCH 02/10] refactor(web): hide-default-rta-option-if-alrd-shown-in-options --- .../Voting/Classic/OptionsContainer.tsx | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/web/src/pages/Cases/CaseDetails/Voting/Classic/OptionsContainer.tsx b/web/src/pages/Cases/CaseDetails/Voting/Classic/OptionsContainer.tsx index e3c4e2744..08186b682 100644 --- a/web/src/pages/Cases/CaseDetails/Voting/Classic/OptionsContainer.tsx +++ b/web/src/pages/Cases/CaseDetails/Voting/Classic/OptionsContainer.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from "react"; +import React, { useCallback, useMemo, useState } from "react"; import styled from "styled-components"; import ReactMarkdown from "react-markdown"; @@ -53,6 +53,12 @@ const Options: React.FC = ({ arbitrable, handleSelection, justificatio const [chosenOption, setChosenOption] = useState(BigInt(-1)); const [isSending, setIsSending] = useState(false); + // if RTA not found in dispute.answers, show RTA. shows RTA in case of invalid dispute too + const showRTA = useMemo( + () => isUndefined(disputeDetails?.answers.find((answer) => BigInt(answer.id) === BigInt(0))), + [disputeDetails] + ); + const onClick = useCallback( async (id: bigint) => { setIsSending(true); @@ -86,17 +92,19 @@ const Options: React.FC = ({ arbitrable, handleSelection, justificatio })} - - -