|
|
@ -9,11 +9,12 @@ import { Box, Checkbox, checkboxClasses } from '@mui/material'; |
|
|
|
import API_BASE_URL from '../../lib/consts/API_BASE_URL'; |
|
|
|
import API_BASE_URL from '../../lib/consts/API_BASE_URL'; |
|
|
|
import { GREY, RED, TEXT } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
import { GREY, RED, TEXT } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ContainedButton from '../ContainedButton'; |
|
|
|
import FileInfo from './FileInfo'; |
|
|
|
import FileInfo from './FileInfo'; |
|
|
|
|
|
|
|
import Spinner from '../Spinner'; |
|
|
|
|
|
|
|
|
|
|
|
import fetchJSON from '../../lib/fetchers/fetchJSON'; |
|
|
|
import fetchJSON from '../../lib/fetchers/fetchJSON'; |
|
|
|
import mainAxiosInstance from '../../lib/singletons/mainAxiosInstance'; |
|
|
|
import mainAxiosInstance from '../../lib/singletons/mainAxiosInstance'; |
|
|
|
import StyledContainedButton from './StyledContainedButton'; |
|
|
|
|
|
|
|
import Spinner from '../Spinner'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type FileEditProps = { |
|
|
|
type FileEditProps = { |
|
|
|
filesOverview: FileOverviewMetadata[]; |
|
|
|
filesOverview: FileOverviewMetadata[]; |
|
|
@ -26,25 +27,24 @@ type FileToEdit = FileDetailMetadata & { |
|
|
|
|
|
|
|
|
|
|
|
const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => { |
|
|
|
const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => { |
|
|
|
const [filesToEdit, setFilesToEdit] = useState<FileToEdit[]>([]); |
|
|
|
const [filesToEdit, setFilesToEdit] = useState<FileToEdit[]>([]); |
|
|
|
const [isLoadingFilesToEdit, setIsLoadingFilesToEdit] = useState<boolean>( |
|
|
|
const [isLoadingFilesToEdit, setIsLoadingFilesToEdit] = |
|
|
|
false, |
|
|
|
useState<boolean>(false); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const generateFileInfoChangeHandler = |
|
|
|
const generateFileInfoChangeHandler = ( |
|
|
|
(fileIndex: number): FileInfoChangeHandler => |
|
|
|
fileIndex: number, |
|
|
|
(inputValues, { fileLocationIndex } = {}) => { |
|
|
|
): FileInfoChangeHandler => (inputValues, { fileLocationIndex } = {}) => { |
|
|
|
if (fileLocationIndex) { |
|
|
|
if (fileLocationIndex) { |
|
|
|
filesToEdit[fileIndex].fileLocations[fileLocationIndex] = { |
|
|
|
filesToEdit[fileIndex].fileLocations[fileLocationIndex] = { |
|
|
|
...filesToEdit[fileIndex].fileLocations[fileLocationIndex], |
|
|
|
...filesToEdit[fileIndex].fileLocations[fileLocationIndex], |
|
|
|
...inputValues, |
|
|
|
...inputValues, |
|
|
|
}; |
|
|
|
}; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
filesToEdit[fileIndex] = { |
|
|
|
filesToEdit[fileIndex] = { |
|
|
|
...filesToEdit[fileIndex], |
|
|
|
...filesToEdit[fileIndex], |
|
|
|
...inputValues, |
|
|
|
...inputValues, |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const editFiles: FormEventHandler<HTMLFormElement> = (event) => { |
|
|
|
const editFiles: FormEventHandler<HTMLFormElement> = (event) => { |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
@ -181,7 +181,7 @@ const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
<StyledContainedButton |
|
|
|
<ContainedButton |
|
|
|
onClick={purgeFiles} |
|
|
|
onClick={purgeFiles} |
|
|
|
sx={{ |
|
|
|
sx={{ |
|
|
|
backgroundColor: RED, |
|
|
|
backgroundColor: RED, |
|
|
@ -190,10 +190,8 @@ const FileEditForm = ({ filesOverview }: FileEditProps): JSX.Element => { |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
Purge |
|
|
|
Purge |
|
|
|
</StyledContainedButton> |
|
|
|
</ContainedButton> |
|
|
|
<StyledContainedButton type="submit"> |
|
|
|
<ContainedButton type="submit">Update</ContainedButton> |
|
|
|
Update |
|
|
|
|
|
|
|
</StyledContainedButton> |
|
|
|
|
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
)} |
|
|
|
)} |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|