Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/backoffice-v2/src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const DOWNLOAD_ONLY_MIME_TYPES = [
// xls
'application/vnd.ms-excel',
'application/x-cfb',
// xlsx
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
] as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const DocumentsToolbar: FunctionComponent<{
hideOpenExternalButton?: boolean;
onRotateDocument: () => void;
onOpenDocumentInNewTab: (id: string) => void;
shouldDownload: boolean;
isDocumentWithoutViewer: boolean;
onOcrPressed?: () => void;
isOCREnabled: boolean;
isLoadingOCR: boolean;
Expand All @@ -63,7 +63,7 @@ export const DocumentsToolbar: FunctionComponent<{
onRotateDocument,
onOpenDocumentInNewTab,
onOcrPressed,
shouldDownload,
isDocumentWithoutViewer,
isLoadingOCR,
isOCREnabled,
fileToDownloadBase64,
Expand Down Expand Up @@ -109,7 +109,7 @@ export const DocumentsToolbar: FunctionComponent<{
type="button"
className={ctw(toolbarButtonClass)}
onClick={onOpenInNewTabClick}
disabled={shouldDownload}
disabled={isDocumentWithoutViewer}
aria-label="Open in new tab"
>
<ExternalLinkIcon className="p-0.5" />
Expand All @@ -127,7 +127,7 @@ export const DocumentsToolbar: FunctionComponent<{
type="button"
className={ctw(toolbarButtonClass)}
onClick={onRotateDocument}
disabled={shouldDownload}
disabled={isDocumentWithoutViewer}
aria-label="Rotate document"
>
<FileText className="rotate-90 p-0.5" />
Expand All @@ -139,12 +139,20 @@ export const DocumentsToolbar: FunctionComponent<{
)}

{/* Download Document Button */}
<div className="flex flex-col items-center">
<div
className={ctw('flex flex-col items-center', {
'pointer-events-none opacity-50': !fileToDownloadBase64,
})}
>
<a
className={ctw(toolbarButtonClass)}
download={image?.fileName}
href={fileToDownloadBase64}
aria-label="Download document"
aria-disabled={!fileToDownloadBase64}
{...(!fileToDownloadBase64 && {
tabIndex: -1,
})}
>
<Download className="p-0.5" />
</a>
Expand All @@ -157,7 +165,10 @@ export const DocumentsToolbar: FunctionComponent<{
{/* Zoom Document Button */}
{!isLoading && (
<div className="flex flex-col items-center">
<ImageViewer.ZoomButton disabled={shouldDownload} className={ctw(toolbarButtonClass)} />
<ImageViewer.ZoomButton
disabled={isDocumentWithoutViewer}
className={ctw(toolbarButtonClass)}
/>
<span className="mt-1 whitespace-nowrap text-[11px] font-extrabold text-black">
Zoom
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const Documents: FunctionComponent<IDocumentsProps> = ({
onOpenDocumentInNewTab,
onTransformed,
isRotatedOrTransformed,
shouldDownload,
isDocumentWithoutViewer,
isOCREnabled,
fileToDownloadBase64,
} = useDocumentsLogic(documents);
Expand All @@ -56,7 +56,7 @@ export const Documents: FunctionComponent<IDocumentsProps> = ({
<ImageViewer selectedImage={selectedImage} onSelectImage={onSelectImage}>
<div className={`flex w-full flex-col items-center`}>
<div className={ctw(`d-full relative flex rounded-md`, wrapperClassName)}>
{!shouldDownload && (
{!isDocumentWithoutViewer && (
<ImageEditor
image={selectedImage}
crop={crop}
Expand All @@ -73,8 +73,8 @@ export const Documents: FunctionComponent<IDocumentsProps> = ({
/>
</ImageEditor>
)}
{shouldDownload && (
<div className={`w-[441px]`}>
{isDocumentWithoutViewer && (
<div className={`h-[600px] w-full`}>
<DownloadFile heading={selectedImage?.fileName} />
</div>
)}
Expand All @@ -85,7 +85,7 @@ export const Documents: FunctionComponent<IDocumentsProps> = ({
onRotateDocument={onRotateDocument}
onOpenDocumentInNewTab={onOpenDocumentInNewTab}
// isRotatedOrTransformed={isRotatedOrTransformed}
shouldDownload={shouldDownload}
shouldDownload={isDocumentWithoutViewer}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix prop name inconsistency.

The DocumentsToolbar component interface expects isDocumentWithoutViewer prop, but you're passing shouldDownload. This will cause a TypeScript error.

Apply this fix:

-            shouldDownload={isDocumentWithoutViewer}
+            isDocumentWithoutViewer={isDocumentWithoutViewer}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
shouldDownload={isDocumentWithoutViewer}
isDocumentWithoutViewer={isDocumentWithoutViewer}
🤖 Prompt for AI Agents
In apps/backoffice-v2/src/pages/Entity/components/Case/Case.Documents.tsx at
line 88, replace the prop name `shouldDownload` with `isDocumentWithoutViewer`
when passing props to the DocumentsToolbar component to match its expected
interface and avoid TypeScript errors.

isOCREnabled={!!isDocumentEditable && isOCREnabled}
onOcrPressed={onOcrPressed}
isLoadingOCR={!!isLoadingOCR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ export const useDocumentsLogic = (_initialDocuments: IDocumentsProps['documents'
[filterId],
);

const shouldDownload = DOWNLOAD_ONLY_MIME_TYPES.includes(selectedImage?.fileType);
const isDocumentWithoutViewer = DOWNLOAD_ONLY_MIME_TYPES.includes(selectedImage?.fileType);
const { data: fileToDownloadBase64 } = useStorageFileByIdQuery(selectedImage?.id, {
isEnabled: shouldDownload,
withSignedUrl: false,
});

Expand All @@ -80,7 +79,7 @@ export const useDocumentsLogic = (_initialDocuments: IDocumentsProps['documents'
onOpenDocumentInNewTab,
isRotatedOrTransformed,
onTransformed,
shouldDownload,
isDocumentWithoutViewer,
fileToDownloadBase64,
};
};
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations