fix: lint, stubs, StatusBadge, uptime %, closure remarks UX
This commit is contained in:
@@ -16,26 +16,9 @@ import {
|
||||
} from "@/api/attachments";
|
||||
import { ApiError } from "@/api/client";
|
||||
import { formatDateTime } from "@/lib/format";
|
||||
import { validateAttachmentFile } from "@/lib/validation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
const MAX_SIZE_BYTES = 10 * 1024 * 1024; // 10 MB
|
||||
const ALLOWED_EXTENSIONS = [".jpg", ".jpeg", ".png", ".pdf"];
|
||||
const ALLOWED_MIME_TYPES = ["image/jpeg", "image/png", "application/pdf"];
|
||||
|
||||
export function validateAttachmentFile(file: File): string | null {
|
||||
const nameLower = file.name.toLowerCase();
|
||||
const hasAllowedExt = ALLOWED_EXTENSIONS.some((ext) => nameLower.endsWith(ext));
|
||||
const hasAllowedMime = !file.type || ALLOWED_MIME_TYPES.includes(file.type);
|
||||
|
||||
if (!hasAllowedExt || !hasAllowedMime) {
|
||||
return "Invalid file type. Only JPG, PNG, and PDF files are allowed.";
|
||||
}
|
||||
if (file.size > MAX_SIZE_BYTES) {
|
||||
return "File is too large. Maximum allowed size is 10 MB.";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
|
||||
Reference in New Issue
Block a user