IMPROVE error handling on frontend

This commit is contained in:
2025-06-10 12:12:19 +02:00
parent faaac0abec
commit f79beadb09
5 changed files with 48 additions and 25 deletions

View File

@@ -8,14 +8,14 @@ const clipUpload = () => {
const [file, setFile] = useState<File | null>(null);
const navigate = useNavigate();
const [noFileError, setNoFileError] = useState(false);
const [error, setError] = useState<null | string>(null);
const press = (() => {
if (file) {
uploadFile(file)
uploadFile(file, setError)
.then(uuid => navigate(`/create/${uuid}`))
.catch(e => console.error(e));
} else {
setNoFileError(true);
setError("Please choose a file");
}
});
@@ -35,9 +35,7 @@ const clipUpload = () => {
Upload
</BlueButton>
{noFileError &&
<label className={"text-center text-red-500"}>Please choose a file</label>
}
<label className={"text-center text-red-500"}>{error}</label>
</Box>
)
};