From 8a1cd9c335ef230de65aac736a4ebd7249e948a9 Mon Sep 17 00:00:00 2001 From: Barukimang Date: Thu, 11 Jul 2024 12:45:46 +0300 Subject: [PATCH] fix(APP-2518): Link to proposal in the Finance Page Withdrawal isn't working (#1383) --- src/containers/transactionDetail/index.tsx | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/containers/transactionDetail/index.tsx b/src/containers/transactionDetail/index.tsx index bdde29dc8..4c0a3291e 100644 --- a/src/containers/transactionDetail/index.tsx +++ b/src/containers/transactionDetail/index.tsx @@ -23,6 +23,14 @@ import {Proposal} from 'utils/paths'; import {abbreviateTokenAmount} from 'utils/tokens'; import {Withdraw} from 'utils/types'; +// extract the part of proposal id needed for the useproposal hook +const extractProposalId = (proposalId: string): string => { + const parts = proposalId.split('_'); + const secondPart = parts[1]; + const truncatedSecondPart = secondPart.replace(/0{62}$/, ''); + return `${parts[0]}_${truncatedSecondPart}`; +}; + const TransactionDetail: React.FC = () => { const {t} = useTranslation(); const navigate = useNavigate(); @@ -36,9 +44,10 @@ const TransactionDetail: React.FC = () => { const explorerURL = CHAIN_METADATA[network].explorer; const transactionUrl = ` ${explorerURL}tx/${transfer.transaction}`; + const proposalId = transfer.transferType === TransferTypes.Withdraw - ? (transfer as Withdraw).proposalId + ? extractProposalId(String((transfer as Withdraw).proposalId)) : undefined; const daoExplorerURL = `${explorerURL}address/${address}`; @@ -50,15 +59,14 @@ const TransactionDetail: React.FC = () => { }); const handleNavigateToProposal = useCallback(() => { - navigate( - generatePath(Proposal, { - network, - dao: toDisplayEns(ensDomain) ?? daoName, - id: proposalId!.toUrlSlug(), // only called for Withdrawals - }) - ); + const path = generatePath(Proposal, { + network, + dao: ensDomain || daoDetails?.address, + id: proposalId, + }); + navigate(path); onClose(); - }, [ensDomain, daoName, navigate, network, onClose, proposalId]); + }, [network, ensDomain, daoDetails?.address, proposalId, navigate, onClose]); return (