From ecb228bf35c651cb3e2cf8e75f6deb633527143e Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Tue, 10 Oct 2023 15:53:04 +0700 Subject: [PATCH] Update for new proposal (#2286) * update hardcoded option title * update env * update title also for participants --- .../KyberDAO/Vote/ProposalItem/OptionButton.tsx | 6 +++++- .../KyberDAO/Vote/ProposalItem/Participants.tsx | 15 +++++++++++---- src/pages/KyberDAO/Vote/ProposalItem/index.tsx | 3 ++- src/pages/KyberDAO/constants.tsx | 5 +++++ 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 src/pages/KyberDAO/constants.tsx diff --git a/src/pages/KyberDAO/Vote/ProposalItem/OptionButton.tsx b/src/pages/KyberDAO/Vote/ProposalItem/OptionButton.tsx index 906c27b9e6..b2bd476f57 100644 --- a/src/pages/KyberDAO/Vote/ProposalItem/OptionButton.tsx +++ b/src/pages/KyberDAO/Vote/ProposalItem/OptionButton.tsx @@ -8,6 +8,7 @@ import RadioButtonChecked from 'components/Icons/RadioButtonChecked' import RadioButtonUnchecked from 'components/Icons/RadioButtonUnchecked' import { RowBetween, RowFit } from 'components/Row' import { MouseoverTooltip } from 'components/Tooltip' +import { HARDCODED_OPTION_TITLE } from 'pages/KyberDAO/constants' const Wrapper = styled.div<{ type?: 'Finished' | 'Active' | 'Choosing' | 'Pending'; disabled?: boolean }>` border-radius: 4px; @@ -112,6 +113,7 @@ export default function OptionButton({ onOptionClick, isCheckBox, disabled, + proposalId, id, }: { checked?: boolean @@ -121,9 +123,11 @@ export default function OptionButton({ onOptionClick?: () => void isCheckBox: boolean disabled?: boolean + proposalId: number id: number }) { const parsedPercent = parseFloat(percent.toFixed(2) || '0') + const hardCodedTitle = HARDCODED_OPTION_TITLE[proposalId][id] return ( !disabled && onOptionClick?.()} disabled={disabled} type={type}>
@@ -147,7 +151,7 @@ export default function OptionButton({ )}{' '} - {`${id}. ${title}`} + {`${id}. ${hardCodedTitle || title}`} diff --git a/src/pages/KyberDAO/Vote/ProposalItem/Participants.tsx b/src/pages/KyberDAO/Vote/ProposalItem/Participants.tsx index ef858197b2..1715ab8f7d 100644 --- a/src/pages/KyberDAO/Vote/ProposalItem/Participants.tsx +++ b/src/pages/KyberDAO/Vote/ProposalItem/Participants.tsx @@ -11,6 +11,7 @@ import Row, { RowBetween, RowFit } from 'components/Row' import { useProposalInfoById } from 'hooks/kyberdao' import { ProposalType, VoteDetail } from 'hooks/kyberdao/types' import useTheme from 'hooks/useTheme' +import { HARDCODED_OPTION_TITLE } from 'pages/KyberDAO/constants' import { getFullDisplayBalance } from 'utils/formatBalance' const Wrapper = styled.div` @@ -176,15 +177,21 @@ export default function Participants({ proposalId }: { proposalId?: number }) { return ( {options && participants - ? options.map((o, index) => { + ? options.map((optionTitle, index) => { const sumPower = proposalInfo?.vote_stats.options.find(option => option.option === index)?.vote_count const isWonOption = proposalInfo?.proposal_type === ProposalType.BinaryProposal && proposalInfo?.vote_stats?.options.reduce((max, o) => (o.vote_count > max.vote_count ? o : max)).option === index const filteredParticipants = participants.filter(p => p.option === index) + const hardCodedTitle = proposalId ? HARDCODED_OPTION_TITLE[proposalId][index] : undefined return ( - setModalIndex(index)} hasHoverStyle> + setModalIndex(index)} + hasHoverStyle + > {isWonOption && gold-medal} @@ -192,7 +199,7 @@ export default function Participants({ proposalId }: { proposalId?: number }) { fontSize={isLongText ? '14px' : '16px'} style={{ overflow: 'hidden', textOverflow: 'ellipsis' }} > - {o} + {hardCodedTitle || optionTitle} @@ -234,7 +241,7 @@ export default function Participants({ proposalId }: { proposalId?: number }) { onDismiss={() => setModalIndex(null)} isWonOption={isWonOption} sumPower={sumPower} - option={o} + option={optionTitle} /> ) diff --git a/src/pages/KyberDAO/Vote/ProposalItem/index.tsx b/src/pages/KyberDAO/Vote/ProposalItem/index.tsx index 705a6dab79..1c2bfedc8c 100644 --- a/src/pages/KyberDAO/Vote/ProposalItem/index.tsx +++ b/src/pages/KyberDAO/Vote/ProposalItem/index.tsx @@ -187,7 +187,7 @@ const VoteButton = ({ ) } -const FORCED_TO_BINARY_OPTION_PROPOSALS = [14, 15, 17, 18] +const FORCED_TO_BINARY_OPTION_PROPOSALS = [14, 15, 17, 18, 19] function ProposalItem({ proposal, @@ -324,6 +324,7 @@ function ProposalItem({ : 'Finished' } isCheckBox={proposal.proposal_type === ProposalType.GenericProposal && !isForcedBinaryOption} + proposalId={proposal.proposal_id} id={index} /> ) diff --git a/src/pages/KyberDAO/constants.tsx b/src/pages/KyberDAO/constants.tsx new file mode 100644 index 0000000000..5102d61e9d --- /dev/null +++ b/src/pages/KyberDAO/constants.tsx @@ -0,0 +1,5 @@ +// Operator miss typing option title, need to custom it in UI +// { [ProposalId]: {[OptionId]: newTitle } } +export const HARDCODED_OPTION_TITLE: Record> = { + 19: { 1: 'Base - KNC-USDC & KNC-ETH' }, +}