diff --git a/src/app/user/projects/page.tsx b/src/app/user/projects/page.tsx index b3e262a..72fdb42 100644 --- a/src/app/user/projects/page.tsx +++ b/src/app/user/projects/page.tsx @@ -23,6 +23,9 @@ import StickyHeader from "@/components/ui/StickyHeader"; export type ProjectSortColumn = "created_at" | "updated_at" | "title"; +const IMPORT_JSON_MAX_BYTES = 2 * 1024 * 1024; +const IMPORT_JSON_MAX_LABEL = "2MB"; + function isRecord(value: unknown): value is Record { return !!value && typeof value === "object" && !Array.isArray(value); } @@ -193,6 +196,14 @@ export default function ProjectsPage() { const handleImportJsonFile = async (file: File | null) => { if (!file) return; + if (file.size > IMPORT_JSON_MAX_BYTES) { + setImportSnapshot(null); + setImportSnapshotName(null); + if (importJsonInputRef.current) importJsonInputRef.current.value = ""; + toast.error(`File JSON tối đa ${IMPORT_JSON_MAX_LABEL}.`); + return; + } + try { const text = await file.text(); const raw = JSON.parse(text) as unknown; @@ -591,6 +602,9 @@ export default function ProjectsPage() {
+

+ Chỉ hỗ trợ JSON snapshot tối đa {IMPORT_JSON_MAX_LABEL}. +