diff --git a/editor.planx.uk/src/@planx/components/Confirmation/Confirmation.stories.tsx b/editor.planx.uk/src/@planx/components/Confirmation/Confirmation.stories.tsx index b8dd57dede..4cd47a1676 100644 --- a/editor.planx.uk/src/@planx/components/Confirmation/Confirmation.stories.tsx +++ b/editor.planx.uk/src/@planx/components/Confirmation/Confirmation.stories.tsx @@ -3,12 +3,12 @@ import React from "react"; import Wrapper from "../fixtures/Wrapper"; import Editor from "./Editor"; -import Confirmation from "./Public"; +import Confirmation, { Presentational } from "./Public"; const meta = { title: "PlanX Components/Confirmation", - component: Confirmation, -} satisfies Meta; + component: Presentational, +} satisfies Meta; export default meta; @@ -20,6 +20,19 @@ export const Basic = { description: `A payment receipt has been emailed to you. You will also receive an email to confirm when your application has been received.`, color: { background: "rgba(1, 99, 96, 0.1)", text: "#000" }, + sessionId: "123-t3st-456", + applicableDetails: { + "Planning Application Reference": "LBL–LDCP-2138261", + "Property Address": "45, Greenfield Road, London SE22 7FF", + "Application type": + "Application for a Certificate of Lawfulness – Proposed", + Submitted: new Date().toLocaleDateString("en-gb", { + day: "numeric", + month: "long", + year: "numeric", + }), + "GOV.UK Payment reference": "qe817o3kds9474rfkfldfHSK874JB", + }, nextSteps: [ { title: "Validation", description: "Something will be validated" }, { title: "Site visit", description: "Someone will visit" }, @@ -36,6 +49,7 @@ export const Basic = {

What did you think of this service? Please give us your feedback using the link in the footer below. `, + data: [], }, } satisfies Story; diff --git a/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx b/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx index 0457b7ed98..bdb2db967f 100644 --- a/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx @@ -20,11 +20,38 @@ export type Props = PublicProps; export default function ConfirmationComponent(props: Props) { const [data, setData] = useState([]); - const [sessionId, saveToEmail, $public] = useStore((state) => [ - state.sessionId, - state.saveToEmail, - state.$public, - ]); + const [sessionId, saveToEmail, $public, passport, govUkPayment, flowName] = + useStore((state) => [ + state.sessionId, + state.saveToEmail, + state.$public, + state.computePassport(), + state.govUkPayment, + state.flowName, + ]); + + const details = { + "Application reference": sessionId, + "Property address": passport.data?._address?.title, + "Application type": [ + flowName.replace("Apply", "Application"), + getWorkStatus(passport), + ] + .filter(Boolean) + .join(" - "), + "GOV.UK payment reference": govUkPayment?.payment_id, + "Paid at": + govUkPayment?.created_date && + new Date(govUkPayment.created_date).toLocaleDateString("en-gb", { + day: "numeric", + month: "long", + year: "numeric", + }), + }; + const applicableDetails = objectWithoutNullishValues(details) as Record< + string, + string + >; useEffect(() => { const makeCsvData = async () => { @@ -41,6 +68,23 @@ export default function ConfirmationComponent(props: Props) { } }); + return ( + + ); +} + +interface PresentationalProps extends Props { + sessionId: string; + applicableDetails: Record; + data: QuestionAndResponses[]; +} + +export function Presentational(props: PresentationalProps) { return ( -
- + + {Object.entries(props.applicableDetails).map(([k, v], i) => ( + + {k} + {v} + + ))} + + {props.nextSteps && Boolean(props.nextSteps?.length) && ( @@ -87,49 +141,6 @@ export default function ConfirmationComponent(props: Props) { ); } -function Details() { - const [sessionId, passport, govUkPayment, flowName] = useStore((state) => [ - state.sessionId, - state.computePassport(), - state.govUkPayment, - state.flowName, - ]); - - const details = { - "Application reference": sessionId, - "Property address": passport.data?._address?.title, - "Application type": [ - flowName.replace("Apply", "Application"), - getWorkStatus(passport), - ] - .filter(Boolean) - .join(" - "), - "GOV.UK payment reference": govUkPayment?.payment_id, - "Paid at": - govUkPayment?.created_date && - new Date(govUkPayment.created_date).toLocaleDateString("en-gb", { - day: "numeric", - month: "long", - year: "numeric", - }), - }; - const applicableDetails = objectWithoutNullishValues(details) as Record< - string, - string - >; - - return ( - - {Object.entries(applicableDetails).map(([k, v], i) => ( - - {k} - {v} - - ))} - - ); -} - // TODO - Retire in favor of ODP Schema application type descriptions or fallback to flowName function getWorkStatus(passport: Store.passport): string | undefined { switch (passport?.data?.["application.type"]?.toString()) {