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

amountCollected; #20

Open Davison82 opened 1 year ago

Davison82 commented 1 year ago

Hi All

I'm having another issue with the uint256 amountCollected; sturct it's not showing up. The amount donated isn't displaying in the Countbox, code is in Campaign Details:

<CountBox title={Raised of ${state.target}} value={state.amountCollected} />

Thanks

A-Pradeep commented 1 year ago

@Davison82 Are you still facing the issue ?

Davison82 commented 1 year ago

Yes I'm still facing the issue even with the back ticks. The problem is the value={state.amountCollected} function won't show and I have created and donated to a campaign?  

                    <CountBox title={Raised of ${state.target}} value={state.amountCollected} />                 
     
On Friday, 7 April 2023 at 17:04:25 BST, Pradeep A @.***> wrote:

@Davison82 Are you still facing the issue ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

A-Pradeep commented 1 year ago

@Davison82

        <div className="flex md:w-[150px] w-full flex-wrap justify-between gap-[30px]">
          <CountBox title="Days left" value={remainingDays} />
          <CountBox
            title={`Raised of ${state.target}`}
            value={state.amountCollected}
          />
          <CountBox title="Total Backers" value={donators.length} />
        </div>
      </div>

This is working fine for me. Suggest you to console log the state and check what values are passed to the component. const { state } = useLocation();

state should consist of key value like below :

{
    "owner": "0x....",
    "title": "The Power of One....",
    "description": "Individuals can .....",
    "target": "1.0",
    "deadline": 1682812800000,
    "amountCollected": "0.06",
    "image": "https://cdn.......",
    "pID": 0
}

*pID is my local change. So you should see either pId or the name you gave for id.

Davison82 commented 1 year ago

Thank you for this. I ran console.log on the state, and "amountCollected" isn't being passed as "0.0", pID is 9. { 

Could this be because it's 0 in the createCampaign function in the Solidity file? campaign.owner = _owner;        campaign.title = _title;        campaign.description = _description;        campaign.target = _target;        campaign.deadline = _deadline;        campaign.amountCollected = 0;        campaign.image = _image; On Saturday, 8 April 2023 at 11:50:47 BST, Pradeep A @.***> wrote:

@Davison82

  </div>

This is working fine for me. Suggest you to console log the state and check what values are passed to the component. const { state } = useLocation();

state should consist of key value like below : { "owner": "0x....", "title": "The Power of One....", "description": "Individuals can .....", "target": "1.0", "deadline": 1682812800000, "amountCollected": "0.06", "image": "https://cdn.......", "pID": 0 }

*pID is my local change. So you should see either pId or the name you gave for id.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

kihiuFrank commented 1 year ago

@Davison82 @A-Pradeep @adrianhajdin @krishnaacharyaa Hello.

Does anyone has a solution to this?

A-Pradeep commented 1 year ago

@Davison82 @A-Pradeep @adrianhajdin @krishnaacharyaa Hello.

Does anyone has a solution to this?

what's the issue ?

Davison82 commented 1 year ago

campaign.amountCollected is showing 0 value. I have console.log and got this { 

@Davison82 @A-Pradeep @adrianhajdin @krishnaacharyaa Hello.

Does anyone has a solution to this?

what's the issue ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

kihiuFrank commented 1 year ago

@A-Pradeep The amountCollected isn't displaying in the Countbox.

Here

<CountBox
            title={`Raised out of ${state.target}`}
            value={state.amountCollected}
          />

This is what I get when I log state.

amountCollected: "0.0"
deadline: 1689724800000
description: "Embark on an epic dungeon-crawling adventure! Immerse yourself in our captivating, gamified stories featuring stunning miniatures and artwork, and 110+ unique quests, each offering truly diverse challenges that will keep you on the edge of your seat. The highly refined level-up system allows you to customize your hero and forge a path to glory. With an innovative skill system, you'll stay engaged even on other players' turns, ensuring non-stop strategies and combos."
image: "https://ksr-ugc.imgix.net/assets/041/090/860/94429932cd9629efbcce801f2e109ead_original.jpg?ixlib=rb-4.0.2&w=680&fit=max&v=1685125335&gif-q=50&q=92&s=ba780d5dee1b65972cd65903c8eed314"
owner: "0x13A19933267ec307c96f3dE8Ff8A2392C39263EB"
pId: 0
target: "1.0"
title: "Tanares Adventures Essential Gameplay"
kihiuFrank commented 1 year ago

I restarted the server and now everything works well. Weird.