Skip to content

Commit

Permalink
fix(APP-2518): Link to proposal in the Finance Page Withdrawal isn't …
Browse files Browse the repository at this point in the history
…working (#1383)
  • Loading branch information
Barukimang authored Jul 11, 2024
1 parent 8c5dfdb commit 8a1cd9c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/containers/transactionDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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}`;
Expand All @@ -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 (
<ModalBottomSheetSwitcher isOpen={isOpen} onClose={onClose}>
Expand Down

0 comments on commit 8a1cd9c

Please sign in to comment.