-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e385b98
commit ab896b7
Showing
2 changed files
with
41 additions
and
7 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
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,32 @@ | ||
import React from 'react' | ||
import React, { useState, useEffect } from "react"; | ||
|
||
function Profile() { | ||
return ( | ||
<div>Profile</div> | ||
) | ||
} | ||
import DisplayCampaigns from "../components/DisplayCampaigns" | ||
import { useStateContext } from "../context"; | ||
|
||
export default Profile; | ||
const Profile = () => { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [campaigns, setCampaigns] = useState([]); | ||
|
||
const { address, contract, getUserCampaigns } = useStateContext(); | ||
|
||
const fetchCampaigns = async() => { | ||
setIsLoading(true); | ||
const data = await getUserCampaigns(); | ||
setCampaigns(data); | ||
setIsLoading(false); | ||
} | ||
|
||
useEffect(() => { | ||
if(contract) fetchCampaigns(); | ||
}, [address, contract]); | ||
|
||
return( | ||
<DisplayCampaigns | ||
title="All Campaigns" | ||
isLoading= {isLoading} | ||
campaigns = {campaigns} | ||
/> | ||
); | ||
}; | ||
|
||
export default Profile; |