diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 0e2f46c..4fd986f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -20,6 +20,22 @@ export default function App() { const [tokenBalance, setTokenBalance] = useState(null); const [decimals, setDecimals] = useState(0); + const connect = () => { + const addr = prompt('Enter your Stellar address (G...):'); + if (addr?.startsWith('G')) setWalletAddress(addr); + }; + + const disconnect = () => setWalletAddress(null); + + useEffect(() => { + if (!walletAddress) { setTokenBalance(null); return; } + fetchTokenBalance(walletAddress).then(setTokenBalance).catch(() => setTokenBalance(null)); + }, [walletAddress]); + + const refreshProposals = () => { + fetchAllProposals().then(setProposals).catch(() => {}); + }; + useEffect(() => { Promise.all([fetchAllProposals(), fetchTokenDecimals()]) .then(([props, decs]) => { @@ -54,6 +70,12 @@ export default function App() { {tokenBalance !== null && (
{formatTokenAmount(tokenBalance, decimals)}
)} + ) : ( + ))} + + + {!walletAddress && ( +
+ ℹ️ Connect your wallet to vote on this proposal +
+ )} + + {walletAddress && hasVoted && ( +
+ ✓ You have already voted on this proposal +
+ )} + + {walletAddress && !isProposalActive && ( +
+ ℹ️ This proposal is not active and cannot receive new votes +
+ )} + + {walletAddress && isProposalActive && !votingOpen && ( +
+ ℹ️ Voting is not open yet or has ended for this proposal +
+ )} );