Skip to content

Commit

Permalink
election needle standalone page
Browse files Browse the repository at this point in the history
  • Loading branch information
mantikoros committed Jul 25, 2024
1 parent 1d0d394 commit d20a529
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions web/pages/election/needle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { GetStaticProps } from 'next'
import { MultiContract } from 'common/contract'
import { PoliticsCard } from 'web/components/us-elections/contracts/politics-card'
import { getElectionsPageProps } from 'web/lib/politics/home'
import { ElectionsPageProps } from 'web/public/data/elections-data'
import { useTracking } from 'web/hooks/use-tracking'

interface ElectionNeedleProps {
electionPartyContract: MultiContract
}

function ElectionNeedle({ electionPartyContract }: ElectionNeedleProps) {
useTracking('view election needle')

return (
<PoliticsCard
contract={electionPartyContract}
viewType="PARTY"
customTitle="Which party will win the Presidential Election?"
/>
)
}

export default function ElectionNeedlePage({
electionPartyContract,
}: ElectionNeedleProps) {
return <ElectionNeedle electionPartyContract={electionPartyContract} />
}

export const getStaticProps: GetStaticProps<ElectionNeedleProps> = async () => {
try {
const electionsPageProps: ElectionsPageProps = await getElectionsPageProps()

if (!electionsPageProps.electionPartyContract) {
return { notFound: true }
}

return {
props: {
electionPartyContract:
electionsPageProps.electionPartyContract as MultiContract,
},
revalidate: 60, // Revalidate every 60 seconds
}
} catch (error) {
console.error('Error fetching election party contract:', error)
return { notFound: true }
}
}

0 comments on commit d20a529

Please sign in to comment.