From b94851c0e40d0810d30d4c677a5f0d060e9cbe9a Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:27:48 +0530 Subject: [PATCH] open pdf file preview in new tab (#6226) --- src/Components/Patient/FileUpload.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 3fb0fde6229..fe0881e6994 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -481,15 +481,20 @@ export const FileUpload = (props: FileUploadProps) => { }; const responseData = await dispatch(retrieveUpload(data, id)); const file_extension = getExtension(responseData.data.read_signed_url); - setFileState({ - ...file_state, - open: true, - name: responseData.data.name, - extension: file_extension, - isImage: ExtImage.includes(file_extension), - }); - downloadFileUrl(responseData.data.read_signed_url); - setFileUrl(responseData.data.read_signed_url); + if (file_extension === "pdf") { + window.open(responseData.data.read_signed_url, "_blank"); + setFileState({ ...file_state, open: false }); + } else { + setFileState({ + ...file_state, + open: true, + name: responseData.data.name, + extension: file_extension, + isImage: ExtImage.includes(file_extension), + }); + downloadFileUrl(responseData.data.read_signed_url); + setFileUrl(responseData.data.read_signed_url); + } }; const validateEditFileName = (name: any) => { @@ -1457,7 +1462,7 @@ export const FileUpload = (props: FileUploadProps) => { )} -