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 */}
+ {listError} +
+ )} + {listLoading && ( ++ Загрузка... +
+ )} + {!listLoading && filtered.length === 0 && (Нет вопросов
@@ -270,9 +292,9 @@ export function QuestionSplitView({ currentUserId }: { currentUserId: string }){msg.text}
{msg.files && msg.files.length > 0 && (