Show error for files that are too large

This commit is contained in:
jude 2024-03-01 16:56:31 +00:00
parent 0e0ab053f3
commit e83b643d86

View File

@ -1,8 +1,11 @@
import { useReminder } from "./ReminderContext"; import { useReminder } from "./ReminderContext";
import { useFlash } from "../App/FlashContext";
export const Attachment = () => { export const Attachment = () => {
const [{ attachment_name }, setReminder] = useReminder(); const [{ attachment_name }, setReminder] = useReminder();
const flash = useFlash();
return ( return (
<div class="file is-small is-boxed"> <div class="file is-small is-boxed">
<label class="file-label"> <label class="file-label">
@ -16,7 +19,8 @@ export const Attachment = () => {
let file = input.files[0]; let file = input.files[0];
if (file.size >= 8 * 1024 * 1024) { if (file.size >= 8 * 1024 * 1024) {
return { error: "File too large." }; flash({ message: "File too large (max. 8MB).", type: "error" });
return;
} }
let attachment: string = await new Promise((resolve) => { let attachment: string = await new Promise((resolve) => {