-
Notifications
You must be signed in to change notification settings - Fork 156
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
1d0d394
commit d20a529
Showing
1 changed file
with
49 additions
and
0 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,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 } | ||
} | ||
} |