11// src/components/DatasetOrganizer/DropZone.tsx
22import { processFile , processFolder , processZip } from "./utils/fileProcessors" ;
33import { CloudUpload , Add } from "@mui/icons-material" ;
4- import { Box , Typography , Paper , Button } from "@mui/material" ;
4+ import { Box , Typography , Paper , Button , TextField } from "@mui/material" ;
55import { Colors } from "design/theme" ;
66import React , { useState , useRef } from "react" ;
77import { FileItem } from "redux/projects/types/projects.interface" ;
@@ -25,6 +25,7 @@ const DropZone: React.FC<DropZoneProps> = ({
2525} ) => {
2626 const [ isDragging , setIsDragging ] = useState ( false ) ;
2727 const fileInputRef = useRef < HTMLInputElement > ( null ) ;
28+ const [ basePath , setBasePath ] = useState < string > ( "" ) ;
2829
2930 const handleDragOver = ( e : React . DragEvent ) => {
3031 e . preventDefault ( ) ;
@@ -68,7 +69,7 @@ const DropZone: React.FC<DropZoneProps> = ({
6869 const zipFiles = await processZip ( file ) ;
6970 setFiles ( ( prev ) => [ ...prev , ...zipFiles ] ) ;
7071 } else {
71- const fileItem = await processFile ( file ) ;
72+ const fileItem = await processFile ( file , basePath ) ;
7273 setFiles ( ( prev ) => [ ...prev , fileItem ] ) ;
7374 }
7475 }
@@ -82,10 +83,13 @@ const DropZone: React.FC<DropZoneProps> = ({
8283 const zipFiles = await processZip ( file ) ;
8384 setFiles ( ( prev ) => [ ...prev , ...zipFiles ] ) ;
8485 } else {
85- const fileItem = await processFile ( file ) ;
86+ const fileItem = await processFile ( file , basePath ) ;
8687 setFiles ( ( prev ) => [ ...prev , fileItem ] ) ;
8788 }
8889 }
90+
91+ // Reset input
92+ e . target . value = "" ;
8993 } ;
9094
9195 return (
@@ -139,6 +143,7 @@ const DropZone: React.FC<DropZoneProps> = ({
139143 < Typography variant = "body2" color = "text.secondary" sx = { { mb : 1 } } >
140144 Supports NIfTI, SNIRF, HDF5, NeuroJSON, folders, and ZIP archives
141145 </ Typography >
146+
142147 { files . length === 0 && (
143148 < >
144149 < Typography
@@ -168,6 +173,16 @@ const DropZone: React.FC<DropZoneProps> = ({
168173 accept = ".nii,.nii.gz,.snirf,.h5,.hdf5,.jnii,.jmsh,.json,.txt,.md,.zip,.docx,.pdf,.xlsx,.xls"
169174 />
170175 </ Paper >
176+ < TextField
177+ label = "Base Directory Path (optional)"
178+ placeholder = "example: /Users/username/Desktop/Downloads"
179+ value = { basePath }
180+ onChange = { ( e ) => setBasePath ( e . target . value ) }
181+ fullWidth
182+ size = "small"
183+ sx = { { mb : 2 } }
184+ helperText = "Enter the folder path where these files are located"
185+ />
171186 </ Box >
172187 ) ;
173188} ;
0 commit comments