-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🫐⛸ ↣ Add new page queries to view components of specific proposals in […
- Loading branch information
1 parent
6dac15f
commit 49a5ce3
Showing
6 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
|
||
const CountBox = ({ title, value }) => { | ||
return ( | ||
<div className='flex flex-col items-center w-[150px]'> | ||
<h4 className='font-epilogue font-bold text-[30px] text-white p-3 bg-[#1c1c24] rounded-t-[10px] w-full text-center truncate'>{value}</h4> | ||
<p className="font-epilogue font-normal text-[16px] text-[#808191] bg-[#28282e] px-3 py-2 w-full rouned-b-[10px] text-center">{title}</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default CountBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,30 @@ | ||
import React from 'react' | ||
import React, { useState, useEffect } from 'react'; | ||
import { useStateContext } from '../context'; | ||
import { DisplayProposals } from '../components'; | ||
|
||
const Profile = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [proposals, setProposals] = useState([]); // Empty array, retrieved from the state context from onchain | ||
|
||
const { address, contract, getUserProposals } = useStateContext(); | ||
const fetchProposals = async () => { // This is to allow us to call this g.request in the useEffect (as the request is async in /context) | ||
setIsLoading(true); | ||
const data = await getUserProposals(); | ||
setProposals(data); | ||
setIsLoading(false); | ||
} | ||
|
||
useEffect(() => { | ||
if (contract) fetchProposals(); | ||
}, [address, contract]); // Re-called when these change | ||
|
||
return ( | ||
<div>Profile</div> | ||
<DisplayProposals // Component that selects different proposals based on props passed here | ||
title="All Proposals" | ||
isLoading={isLoading} | ||
proposals={proposals} | ||
/> | ||
) | ||
} | ||
|
||
export default Profile | ||
export default Profile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,74 @@ | ||
import React from 'react' | ||
import React, { useState, useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { ethers } from 'ethers'; | ||
import { useStateContext } from '../context'; | ||
import { CustomButton, CountBox } from '../components'; | ||
import { calculateBarPercentage, daysLeft } from '../utils'; | ||
import { thirdweb } from '../assets'; | ||
|
||
const ProposalDetails = () => { | ||
const { state } = useLocation(); | ||
const { getVoters, contract, address } = useStateContext(); | ||
console.log(state); | ||
|
||
const [isLoading, setIsLoading] = useState(false); | ||
const [amount, setAmount] = useState(''); | ||
const [voters, setVoters] = useState([]); // Array of voters on a specific proposal | ||
const remainingDays = daysLeft(state.deadline); | ||
|
||
return ( | ||
<div>ProposalDetails</div> | ||
<div> | ||
{isLoading && 'Loading...'} | ||
<div className='w-full flex md:flex-row flex-col mt-10 gap-[30px]'> | ||
<div className='flex-1 flex-col'> | ||
<img src={state.image} alt='campaign' className='w-full h-[410px] object-cover rounded-xl' /> | ||
<div className='relative w-full h-[5px] bg-[#3a3a43] mt-2'> | ||
<div className='absolute h-full bg-[#41cd8d]' style={{ width: `${calculateBarPercentage(state.target, state.amountCollected)}%`, maxWidth: '100%' }}> | ||
</div> | ||
</div> | ||
</div> | ||
<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='Voters' value={voters.length} /> | ||
</div> | ||
</div> | ||
<div className='mt-[60px] flex lg:flex-row flex-col gap-5'> | ||
<div className='flex-[2] flex flex-col gap-[40px]'> | ||
<div> | ||
<h4 className='font-epilogue font-semibold text-[18px] text-white uppercase'>CREATOR:</h4> | ||
<div className='mt-[20px] flex flex-row items-center flex-wrap gap-[14px]'> | ||
<div className='w-[52px] h-[52px] flex items-center justify-center rounded-full bg-[#2c2f32] cursor-pointer'> | ||
<img src={thirdweb} alt='user profilepic' className='w-[60%] h-[60%] object-contain' /> | ||
</div> | ||
<div> | ||
<h4 className='font-epilogue font-semibold text-[14px] text-white break-all'>{state.owner}</h4> | ||
<p className='mt-[4px] font-epilogue font-normal text-[12px] text-[#808191]'>10 Proposals</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div> | ||
<h4 className='font-epilogue font-semibold text-[18px] text-white uppercase'>STORY:</h4> | ||
<div className='mt-[20px]'> | ||
<p className='font-epilogue font-normal text-[16px] text-[#808191] leading-[26px] text-justify'>{state.description}</p> | ||
</div> | ||
</div> | ||
<div> | ||
<h4 className='font-epilogue font-semibold text-[18px] text-white uppercase'>VOTERS:</h4> | ||
<div className='mt-[20px] flex flex-col gap-4'> | ||
{voters.length > 0 ? voters.map((item, index) => { | ||
<div> | ||
VOTER | ||
</div> | ||
}) : ( | ||
<p className='font-epilogue font-normal text-[16px] text-[#808191] leading-[26px] text-justify'>Nobody has voted on this proposal yet</p> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ProposalDetails | ||
export default ProposalDetails; |