diff --git a/apps/portal/src/app/features/licensing/components/DocumentSlots.tsx b/apps/portal/src/app/features/licensing/components/DocumentSlots.tsx index 0abf6ddcb..c0e075d4e 100644 --- a/apps/portal/src/app/features/licensing/components/DocumentSlots.tsx +++ b/apps/portal/src/app/features/licensing/components/DocumentSlots.tsx @@ -25,6 +25,8 @@ import { type DocumentRequirement, } from '@ema-platform/api'; +const MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024; + interface Props { requirements: DocumentRequirement[]; attachments: Attachment[]; @@ -68,6 +70,11 @@ export function DocumentSlots({ async function handle(documentKey: string, file: File | null) { if (!file) return; + if (file.size > MAX_FILE_SIZE_BYTES) { + setError(`File exceeds 5MB limit (${(file.size / 1024 / 1024).toFixed(1)}MB).`); + resetRefs.current[documentKey]?.(); + return; + } setBusy(documentKey); setError(null); const result = await uploadDocument({ ownerType, ownerId, documentKey, file }); diff --git a/apps/portal/src/app/features/licensing/components/StaffEvidence.tsx b/apps/portal/src/app/features/licensing/components/StaffEvidence.tsx index fd3cb6ba2..060a4ddbb 100644 --- a/apps/portal/src/app/features/licensing/components/StaffEvidence.tsx +++ b/apps/portal/src/app/features/licensing/components/StaffEvidence.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react'; import { Badge, Button, FileButton, Group, Loader } from '@mantine/core'; +import { notifications } from '@mantine/notifications'; import { IconCheck } from '@tabler/icons-react'; import { localized, @@ -8,6 +9,8 @@ import { type StaffEvidenceRequirement, } from '@ema-platform/api'; +const MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024; + interface Props { staffId: string; evidence: StaffEvidenceRequirement[]; @@ -42,6 +45,13 @@ export function StaffEvidence({ staffId, evidence, readOnly, onUploaded }: Props accept="application/pdf,image/jpeg,image/png" onChange={async (file) => { if (!file) return; + if (file.size > MAX_FILE_SIZE_BYTES) { + notifications.show({ + color: 'red', + message: `File exceeds 5MB limit (${(file.size / 1024 / 1024).toFixed(1)}MB).`, + }); + return; + } setBusy(item.docKey); await uploadDocument({ ownerType: 'APPLICATION_STAFF',