generated from neurobagel/react-bagel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
120 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { Autocomplete, TextField, CircularProgress } from '@mui/material'; | ||
import repos from '../assets/repos.json'; | ||
import axios from 'axios'; | ||
|
||
const Download = ({ onSomeError }: { onSomeError: (message: string) => void }) => { | ||
// const [repos, setRepos] = useState([]); | ||
// const [loading, setLoading] = useState(false); | ||
// const [fetching, setFetching] = useState(false); | ||
|
||
return ( | ||
<Autocomplete | ||
options={repos} | ||
getOptionLabel={(option) => option.name} | ||
renderInput={(params) => ( | ||
<TextField | ||
{...params} | ||
label="Select a Repository" | ||
variant="outlined" | ||
InputProps={{ | ||
...params.InputProps, | ||
}} | ||
/> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default Download; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { TextField, Button, Typography } from '@mui/material'; | ||
import CloudUploadIcon from '@mui/icons-material/CloudUpload'; | ||
|
||
function Upload({ | ||
fileInput, | ||
uploadedFile, | ||
setUploadedFile, | ||
onUpdateSelectedRepo, | ||
onHandleSubmit, | ||
}: { | ||
onUpdateSelectedRepo: (value: string | null) => void; | ||
fileInput: React.RefObject<HTMLInputElement>; | ||
uploadedFile: File | null; | ||
setUploadedFile: (value: File | null) => void; | ||
onHandleSubmit: () => void; | ||
}) { | ||
function handleFileChange(event: React.ChangeEvent<HTMLInputElement>) { | ||
const file = event.target.files?.[0] || null; | ||
setUploadedFile(file); | ||
} | ||
|
||
function handleUpload() { | ||
fileInput.current?.click(); | ||
} | ||
return ( | ||
<div className="flex h-[70vh] flex-col items-center justify-center space-y-3"> | ||
<TextField | ||
data-cy="dataset-id-field" | ||
label="Dataset ID" | ||
placeholder="dataset id" | ||
required | ||
type="text" | ||
onChange={(event) => onUpdateSelectedRepo(event.target.value)} | ||
/> | ||
{/* | ||
* We have to use a button and an invisible input to trigger the file upload | ||
* since MUI doesn't have a native file input. | ||
* Once the button is clicked we click the invisible input through DOM manipulation | ||
* to trigger the file upload. | ||
*/} | ||
<label htmlFor="file-upload"> | ||
<input | ||
ref={fileInput} | ||
accept="*/*" | ||
style={{ display: 'none' }} | ||
id="file-upload" | ||
type="file" | ||
onChange={handleFileChange} | ||
/> | ||
<Button | ||
data-cy="upload-file-button" | ||
onClick={() => handleUpload()} | ||
startIcon={<CloudUploadIcon />} | ||
variant="contained" | ||
> | ||
Upload File | ||
</Button> | ||
</label> | ||
<Typography>{uploadedFile && `File uploaded: ${uploadedFile.name}`}</Typography> | ||
|
||
<Button data-cy="submit-button" variant="contained" onClick={() => onHandleSubmit()}> | ||
Submit | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
export default Upload; |