Skip to content

Commit

Permalink
remove frontend Send bops & uniform in favor of planx-core public cli…
Browse files Browse the repository at this point in the history
…ent csv generation
  • Loading branch information
jessicamcinchak committed Feb 6, 2024
1 parent 3a89fcd commit 6291247
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 2,169 deletions.
46 changes: 20 additions & 26 deletions editor.planx.uk/src/@planx/components/Confirmation/Public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import Check from "@mui/icons-material/Check";
import Box from "@mui/material/Box";
import { styled } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
import { QuestionAndResponses } from "@opensystemslab/planx-core/types";
import Card from "@planx/components/shared/Preview/Card";
import { PublicProps } from "@planx/components/ui";
import { useStore } from "pages/FlowEditor/lib/store";
import React from "react";
import React, { useEffect, useState } from "react";
import Banner from "ui/public/Banner";
import FileDownload from "ui/public/FileDownload";
import NumberedList from "ui/public/NumberedList";
import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml";

import { makeCsvData } from "../Send/uniform";
import type { Confirmation } from "./model";

const Table = styled("table")(({ theme }) => ({
Expand All @@ -31,23 +31,24 @@ const Table = styled("table")(({ theme }) => ({
export type Props = PublicProps<Confirmation>;

export default function ConfirmationComponent(props: Props) {
const [breadcrumbs, flow, passport, sessionId, flowName] = useStore(
(state) => [
state.breadcrumbs,
state.flow,
state.computePassport(),
state.sessionId,
state.flowName,
],
);
const [data, setData] = useState<QuestionAndResponses[]>([]);

const [sessionId, $public] = useStore((state) => [
state.sessionId,
state.$public,
]);

useEffect(() => {
async function makeCsvData() {
const csvData = await $public.export.csvData(sessionId);
if (csvData) {
setData(csvData);
}
}

// make a CSV data structure based on the payloads we Send to BOPs/Uniform
const data = makeCsvData({
breadcrumbs,
flow,
flowName,
passport,
sessionId,
if (data.length < 1) {
makeCsvData();
}
});

return (
Expand Down Expand Up @@ -80,14 +81,7 @@ export default function ConfirmationComponent(props: Props) {
</Table>
)}

{
<FileDownload
data={data}
filename={
props.details?.["Planning Application Reference"] || "application"
}
/>
}
{<FileDownload data={data} filename={sessionId || "application"} />}

{props.nextSteps && Boolean(props.nextSteps?.length) && (
<Box pt={3}>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6291247

Please sign in to comment.