New card gen attempt

This commit is contained in:
Ian Philips 2022-07-26 17:11:50 -07:00
parent a28b3cad77
commit cf653bd567

View File

@ -35,6 +35,7 @@ import {
import { ContractProbGraph } from 'web/components/contract/contract-prob-graph' import { ContractProbGraph } from 'web/components/contract/contract-prob-graph'
import { SEO } from 'web/components/SEO' import { SEO } from 'web/components/SEO'
import { getOpenGraphProps } from 'web/components/contract/contract-card-preview' import { getOpenGraphProps } from 'web/components/contract/contract-card-preview'
import Custom404 from 'web/pages/404'
export const getStaticProps = fromPropz(getStaticPropz) export const getStaticProps = fromPropz(getStaticPropz)
export async function getStaticPropz(props: { export async function getStaticPropz(props: {
@ -78,20 +79,29 @@ export default function ChallengePage(props: {
slug: '', slug: '',
} }
const contract = useContractWithPreload(props.contract) const contract = useContractWithPreload(props.contract) ?? props.contract
const challenge = useChallenge(props.challengeSlug, contract?.id) const challenge = useChallenge(props.challengeSlug, contract?.id)
const { user, bets } = props const { user, bets } = props
const currentUser = useUser() const currentUser = useUser()
if (!contract || !challenge) { if (!contract) return <Custom404 />
const ogCardProps = getOpenGraphProps(contract)
if (!challenge) {
return ( return (
<Page>
<SEO
title={ogCardProps.question}
description={ogCardProps.description}
// url={getChallengeUrl(challenge)}
ogCardProps={ogCardProps}
/>
<Col className={'min-h-screen items-center justify-center'}> <Col className={'min-h-screen items-center justify-center'}>
<LoadingIndicator /> <LoadingIndicator />
</Col> </Col>
</Page>
) )
} }
const ogCardProps = getOpenGraphProps(contract)
ogCardProps.question = ogCardProps.question =
challenge.creatorName.split(' ')[0] + challenge.creatorName.split(' ')[0] +
"'s CHALLENGING you: " + "'s CHALLENGING you: " +
@ -101,14 +111,12 @@ export default function ChallengePage(props: {
return ( return (
<Page> <Page>
{ogCardProps && (
<SEO <SEO
title={ogCardProps.question} title={ogCardProps.question}
description={ogCardProps.description} description={ogCardProps.description}
url={getChallengeUrl(challenge)} url={getChallengeUrl(challenge).replace('https://', '')}
ogCardProps={ogCardProps} ogCardProps={ogCardProps}
/> />
)}
{challenge.acceptances.length >= challenge.maxUses ? ( {challenge.acceptances.length >= challenge.maxUses ? (
<ClosedChallengeContent <ClosedChallengeContent
contract={contract} contract={contract}