import { GetServerSideProps, NextPage } from "next"; import NextError from "next/error"; import ReactMarkdown from "react-markdown"; import { BoxedLink } from "../../common/BoxedLink"; import { Card } from "../../common/Card"; import { CopyParagraph } from "../../common/CopyParagraph"; import { Layout } from "../../common/Layout"; import { Query } from "../../common/Query"; import { QuestionWithHistoryFragment } from "../../fragments.generated"; import { ssrUrql } from "../../urql"; import { getBasePath } from "../../utils"; import { CaptureQuestion } from "../components/CaptureQuestion"; import { IndicatorsTable } from "../components/IndicatorsTable"; import { QuestionChartOrVisualization } from "../components/QuestionChartOrVisualization"; import { QuestionInfoRow } from "../components/QuestionInfoRow"; import { QuestionTitle } from "../components/QuestionTitle"; import { QuestionPageDocument } from "../queries.generated"; interface Props { id: string; } export const getServerSideProps: GetServerSideProps = async ( context ) => { const [ssrCache, client] = ssrUrql(); const id = context.query.id as string; const question = (await client.query(QuestionPageDocument, { id }).toPromise()).data ?.result || null; if (!question) { context.res.statusCode = 404; } return { props: { urqlState: ssrCache.extractData(), id, }, }; }; const Section: React.FC<{ title: string }> = ({ title, children }) => (

{title}

{children}
); const EmbedSection: React.FC<{ question: QuestionWithHistoryFragment }> = ({ question, }) => { const url = getBasePath() + `/questions/embed/${question.id}`; return (
Preview
`} buttonText="Copy HTML" />
); }; const LargeQuestionCard: React.FC<{ question: QuestionWithHistoryFragment; }> = ({ question }) => { return (
{question.description.replaceAll("---", "")}
); }; const QuestionPage: NextPage = ({ id }) => { return (
{({ data }) => data.result ? ( ) : ( ) }
); }; export default QuestionPage;