-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: governance UI hash preview (#976)
* feat: add governance preview ui * fix: remove double fetching from governance & reduce interval * perf: reduce refetch interval * Update pages/governance/proposal/[proposalId].governance.tsx Co-authored-by: Andrew Schmidt <[email protected]> Co-authored-by: Andrew Schmidt <[email protected]>
- Loading branch information
1 parent
d820aef
commit a7725a0
Showing
4 changed files
with
62 additions
and
29 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,41 @@ | ||
import { useRouter } from 'next/router'; | ||
import { useEffect, useState } from 'react'; | ||
import { GovVoteModal } from 'src/components/transactions/GovVote/GovVoteModal'; | ||
import { GovernanceDataProvider } from 'src/hooks/governance-data-provider/GovernanceDataProvider'; | ||
import { MainLayout } from 'src/layouts/MainLayout'; | ||
import { getProposalMetadata } from 'src/modules/governance/utils/getProposalMetadata'; | ||
import { IpfsType } from 'src/static-build/ipfs'; | ||
import { governanceConfig } from 'src/ui-config/governanceConfig'; | ||
import ProposalPage from './proposal/[proposalId].governance'; | ||
|
||
export default function IpfsPreview() { | ||
const router = useRouter(); | ||
const ipfsHash = router.query.ipfsHash as string; | ||
const [ipfs, setIpfs] = useState<IpfsType>(); | ||
|
||
async function fetchIpfs() { | ||
const newIpfs = { | ||
id: -1, | ||
originalHash: ipfsHash, | ||
...(await getProposalMetadata(ipfsHash, governanceConfig?.ipfsGateway)), | ||
}; | ||
setIpfs(newIpfs); | ||
} | ||
// // fetch ipfs on initial load | ||
useEffect(() => { | ||
if (!ipfsHash) return; | ||
fetchIpfs(); | ||
}, [ipfsHash]); | ||
return <ProposalPage ipfs={ipfs} proposal={undefined} />; | ||
} | ||
|
||
IpfsPreview.getLayout = function getLayout(page: React.ReactElement) { | ||
return ( | ||
<MainLayout> | ||
<GovernanceDataProvider> | ||
{page} | ||
<GovVoteModal /> | ||
</GovernanceDataProvider> | ||
</MainLayout> | ||
); | ||
}; |
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
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs
a7725a0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit was deployed on ipfs