This repository was archived by the owner on Dec 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +30
-8
lines changed
pages/MainPage/pages/filesPage Expand file tree Collapse file tree 4 files changed +30
-8
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ import { useGetDownloadFileV2 } from "@/controllers/API/queries/file-management" ;
2+ import { FileType } from "@/types/file_management" ;
3+
4+ interface SingleFileDownloadParams {
5+ id : string ;
6+ filename : string ;
7+ type : string ;
8+ }
9+
10+ export const useCustomHandleSingleFileDownload = ( file : FileType ) => {
11+ const { mutate : downloadFile } = useGetDownloadFileV2 ( {
12+ id : file . id ,
13+ filename : file . name ,
14+ type : file . path . split ( "." ) . pop ( ) || "" ,
15+ } ) ;
16+
17+ const handleSingleDownload = (
18+ params ?: SingleFileDownloadParams ,
19+ setSuccessData ?: ( data : { title : string } ) => void ,
20+ setErrorData ?: ( data : { title : string ; list : string [ ] } ) => void ,
21+ ) => {
22+ downloadFile ( ) ;
23+ } ;
24+
25+ return { handleSingleDownload } ;
26+ } ;
Original file line number Diff line number Diff line change 55 DropdownMenuItem ,
66 DropdownMenuTrigger ,
77} from "@/components/ui/dropdown-menu" ;
8- import { useGetDownloadFileV2 } from "@/controllers/API/queries/file-management" ;
98import { useDeleteFileV2 } from "@/controllers/API/queries/file-management/use-delete-file" ;
109import { useDuplicateFileV2 } from "@/controllers/API/queries/file-management/use-duplicate-file" ;
10+ import { useCustomHandleSingleFileDownload } from "@/customization/hooks/use-custom-handle-single-file-download" ;
1111import ConfirmationModal from "@/modals/confirmationModal" ;
1212import useAlertStore from "@/stores/alertStore" ;
1313import { FileType } from "@/types/file_management" ;
@@ -29,11 +29,7 @@ export default function FilesContextMenuComponent({
2929
3030 const setSuccessData = useAlertStore ( ( state ) => state . setSuccessData ) ;
3131
32- const { mutate : downloadFile } = useGetDownloadFileV2 ( {
33- id : file . id ,
34- filename : file . name ,
35- type : file . path . split ( "." ) . pop ( ) || "" ,
36- } ) ;
32+ const { handleSingleDownload } = useCustomHandleSingleFileDownload ( file ) ;
3733
3834 const { mutate : deleteFile } = useDeleteFileV2 ( {
3935 id : file . id ,
@@ -54,7 +50,7 @@ export default function FilesContextMenuComponent({
5450 console . log ( "replace" ) ;
5551 break ;
5652 case "download" :
57- downloadFile ( ) ;
53+ handleSingleDownload ( ) ;
5854 break ;
5955 case "delete" :
6056 setShowDeleteConfirmation ( true ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { SidebarTrigger } from "@/components/ui/sidebar";
99import { useGetFilesV2 } from "@/controllers/API/queries/file-management" ;
1010import { useDeleteFilesV2 } from "@/controllers/API/queries/file-management/use-delete-files" ;
1111import { usePostRenameFileV2 } from "@/controllers/API/queries/file-management/use-put-rename-file" ;
12- import { useCustomHandleBulkFilesDownload } from "@/customization/hooks/custom-handle-bulk-files-download" ;
12+ import { useCustomHandleBulkFilesDownload } from "@/customization/hooks/use- custom-handle-bulk-files-download" ;
1313import { customPostUploadFileV2 } from "@/customization/hooks/use-custom-post-upload-file" ;
1414import useUploadFile from "@/hooks/files/use-upload-file" ;
1515import DeleteConfirmationModal from "@/modals/deleteConfirmationModal" ;
You can’t perform that action at this time.
0 commit comments