From 63a954ba9345dc0fdc8e52de9855473bc91a95fa Mon Sep 17 00:00:00 2001 From: learner97 Date: Wed, 18 Sep 2024 10:01:38 -0600 Subject: [PATCH] made some changes for upload attachments, backend doesn't like it when run from source, but working if backend is on docker --- .../Viewing/Sections/Attachments/AttachmentRows.js | 8 +++++--- .../Viewing/Sections/Attachments/AttachmentsTable.js | 4 ++-- .../Viewing/Sections/Attachments/UploadAttachments.js | 2 +- frontend/package.json | 1 + frontend/public/commitHash.txt | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js b/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js index 9bfb74a0..adc378b1 100644 --- a/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js +++ b/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js @@ -29,17 +29,19 @@ export default function AttachmentRows(properties) { const dispatch = useDispatch(); const token = useSelector(state => state.user.token); const [attachmentInfo, setStateAttachments] = useState(); - const [attachments, setAttachments] = useState(properties.attachments.map(attachment => ({ + + const [attachments, setAttachments] = useState((properties.attachments || []).map(attachment => ({ ...attachment, processedTopLevel: attachment.topLevel // Initialize with topLevel }))); + //There are attachments from the parent but they haven't been added to the state yet. - if (attachmentInfo === undefined && properties.attachments.length > 0) + if (attachmentInfo === undefined && properties.attachments && properties.attachments.length > 0) setStateAttachments(properties.attachments); //There are no attachments to get. - if (properties.attachments.length === 0) return null; + if (properties.attachments && properties.attachments.length === 0) return null; // useEffect(() => { // async function processAttachments() { diff --git a/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js b/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js index f07af3c8..67c3077f 100644 --- a/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js +++ b/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js @@ -8,8 +8,8 @@ import styles from '../../../../styles/view.module.css'; */ export default function AttachmentsTable(properties) { const header = createHeader(properties.headers); - - if (properties.attachments.length === 0 && !properties.owner) return null; + console.log(properties); + if (properties.attachments && properties.attachments.length === 0 && !properties.owner) return null; return ( diff --git a/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js b/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js index 1345f554..934c89b8 100644 --- a/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js +++ b/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js @@ -193,7 +193,7 @@ export default function UploadAttachments(properties) { //Query all the attachments so the store can be updated. getQueryResponse(dispatch, getAttachments, { uri: properties.uri - }).then(allAttachments => { + }, token).then(allAttachments => { dispatch(setAttachments(allAttachments)); }); }); diff --git a/frontend/package.json b/frontend/package.json index eb421832..ffe488ef 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,6 +4,7 @@ "private": true, "scripts": { "dev": "NODE_OPTIONS=--openssl-legacy-provider node customDev.js", + "dev1": "node customDev.js", "build": "next build", "start": "next start -p 3333", "lint": "eslint '*/**/*.{js,jsx}'", diff --git a/frontend/public/commitHash.txt b/frontend/public/commitHash.txt index eeae27fb..921f76cc 100644 --- a/frontend/public/commitHash.txt +++ b/frontend/public/commitHash.txt @@ -1 +1 @@ -5af31bb4414db276ba10fd44d4d6847dc521bcb8 \ No newline at end of file +c8d687e1e2b0a24ec2e3164ca6250a256f9ea980 \ No newline at end of file