Fix QuestionSplitView error handling, loading state, file key
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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 */}
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
{filtered.length === 0 && (
|
||||
{listError && (
|
||||
<p className="text-xs p-4" style={{ color: "var(--destructive)" }}>
|
||||
{listError}
|
||||
</p>
|
||||
)}
|
||||
{listLoading && (
|
||||
<p className="text-xs p-4" style={{ color: "var(--muted-foreground)" }}>
|
||||
Загрузка...
|
||||
</p>
|
||||
)}
|
||||
{!listLoading && filtered.length === 0 && (
|
||||
<p className="text-xs p-4" style={{ color: "var(--muted-foreground)" }}>
|
||||
Нет вопросов
|
||||
</p>
|
||||
@@ -270,9 +292,9 @@ export function QuestionSplitView({ currentUserId }: { currentUserId: string })
|
||||
<p style={{ color: "var(--foreground)" }}>{msg.text}</p>
|
||||
{msg.files && msg.files.length > 0 && (
|
||||
<div className="flex flex-col gap-1 mt-2">
|
||||
{msg.files.map((f, i) => (
|
||||
{msg.files.map((f) => (
|
||||
<a
|
||||
key={i}
|
||||
key={f.url}
|
||||
href={f.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
|
||||
Reference in New Issue
Block a user