Skip to content

Commit

Permalink
Show executed time on proposal page
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Apr 27, 2024
1 parent e5187da commit 303dbd0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/governance/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function ProposalContent({ propData }: { propData: MergedProposalData }) {
<div className="space-y-3">
<BackLink href="/governance">Browse proposals</BackLink>
<h1 className="font-serif text-2xl md:text-2xl">{title}</h1>
<ProposalBadgeRow propData={propData} showProposer />
<ProposalBadgeRow propData={propData} showProposer showExecutedTime />
<ProposalLinkRow propData={propData} />
{isLoading && !content && <FullWidthSpinner>Loading proposal content</FullWidthSpinner>}
{!isLoading && !content && (
Expand Down
14 changes: 13 additions & 1 deletion src/features/governance/components/ProposalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,24 @@ export function ProposalCard({
export function ProposalBadgeRow({
propData,
showProposer,
showExecutedTime,
}: {
propData: MergedProposalData;
showProposer?: boolean;
showExecutedTime?: boolean;
}) {
const { stage, proposal, metadata, id } = propData;

const { timestamp, proposer, isApproved } = proposal || {};
const { timestamp: cgpTimestamp, cgp } = metadata || {};
const { timestamp: cgpTimestamp, cgp, timestampExecuted } = metadata || {};

const proposedTimestamp = timestamp || cgpTimestamp;
const proposedTimeValue = proposedTimestamp
? new Date(proposedTimestamp).toLocaleDateString()
: undefined;
const executedTimeValue = timestampExecuted
? new Date(timestampExecuted).toLocaleDateString()
: undefined;

return (
<div className="flex items-center space-x-2">
Expand All @@ -110,6 +115,13 @@ export function ProposalBadgeRow({
<ShortAddress address={proposer} className="hidden text-sm text-taupe-600 sm:block" />
</>
)}
{/* Show one of proposer or executedTimeValue but not both, too crowded */}
{showExecutedTime && executedTimeValue && !proposer && (
<>
<div className="hidden text-xs opacity-50 sm:block"></div>
<div className="hidden text-sm text-taupe-600 sm:block">{`Executed ${executedTimeValue}`}</div>
</>
)}
</div>
);
}
Expand Down

0 comments on commit 303dbd0

Please sign in to comment.