2
0

fix(bot): 🐛 Files upload progress bar not sequential

This commit is contained in:
Baptiste Arnaud
2022-07-02 17:07:48 +02:00
parent 066147f81d
commit b0010aae32
2 changed files with 15 additions and 16 deletions

View File

@ -24,7 +24,7 @@ export const FileUploadForm = ({
const { resultId } = useAnswers()
const [selectedFiles, setSelectedFiles] = useState<File[]>([])
const [isUploading, setIsUploading] = useState(false)
const [uploadProgressPercent, setUploadProgressPercent] = useState(10)
const [uploadProgressPercent, setUploadProgressPercent] = useState(0)
const [isDraggingOver, setIsDraggingOver] = useState(false)
const [errorMessage, setErrorMessage] = useState<string>()
@ -85,6 +85,8 @@ export const FileUploadForm = ({
})),
onUploadProgress: setUploadProgressPercent,
})
setIsUploading(false)
setUploadProgressPercent(0)
if (urls.length !== files.length)
return setErrorMessage('An error occured while uploading the files')
onSubmit({
@ -121,7 +123,7 @@ export const FileUploadForm = ({
onDragLeave={handleDragLeave}
onDrop={handleDropFile}
>
{isUploading && uploadProgressPercent ? (
{isUploading ? (
<>
{selectedFiles.length === 1 ? (
<Spinner />
@ -130,7 +132,9 @@ export const FileUploadForm = ({
<div
className="upload-progress-bar h-2.5 rounded-full"
style={{
width: `${uploadProgressPercent}%`,
width: `${
uploadProgressPercent > 0 ? uploadProgressPercent : 10
}%`,
transition: 'width 150ms cubic-bezier(0.4, 0, 0.2, 1)',
}}
/>