From fe0d666c2b2ae3bc60d06879ec605caed11c64fd Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 15 Dec 2021 21:24:11 -0600 Subject: [PATCH] test ssg --- web/pages/[username]/[contractId].tsx | 61 ++++++++++++--------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/web/pages/[username]/[contractId].tsx b/web/pages/[username]/[contractId].tsx index 1a044ffd..28bccd5e 100644 --- a/web/pages/[username]/[contractId].tsx +++ b/web/pages/[username]/[contractId].tsx @@ -10,44 +10,43 @@ import { BetPanel } from '../../components/bet-panel' import { Col } from '../../components/layout/col' import { useUser } from '../../hooks/use-user' import { ResolutionPanel } from '../../components/resolution-panel' -// import { Contract, getContract } from '../../lib/firebase/contracts' -// export async function getStaticProps({ params }: { params: any }) { -// console.log('params', params) -// const contract = await getContract(params.contractId) +import { Contract, getContract } from '../../lib/firebase/contracts' +export async function getStaticProps({ params }: { params: any }) { + console.log('params', params) + const contract = await getContract(params.contractId) -// return { -// props: { -// contract: contract || null -// } -// } -// } + return { + props: { + contract: contract || null, + }, + } +} -// export async function getStaticPaths() { -// return { -// paths: [], -// fallback: true, -// } -// } +export async function getStaticPaths() { + return { + paths: [], + fallback: true, + } +} -export default function ContractPage() {//{ contract }: { contract: Contract }) { +export default function ContractPage({ contract }: { contract: Contract }) { const user = useUser() const router = useRouter() const { contractId } = router.query as { contractId: string } - const contract = useContract(contractId) - if (contract === 'loading') { - return
- } - if (!contract) { - return
Contract not found...
- } - - // if (contract === null) { + // const contract = useContract(contractId) + // if (contract === 'loading') { + // return
+ // } + // if (!contract) { // return
Contract not found...
// } - // if (!contract) - // return
+ + if (contract === null) { + return
Contract not found...
+ } + if (!contract) return
const { creatorId, isResolved } = contract const isCreator = user?.id === creatorId @@ -63,10 +62,7 @@ export default function ContractPage() {//{ contract }: { contract: Contract }) content={contract.question} key="title" /> - + -