From d2362a3f1edb197f6c627d0e4357159d06bbb5ed Mon Sep 17 00:00:00 2001 From: dmitriylaukhin Date: Tue, 19 May 2026 13:47:35 +0500 Subject: [PATCH] Fix QuestionSplitView error handling, loading state, file key Co-Authored-By: Claude Sonnet 4.6 --- .../questions/QuestionSplitView.tsx | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/components/questions/QuestionSplitView.tsx b/src/components/questions/QuestionSplitView.tsx index 8676505..a52adc5 100644 --- a/src/components/questions/QuestionSplitView.tsx +++ b/src/components/questions/QuestionSplitView.tsx @@ -61,12 +61,24 @@ export function QuestionSplitView({ currentUserId }: { currentUserId: string }) const [sending, setSending] = useState(false); const [closing, setClosing] = useState(false); const [error, setError] = useState(""); + const [listError, setListError] = useState(""); + const [listLoading, setListLoading] = useState(true); const fetchList = useCallback(async () => { - const res = await fetch("/api/questions"); - if (res.ok) { + setListError(""); + setListLoading(true); + try { + const res = await fetch("/api/questions"); + if (!res.ok) { + setListError("Не удалось загрузить вопросы"); + return; + } const data = await res.json(); setQuestions(data); + } catch { + setListError("Не удалось загрузить вопросы"); + } finally { + setListLoading(false); } }, []); @@ -166,7 +178,17 @@ export function QuestionSplitView({ currentUserId }: { currentUserId: string }) {/* Question list */}
- {filtered.length === 0 && ( + {listError && ( +

+ {listError} +

+ )} + {listLoading && ( +

+ Загрузка... +

+ )} + {!listLoading && filtered.length === 0 && (

Нет вопросов

@@ -270,9 +292,9 @@ export function QuestionSplitView({ currentUserId }: { currentUserId: string })

{msg.text}

{msg.files && msg.files.length > 0 && (
- {msg.files.map((f, i) => ( + {msg.files.map((f) => (