From b74a15a9e742f1e73ac4cb332b882792c79abd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Wed, 24 Jan 2024 12:07:48 +0000 Subject: [PATCH] fix: Post correct body to `download-application` endpoint --- editor.planx.uk/src/ui/public/FileDownload.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/editor.planx.uk/src/ui/public/FileDownload.tsx b/editor.planx.uk/src/ui/public/FileDownload.tsx index a46b9e4d8d..d61d99d8ff 100644 --- a/editor.planx.uk/src/ui/public/FileDownload.tsx +++ b/editor.planx.uk/src/ui/public/FileDownload.tsx @@ -17,7 +17,11 @@ const Root = styled(Box)(({ theme }) => ({ })); // Render a button which lets the applicant download their application data as a CSV -export default function FileDownload(props: Props): FCReturn { +export default function FileDownload({ + data, + filename, + text, +}: Props): FCReturn { const downloadCsv = (filename: string, content: string) => { const csv = "data:text/csv;charset=utf-8," + content; const data = encodeURI(csv); @@ -39,15 +43,15 @@ export default function FileDownload(props: Props): FCReturn { Accept: "application/json", "Content-Type": "application/json", }, - body: JSON.stringify(props.data), + body: JSON.stringify({ data }), }) .then((res) => res.text()) - .then((data) => downloadCsv(props.filename, data)) + .then((data) => downloadCsv(filename, data)) .catch((error) => console.log(error)); }} > - {props.text || "Download your application (.csv)"} + {text || "Download your application (.csv)"}