adrianhajdin / project_crowdfunding

With a stunning design, connected to the blockchain, metamask pairing, interaction with smart contracts, sending Ethereum through the blockchain network, and writing solidity code.
https://jsmastery.pro
704 stars 380 forks source link

When you click donate with no amount input, it will just load forever #8

Closed gvnut closed 1 year ago

gvnut commented 1 year ago

There is an issue where on the CampaignDetails.jsx page if you click the donation button without inputting any ether amount, it will throw the loading screen. But it will never time out or complete as there was no amount input.

gvnut commented 1 year ago

I edited the CampaignDetails.jsx file to add a conditional statement to check if the amount variable is an empty string before allowing the button to be clicked. I added an alert using the window.alert() function.

Here is an example of how you can modify the handleDonate function:

const handleDonate = async () => { if (amount === '') { window.alert('Please enter a donation amount'); return; } setIsLoading(true);

await donate(state.pId, amount);

navigate('/') setIsLoading(false); }