IMPROVE error checking on frontend

This commit is contained in:
2025-06-10 10:15:41 +02:00
parent c11cdb0ee6
commit b2c10db130
2 changed files with 18 additions and 3 deletions

View File

@@ -62,7 +62,7 @@ export default function ClipConfig({setMetadata, className}: prop) {
</select> </select>
</Selector> </Selector>
<Selector label={"File Size"}> <Selector label={"File Size Limit (MB)"}>
<input type="number" <input type="number"
min="1" min="1"
defaultValue="10" defaultValue="10"

View File

@@ -26,17 +26,25 @@ const ClipEdit = () => {
}); });
const [progress, setProgress] = useState(0); const [progress, setProgress] = useState(0);
const [downloadable, setDownloadable] = useState(false); const [downloadable, setDownloadable] = useState(false);
const [error, setError] = useState<string | null>(null);
const sendData = async() => { const sendData = async() => {
if (!id) return; if (!id) return;
setDownloadable(false); setDownloadable(false);
await editFile(id, outputMetadata); const edited = await editFile(id, outputMetadata);
const processed = await processFile(id); const processed = await processFile(id);
if (!edited) {
console.log("Failed to edit file");
setError("Failed to edit file. Please check the metadata and try again.");
return;
}
if (!processed) { if (!processed) {
console.log("Failed to process file"); console.log("Failed to process file");
setError("Failed to process file. Please try again later.");
return; return;
} }
@@ -122,7 +130,14 @@ const ClipEdit = () => {
setMetadata={setOutputMetadata} setMetadata={setOutputMetadata}
className={"w-full mt-2 bg-primary"} className={"w-full mt-2 bg-primary"}
/> />
</Box>}
{error && (
<div className="text-red-600 text-center mt-2">
{error}
</div>
)}
</Box>
}
<Box className={"flex flex-col gap-2 w-4/5 m-auto mt-4 p-5"}> <Box className={"flex flex-col gap-2 w-4/5 m-auto mt-4 p-5"}>
<ExportWidget <ExportWidget