Skip to content

Commit

Permalink
feat: Public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Sep 16, 2024
1 parent 40d4ba6 commit 43e9455
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions editor.planx.uk/src/@planx/components/Page/Public.tsx
Original file line number Diff line number Diff line change
@@ -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<Page>;

function PageComponent(props: Props) {
const { formikConfig } = useSchema({
schema: props.schema,
previousValues: getPreviouslySubmittedData(props),
});

const formik = useFormik({
...formikConfig,
onSubmit: (data) => console.log({ data }),
});

return (
<Card handleSubmit={props.handleSubmit} isValid>
<CardHeader
info={props.info}
policyRef={props.policyRef}
howMeasured={props.howMeasured}
<Card handleSubmit={formik.handleSubmit} isValid>
<CardHeader {...props} />
<SchemaFields
formik={formik}
schema={props.schema}
sx={(theme) => ({
display: "flex",
flexDirection: "column",
gap: theme.spacing(2),
})}
/>
</Card>
);
Expand Down

0 comments on commit 43e9455

Please sign in to comment.