diff --git a/src/app/(student)/questions/new/page.tsx b/src/app/(student)/questions/new/page.tsx index 3e9c45f..51fae5e 100644 --- a/src/app/(student)/questions/new/page.tsx +++ b/src/app/(student)/questions/new/page.tsx @@ -2,6 +2,7 @@ import { useState } from "react"; import { useRouter } from "next/navigation"; +import Link from "next/link"; export default function NewQuestionPage() { const router = useRouter(); @@ -38,13 +39,13 @@ export default function NewQuestionPage() { return (
- ← Все вопросы - +

@@ -68,7 +69,7 @@ export default function NewQuestionPage() { className="w-full text-sm px-3 py-2 outline-none" style={{ border: "2px solid var(--border)", - background: "var(--surface)", + background: "var(--color-surface)", color: "var(--foreground)", }} /> @@ -90,14 +91,14 @@ export default function NewQuestionPage() { className="w-full text-sm px-3 py-2 outline-none resize-none" style={{ border: "2px solid var(--border)", - background: "var(--surface)", + background: "var(--color-surface)", color: "var(--foreground)", }} />

{error && ( -

+

{error}

)} diff --git a/src/app/(student)/questions/page.tsx b/src/app/(student)/questions/page.tsx index c18d374..bac9e09 100644 --- a/src/app/(student)/questions/page.tsx +++ b/src/app/(student)/questions/page.tsx @@ -37,8 +37,8 @@ export default async function QuestionsPage() { href="/questions/new" className="text-sm font-bold px-4 py-2" style={{ - background: "var(--surface)", - border: "2px solid var(--border-strong)", + background: "var(--color-surface)", + border: "2px solid var(--foreground)", color: "var(--foreground)", }} > @@ -62,8 +62,8 @@ export default async function QuestionsPage() { href={`/questions/${q.id}`} className="block p-3 rounded-sm transition-colors" style={{ - border: unread ? "2px solid var(--border-strong)" : "1px solid var(--border)", - background: q.status === "CLOSED" ? "var(--surface-muted)" : "var(--surface)", + border: unread ? "2px solid var(--foreground)" : "1px solid var(--border)", + background: q.status === "CLOSED" ? "var(--background)" : "var(--color-surface)", opacity: q.status === "CLOSED" ? 0.7 : 1, }} > @@ -82,7 +82,7 @@ export default async function QuestionsPage() { style={ q.status === "OPEN" ? { background: "#E8F0D8", border: "1px solid var(--border)", color: "var(--foreground)" } - : { background: "var(--surface-muted)", color: "var(--muted-foreground)" } + : { background: "var(--background)", color: "var(--muted-foreground)" } } > {q.status === "OPEN" ? "● ОТКРЫТ" : "✓ ЗАКРЫТ"} diff --git a/src/app/api/student/question-upload/route.ts b/src/app/api/student/question-upload/route.ts index aafe1ea..dc62af3 100644 --- a/src/app/api/student/question-upload/route.ts +++ b/src/app/api/student/question-upload/route.ts @@ -35,7 +35,7 @@ export async function POST(req: NextRequest) { return NextResponse.json({ error: "Недопустимое расширение файла" }, { status: 415 }); } - const key = `questions/tmp/${session.user.id}/${randomUUID()}.${ext}`; + const key = `questions/${session.user.id}/${randomUUID()}.${ext}`; const buffer = Buffer.from(await file.arrayBuffer()); const url = await uploadFile(key, buffer, file.type); diff --git a/src/components/questions/QuestionThread.tsx b/src/components/questions/QuestionThread.tsx index cd30056..1d50f19 100644 --- a/src/components/questions/QuestionThread.tsx +++ b/src/components/questions/QuestionThread.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useRef } from "react"; +import { useState, useRef, useEffect } from "react"; interface FileAttachment { name: string; @@ -53,6 +53,11 @@ export function QuestionThread({ const [sending, setSending] = useState(false); const [error, setError] = useState(""); const fileInputRef = useRef(null); + const messagesEndRef = useRef(null); + + useEffect(() => { + messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); + }, [messages]); async function handleFileSelect(e: React.ChangeEvent) { const selected = Array.from(e.target.files ?? []); @@ -82,6 +87,7 @@ export function QuestionThread({ } async function handleSend() { + if (uploading) return; if (!text.trim() && files.length === 0) return; setSending(true); setError(""); @@ -120,7 +126,7 @@ export function QuestionThread({ className="max-w-[88%] px-3 py-2 rounded-sm text-sm" style={{ alignSelf: isMine ? "flex-end" : "flex-start", - background: isMine ? "#E8E8E0" : "#F5F5F0", + background: isMine ? "var(--muted)" : "var(--background)", border: isMine ? "none" : `2px solid #E8F0D8`, borderLeft: !isMine && isNew ? "3px solid #323232" : undefined, }} @@ -145,7 +151,7 @@ export function QuestionThread({ rel="noreferrer" className="flex items-center gap-1.5 text-xs px-2 py-1 rounded-sm" style={{ - background: "#F5F5F0", + background: "var(--background)", border: "1px solid #AAAAAA", color: "var(--foreground)", width: "fit-content", @@ -160,6 +166,7 @@ export function QuestionThread({ ); })} +
{/* Queued files preview */} @@ -169,7 +176,7 @@ export function QuestionThread({
📎 {f.name} @@ -245,7 +252,7 @@ export function QuestionThread({
{error && ( -

+

{error}

)}