From 3f04d20e3d3f092516f9b9f2ed0d570fa880e2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Thu, 8 Feb 2024 16:33:28 +0000 Subject: [PATCH] test: Try repeating code to pass tests (temp) --- .../src/@planx/components/FileUpload/Public.tsx | 10 +++++++++- .../src/@planx/components/FileUploadAndLabel/model.ts | 10 +++++++++- .../src/pages/FlowEditor/lib/store/preview.ts | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/FileUpload/Public.tsx b/editor.planx.uk/src/@planx/components/FileUpload/Public.tsx index aa2008a1f0..9f0c219d3f 100644 --- a/editor.planx.uk/src/@planx/components/FileUpload/Public.tsx +++ b/editor.planx.uk/src/@planx/components/FileUpload/Public.tsx @@ -69,9 +69,17 @@ const FileUpload: React.FC = (props) => { ); const updatedRequestedFiles = () => { + // const { required, recommended, optional } = useStore + // .getState() + // .requestedFiles(); + const { required, recommended, optional } = useStore .getState() - .requestedFiles(); + .computePassport().data?.[PASSPORT_REQUESTED_FILES_KEY] || { + required: [], + recommended: [], + optional: [], + }; return { [PASSPORT_REQUESTED_FILES_KEY]: { diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/model.ts b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/model.ts index 4b4aea3c5c..af695c75d2 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/model.ts +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/model.ts @@ -234,9 +234,17 @@ const hasSlots = (userFile: UserFile): userFile is UserFileWithSlots => Boolean(userFile?.slots); const getUpdatedRequestedFiles = (fileList: FileList) => { + // const { required, recommended, optional } = useStore + // .getState() + // .requestedFiles(); + const { required, recommended, optional } = useStore .getState() - .requestedFiles(); + .computePassport().data?.[PASSPORT_REQUESTED_FILES_KEY] || { + required: [], + recommended: [], + optional: [], + }; return { [PASSPORT_REQUESTED_FILES_KEY]: { diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts index 5340c6fb06..cb3e97e2a1 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts @@ -638,6 +638,7 @@ export const previewStore: StateCreator< } }, + // TODO: Fix this! requestedFiles: () => { const { computePassport } = get(); const currentRequestedFiles =