Skip to content

Commit

Permalink
added logic to extract the part of the proposal needed for the usepro…
Browse files Browse the repository at this point in the history
…posal hook
  • Loading branch information
Barukimang committed Jul 9, 2024
1 parent ad5bd26 commit 0eacf19
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 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,29 +44,29 @@ 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}`;
const transferDaoName = toDisplayEns(ensDomain) || daoName;

const {data: proposal} = useProposal({
pluginType: plugins?.[0].id as PluginTypes,
// id: proposalId?.toString() ?? '',
id: '0x3e3c5b75ef8c9f3b0e245395a4e64987b92bef81_0xe', //pieter: set id to debug navigating to proposal
id: proposalId?.toString() ?? '',
});

const handleNavigateToProposal = useCallback(() => {
const path = generatePath(Proposal, {
network,
dao: ensDomain || daoDetails?.address,
id: proposal?.id,
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 0eacf19

Please sign in to comment.