From e3152230b791b0712714e5fc2e39610e5ff24d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Sat, 14 Sep 2024 19:54:54 +0100 Subject: [PATCH] feat: Public interface --- .../src/@planx/components/Page/Public.tsx | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Page/Public.tsx b/editor.planx.uk/src/@planx/components/Page/Public.tsx index d960c5dfc7..81c18cc423 100644 --- a/editor.planx.uk/src/@planx/components/Page/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Page/Public.tsx @@ -1,19 +1,38 @@ import { PublicProps } from "@planx/components/ui"; +import { useFormik } from "formik"; import React from "react"; import Card from "../shared/Preview/Card"; import CardHeader from "../shared/Preview/CardHeader"; +import { useSchema } from "../shared/Schema/hook"; +import { SchemaFields } from "../shared/Schema/SchemaFields"; +import { getPreviouslySubmittedData } from "../shared/utils"; import { Page } from "./model"; type Props = PublicProps; function PageComponent(props: Props) { + const { formikConfig } = useSchema({ + schema: props.schema, + previousValues: getPreviouslySubmittedData(props), + }); + + const formik = useFormik({ + ...formikConfig, + onSubmit: (data) => console.log({ data }), + }); + return ( - - + + ({ + display: "flex", + flexDirection: "column", + gap: theme.spacing(2), + })} /> );