-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1202 from oasisprotocol/csillag/proposal-detail-p…
…ages Add basic proposal details page
- Loading branch information
Showing
12 changed files
with
198 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 @@ | ||
Add Network proposal details page |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { FC } from 'react' | ||
import { Link as RouterLink } from 'react-router-dom' | ||
import Link from '@mui/material/Link' | ||
import { RouteUtils } from '../../utils/route-utils' | ||
import { Network } from '../../../types/network' | ||
|
||
export const ProposalLink: FC<{ | ||
network: Network | ||
proposalId: string | number | ||
label?: string | ||
}> = ({ network, proposalId, label = proposalId }) => { | ||
const to = RouteUtils.getProposalRoute(network, proposalId) | ||
return ( | ||
<Link component={RouterLink} to={to}> | ||
{label} | ||
</Link> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useRequiredScopeParam } from '../../hooks/useScopeParam' | ||
import { Layer, Proposal, useGetConsensusProposalsProposalId } from '../../../oasis-nexus/api' | ||
import { AppErrors } from '../../../types/errors' | ||
import { useParams } from 'react-router-dom' | ||
import { PageLayout } from '../../components/PageLayout' | ||
import { SubPageCard } from '../../components/SubPageCard' | ||
import { StyledDescriptionList } from 'app/components/StyledDescriptionList' | ||
import { RoundedBalance } from '../../components/RoundedBalance' | ||
import { DashboardLink } from '../ParatimeDashboardPage/DashboardLink' | ||
import { useScreenSize } from '../../hooks/useScreensize' | ||
import { ProposalStatusIcon } from '../../components/Proposals/ProposalStatusIcon' | ||
import { TextSkeleton } from '../../components/Skeleton' | ||
import { AccountLink } from '../../components/Account/AccountLink' | ||
|
||
export const ProposalDetailsPage: FC = () => { | ||
const { t } = useTranslation() | ||
const scope = useRequiredScopeParam() | ||
if (scope.layer !== Layer.consensus) { | ||
throw AppErrors.UnsupportedLayer | ||
} | ||
const proposalId = parseInt(useParams().proposalId!, 10) | ||
|
||
const { isLoading, data } = useGetConsensusProposalsProposalId(scope.network, proposalId) | ||
if (!data?.data && !isLoading) { | ||
throw AppErrors.NotFoundProposalId | ||
} | ||
const proposal = data?.data! | ||
return ( | ||
<PageLayout> | ||
<SubPageCard featured title={t('common.proposal')}> | ||
<ProposalDetailView isLoading={isLoading} proposal={proposal} /> | ||
</SubPageCard> | ||
</PageLayout> | ||
) | ||
} | ||
|
||
export const ProposalDetailView: FC<{ | ||
proposal: Proposal | ||
isLoading?: boolean | ||
showLayer?: boolean | ||
standalone?: boolean | ||
}> = ({ proposal, isLoading, showLayer = false, standalone = false }) => { | ||
const { t } = useTranslation() | ||
const { isMobile } = useScreenSize() | ||
if (isLoading) return <TextSkeleton numberOfRows={7} /> | ||
|
||
return ( | ||
<StyledDescriptionList titleWidth={isMobile ? '100px' : '200px'} standalone={standalone}> | ||
{showLayer && ( | ||
<> | ||
<dt>{t('common.network')}</dt> | ||
<dd> | ||
<DashboardLink scope={proposal} /> | ||
</dd> | ||
</> | ||
)} | ||
|
||
<dt>{t('networkProposal.id')}</dt> | ||
<dd>{proposal.id}</dd> | ||
|
||
<dt>{t('common.title')}</dt> | ||
<dd>{proposal.handler}</dd> | ||
|
||
{/*Not enough data*/} | ||
{/*<dt>{t('common.type')}</dt>*/} | ||
{/*<dd>???</dd>*/} | ||
|
||
<dt>{t('common.submitter')}</dt> | ||
<dd> | ||
<AccountLink scope={proposal} address={proposal.submitter} /> | ||
</dd> | ||
|
||
{/*Not enough data*/} | ||
{/*<dt>{t('common.totalVotes')}</dt>*/} | ||
{/*<dd>{proposal.invalid_votes}</dd>*/} | ||
|
||
<dt>{t('common.status')}</dt> | ||
<dd> | ||
<ProposalStatusIcon status={proposal.state} /> | ||
</dd> | ||
|
||
<dt>{t('networkProposal.deposit')}</dt> | ||
<dd> | ||
<RoundedBalance value={proposal.deposit} /> | ||
</dd> | ||
|
||
<dt>{t('networkProposal.create')}</dt> | ||
<dd>{proposal.created_at}</dd> | ||
|
||
<dt>{t('networkProposal.close')}</dt> | ||
<dd>{proposal.closes_at}</dd> | ||
</StyledDescriptionList> | ||
) | ||
} |
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
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