Polish UX: auto-redirect on create, fix design consistency
- createModule now redirects to module page after creation - createLesson now redirects to lesson editor after creation - Regenerate Prisma client to fix missing types (category, accessLog, expiresAt) - Rewrite sortable-modules/lessons with Second Brain design tokens (remove amber/slate) - Rewrite lesson-editor toolbar and toggle with design tokens - Fix register page/form: replace amber theme with card-aubade design Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,13 +2,17 @@ import { RegisterForm } from "./register-form";
|
|||||||
|
|
||||||
export default function RegisterPage() {
|
export default function RegisterPage() {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex items-center justify-center bg-amber-50">
|
<div className="min-h-screen flex items-center justify-center" style={{ backgroundColor: "var(--background)" }}>
|
||||||
<div className="w-full max-w-md">
|
<div className="w-full max-w-sm">
|
||||||
<div className="text-center mb-8">
|
<div className="text-center mb-8">
|
||||||
<h1 className="text-3xl font-bold text-amber-900">Second Brain</h1>
|
<h1 className="text-2xl font-bold tracking-wide" style={{ color: "var(--foreground)" }}>
|
||||||
<p className="text-amber-700 mt-2">Создайте аккаунт</p>
|
Second Brain
|
||||||
|
</h1>
|
||||||
|
<p className="mt-1 text-sm uppercase tracking-widest" style={{ color: "var(--muted-foreground)", fontSize: "0.65rem" }}>
|
||||||
|
Образовательная платформа
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-white rounded-2xl shadow-sm border border-amber-100 p-8">
|
<div className="card-aubade p-8">
|
||||||
<RegisterForm />
|
<RegisterForm />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { signUp } from "@/lib/auth-client";
|
import { signUp } from "@/lib/auth-client";
|
||||||
|
|
||||||
export function RegisterForm() {
|
export function RegisterForm() {
|
||||||
const router = useRouter();
|
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
@@ -14,6 +12,16 @@ export function RegisterForm() {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [success, setSuccess] = useState(false);
|
const [success, setSuccess] = useState(false);
|
||||||
|
|
||||||
|
const inputStyle = {
|
||||||
|
border: "2px solid var(--border)",
|
||||||
|
background: "var(--background)",
|
||||||
|
outline: "none",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.5rem 0.75rem",
|
||||||
|
fontSize: "0.875rem",
|
||||||
|
fontFamily: "inherit",
|
||||||
|
} as React.CSSProperties;
|
||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent) {
|
async function handleSubmit(e: React.FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setError("");
|
setError("");
|
||||||
@@ -35,14 +43,11 @@ export function RegisterForm() {
|
|||||||
return (
|
return (
|
||||||
<div className="text-center space-y-4">
|
<div className="text-center space-y-4">
|
||||||
<div className="text-4xl">✉️</div>
|
<div className="text-4xl">✉️</div>
|
||||||
<h2 className="text-xl font-semibold text-gray-800">
|
<p className="font-bold">Проверьте почту</p>
|
||||||
Проверьте почту
|
<p className="text-sm" style={{ color: "var(--muted-foreground)" }}>
|
||||||
</h2>
|
Мы отправили письмо на <strong>{email}</strong> для подтверждения аккаунта.
|
||||||
<p className="text-gray-500">
|
|
||||||
Мы отправили письмо на <strong>{email}</strong> для подтверждения
|
|
||||||
аккаунта.
|
|
||||||
</p>
|
</p>
|
||||||
<Link href="/login" className="text-amber-600 hover:underline text-sm">
|
<Link href="/login" className="text-sm underline" style={{ color: "var(--foreground)" }}>
|
||||||
Вернуться к входу
|
Вернуться к входу
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,8 +56,8 @@ export function RegisterForm() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<div>
|
<div className="space-y-1">
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
Имя
|
Имя
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
@@ -60,12 +65,14 @@ export function RegisterForm() {
|
|||||||
value={name}
|
value={name}
|
||||||
onChange={(e) => setName(e.target.value)}
|
onChange={(e) => setName(e.target.value)}
|
||||||
required
|
required
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-400"
|
style={inputStyle}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
placeholder="Иван Иванов"
|
placeholder="Иван Иванов"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="space-y-1">
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
Email
|
Email
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
@@ -73,12 +80,14 @@ export function RegisterForm() {
|
|||||||
value={email}
|
value={email}
|
||||||
onChange={(e) => setEmail(e.target.value)}
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
required
|
required
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-400"
|
style={inputStyle}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
placeholder="you@example.com"
|
placeholder="you@example.com"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div className="space-y-1">
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
Пароль
|
Пароль
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
@@ -87,21 +96,28 @@ export function RegisterForm() {
|
|||||||
onChange={(e) => setPassword(e.target.value)}
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
required
|
required
|
||||||
minLength={8}
|
minLength={8}
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-400"
|
style={inputStyle}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
placeholder="Минимум 8 символов"
|
placeholder="Минимум 8 символов"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{error && <p className="text-red-500 text-sm">{error}</p>}
|
{error && (
|
||||||
|
<p className="text-xs py-2 px-3" style={{ border: "2px solid oklch(0.577 0.245 27.325)", color: "oklch(0.577 0.245 27.325)" }}>
|
||||||
|
{error}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="w-full bg-amber-500 hover:bg-amber-600 text-white font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50"
|
className="btn-aubade btn-aubade-accent w-full py-2 text-sm"
|
||||||
|
style={{ opacity: loading ? 0.6 : 1 }}
|
||||||
>
|
>
|
||||||
{loading ? "Регистрация..." : "Зарегистрироваться"}
|
{loading ? "Регистрация..." : "Зарегистрироваться"}
|
||||||
</button>
|
</button>
|
||||||
<p className="text-center text-sm text-gray-500">
|
<p className="text-center text-xs" style={{ color: "var(--muted-foreground)" }}>
|
||||||
Уже есть аккаунт?{" "}
|
Уже есть аккаунт?{" "}
|
||||||
<Link href="/login" className="text-amber-600 hover:underline">
|
<Link href="/login" className="underline" style={{ color: "var(--foreground)" }}>
|
||||||
Войти
|
Войти
|
||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { prisma } from "@/lib/prisma";
|
|||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { auth } from "@/lib/auth";
|
import { auth } from "@/lib/auth";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
async function requireAdmin() {
|
async function requireAdmin() {
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
@@ -17,8 +18,9 @@ export async function createModule(courseId: string, formData: FormData) {
|
|||||||
await requireAdmin();
|
await requireAdmin();
|
||||||
const title = formData.get("title") as string;
|
const title = formData.get("title") as string;
|
||||||
const count = await prisma.module.count({ where: { courseId } });
|
const count = await prisma.module.count({ where: { courseId } });
|
||||||
await prisma.module.create({ data: { courseId, title, order: count } });
|
const mod = await prisma.module.create({ data: { courseId, title, order: count } });
|
||||||
revalidatePath(`/admin/courses/${courseId}`);
|
revalidatePath(`/admin/courses/${courseId}`);
|
||||||
|
redirect(`/admin/courses/${courseId}/modules/${mod.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateModule(moduleId: string, courseId: string, formData: FormData) {
|
export async function updateModule(moduleId: string, courseId: string, formData: FormData) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { prisma } from "@/lib/prisma";
|
|||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { auth } from "@/lib/auth";
|
import { auth } from "@/lib/auth";
|
||||||
import { revalidatePath } from "next/cache";
|
import { revalidatePath } from "next/cache";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
async function requireAdmin() {
|
async function requireAdmin() {
|
||||||
const session = await auth.api.getSession({ headers: await headers() });
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
@@ -14,8 +15,9 @@ export async function createLesson(moduleId: string, courseId: string, formData:
|
|||||||
await requireAdmin();
|
await requireAdmin();
|
||||||
const title = formData.get("title") as string;
|
const title = formData.get("title") as string;
|
||||||
const count = await prisma.lesson.count({ where: { moduleId } });
|
const count = await prisma.lesson.count({ where: { moduleId } });
|
||||||
await prisma.lesson.create({ data: { moduleId, title, order: count } });
|
const lesson = await prisma.lesson.create({ data: { moduleId, title, order: count } });
|
||||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
||||||
|
redirect(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lesson.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateLesson(lessonId: string, courseId: string, moduleId: string, formData: FormData) {
|
export async function updateLesson(lessonId: string, courseId: string, moduleId: string, formData: FormData) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { prisma } from "@/lib/prisma";
|
import { prisma } from "@/lib/prisma";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { SortableLessons } from "@/components/admin/sortable-lessons";
|
import { SortableLessons } from "@/components/admin/sortable-lessons";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -23,22 +22,25 @@ export default async function ModulePage({ params }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-8 max-w-3xl">
|
<div className="p-8 max-w-3xl">
|
||||||
<nav className="text-sm text-slate-400 mb-6">
|
<nav className="text-xs mb-6 uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
<Link href="/admin/courses" className="hover:text-slate-600">Курсы</Link>
|
<Link href="/admin/courses" className="hover:underline">Курсы</Link>
|
||||||
<span className="mx-2">/</span>
|
<span className="mx-2">/</span>
|
||||||
<Link href={`/admin/courses/${courseId}`} className="hover:text-slate-600">{module.course.title}</Link>
|
<Link href={`/admin/courses/${courseId}`} className="hover:underline">{module.course.title}</Link>
|
||||||
<span className="mx-2">/</span>
|
<span className="mx-2">/</span>
|
||||||
<span className="text-slate-700">{module.title}</span>
|
<span style={{ color: "var(--foreground)" }}>{module.title}</span>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div className="flex items-center justify-between mb-6">
|
<div className="mb-6">
|
||||||
<div>
|
<h1 className="text-2xl font-bold">{module.title}</h1>
|
||||||
<h1 className="text-2xl font-semibold text-slate-800">{module.title}</h1>
|
<p className="text-sm mt-1" style={{ color: "var(--muted-foreground)" }}>
|
||||||
<p className="text-slate-500 text-sm mt-0.5">{module.lessons.length} уроков</p>
|
{module.lessons.length} {module.lessons.length === 1 ? "урок" : module.lessons.length < 5 ? "урока" : "уроков"}
|
||||||
</div>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section className="bg-white border border-slate-200 rounded-2xl p-6">
|
<section className="card-aubade p-6">
|
||||||
|
<p className="text-xs font-bold uppercase tracking-widest mb-5" style={{ color: "var(--muted-foreground)" }}>
|
||||||
|
Уроки модуля
|
||||||
|
</p>
|
||||||
<SortableLessons courseId={courseId} moduleId={moduleId} lessons={module.lessons} />
|
<SortableLessons courseId={courseId} moduleId={moduleId} lessons={module.lessons} />
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import StarterKit from "@tiptap/starter-kit";
|
|||||||
import Image from "@tiptap/extension-image";
|
import Image from "@tiptap/extension-image";
|
||||||
import Link from "@tiptap/extension-link";
|
import Link from "@tiptap/extension-link";
|
||||||
import Placeholder from "@tiptap/extension-placeholder";
|
import Placeholder from "@tiptap/extension-placeholder";
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { saveLesson } from "@/app/admin/courses/[courseId]/modules/[moduleId]/lessons/[lessonId]/actions";
|
import { saveLesson } from "@/app/admin/courses/[courseId]/modules/[moduleId]/lessons/[lessonId]/actions";
|
||||||
|
|
||||||
interface LessonData {
|
interface LessonData {
|
||||||
@@ -35,6 +32,16 @@ export function LessonEditor({
|
|||||||
const [saved, setSaved] = useState(false);
|
const [saved, setSaved] = useState(false);
|
||||||
const [pending, startTransition] = useTransition();
|
const [pending, startTransition] = useTransition();
|
||||||
|
|
||||||
|
const inputStyle = {
|
||||||
|
border: "2px solid var(--border)",
|
||||||
|
background: "var(--background)",
|
||||||
|
outline: "none",
|
||||||
|
width: "100%",
|
||||||
|
padding: "0.5rem 0.75rem",
|
||||||
|
fontSize: "0.875rem",
|
||||||
|
fontFamily: "inherit",
|
||||||
|
} as React.CSSProperties;
|
||||||
|
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
extensions: [
|
extensions: [
|
||||||
StarterKit,
|
StarterKit,
|
||||||
@@ -86,70 +93,103 @@ export function LessonEditor({
|
|||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
{/* Header controls */}
|
{/* Header controls */}
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-3">
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
role="switch"
|
role="switch"
|
||||||
aria-checked={published}
|
aria-checked={published}
|
||||||
onClick={() => setPublished(!published)}
|
onClick={() => setPublished(!published)}
|
||||||
className={`relative w-10 h-6 rounded-full transition-colors ${published ? "bg-green-500" : "bg-slate-300"}`}
|
className="flex items-center gap-2 text-sm"
|
||||||
>
|
>
|
||||||
<span className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full shadow transition-transform ${published ? "translate-x-4" : ""}`} />
|
<span
|
||||||
|
className="relative inline-block w-10 h-6 transition-colors"
|
||||||
|
style={{
|
||||||
|
background: published ? "var(--accent)" : "var(--border)",
|
||||||
|
border: "2px solid var(--foreground)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="absolute top-0.5 w-4 h-4 transition-transform"
|
||||||
|
style={{
|
||||||
|
background: "var(--foreground)",
|
||||||
|
left: "2px",
|
||||||
|
transform: published ? "translateX(16px)" : "translateX(0)",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span style={{ color: published ? "var(--foreground)" : "var(--muted-foreground)" }}>
|
||||||
|
{published ? "Опубликован" : "Черновик"}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<span className="text-sm text-slate-600">{published ? "Опубликован" : "Черновик"}</span>
|
|
||||||
</div>
|
<button
|
||||||
<Button onClick={handleSave} disabled={pending || uploading}>
|
type="button"
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={pending || uploading}
|
||||||
|
className="btn-aubade btn-aubade-accent px-5 py-2 text-sm"
|
||||||
|
style={{ opacity: pending || uploading ? 0.6 : 1 }}
|
||||||
|
>
|
||||||
{pending ? "Сохранение..." : saved ? "✓ Сохранено" : "Сохранить урок"}
|
{pending ? "Сохранение..." : saved ? "✓ Сохранено" : "Сохранить урок"}
|
||||||
</Button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1">
|
||||||
<Label htmlFor="lesson-title">Заголовок урока</Label>
|
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
<Input
|
Заголовок урока
|
||||||
id="lesson-title"
|
</label>
|
||||||
|
<input
|
||||||
value={title}
|
value={title}
|
||||||
onChange={(e) => setTitle(e.target.value)}
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
className="text-lg font-medium"
|
style={{ ...inputStyle, fontSize: "1.1rem", fontWeight: "700" }}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Kinescope ID */}
|
{/* Kinescope ID */}
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1">
|
||||||
<Label htmlFor="kinescope-id">Kinescope ID</Label>
|
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
<Input
|
Kinescope Video ID
|
||||||
id="kinescope-id"
|
</label>
|
||||||
|
<input
|
||||||
value={kinescopeId}
|
value={kinescopeId}
|
||||||
onChange={(e) => setKinescopeId(e.target.value)}
|
onChange={(e) => setKinescopeId(e.target.value)}
|
||||||
placeholder="Оставьте пустым если видео нет"
|
placeholder="Оставьте пустым если видео нет"
|
||||||
className="font-mono text-sm"
|
style={{ ...inputStyle, fontFamily: "var(--font-mono)" }}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* TipTap Editor */}
|
{/* TipTap Editor */}
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1">
|
||||||
<Label>Содержимое урока</Label>
|
<label className="text-xs font-bold uppercase tracking-widest" style={{ color: "var(--muted-foreground)" }}>
|
||||||
|
Содержимое урока
|
||||||
|
</label>
|
||||||
|
|
||||||
{/* Toolbar */}
|
{/* Toolbar */}
|
||||||
<div className="flex flex-wrap gap-1 p-2 bg-slate-50 border border-slate-200 rounded-t-lg border-b-0">
|
<div
|
||||||
|
className="flex flex-wrap gap-1 p-2"
|
||||||
|
style={{ border: "2px solid var(--border)", borderBottom: "1px solid var(--border)", background: "var(--color-surface)" }}
|
||||||
|
>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleBold().run()} active={editor?.isActive("bold")}>Ж</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleBold().run()} active={editor?.isActive("bold")}>Ж</ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleItalic().run()} active={editor?.isActive("italic")}><em>К</em></ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleItalic().run()} active={editor?.isActive("italic")}><em>К</em></ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleHeading({ level: 2 }).run()} active={editor?.isActive("heading", { level: 2 })}>H2</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleHeading({ level: 2 }).run()} active={editor?.isActive("heading", { level: 2 })}>H2</ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()} active={editor?.isActive("heading", { level: 3 })}>H3</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()} active={editor?.isActive("heading", { level: 3 })}>H3</ToolBtn>
|
||||||
<div className="w-px bg-slate-200 mx-1" />
|
<div className="w-px mx-1" style={{ background: "var(--border)" }} />
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleBulletList().run()} active={editor?.isActive("bulletList")}>• Список</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleBulletList().run()} active={editor?.isActive("bulletList")}>• Список</ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleOrderedList().run()} active={editor?.isActive("orderedList")}>1. Список</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleOrderedList().run()} active={editor?.isActive("orderedList")}>1. Список</ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleBlockquote().run()} active={editor?.isActive("blockquote")}>“”</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleBlockquote().run()} active={editor?.isActive("blockquote")}>“”</ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().toggleCodeBlock().run()} active={editor?.isActive("codeBlock")}>{'</>'}</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().toggleCodeBlock().run()} active={editor?.isActive("codeBlock")}>{'</>'}</ToolBtn>
|
||||||
<div className="w-px bg-slate-200 mx-1" />
|
<div className="w-px mx-1" style={{ background: "var(--border)" }} />
|
||||||
<ToolBtn onClick={uploadImage} disabled={uploading}>{uploading ? "Загрузка..." : "🖼 Фото"}</ToolBtn>
|
<ToolBtn onClick={uploadImage} disabled={uploading}>{uploading ? "Загрузка..." : "🖼 Фото"}</ToolBtn>
|
||||||
<div className="w-px bg-slate-200 mx-1" />
|
<div className="w-px mx-1" style={{ background: "var(--border)" }} />
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().undo().run()}>↩</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().undo().run()}>↩</ToolBtn>
|
||||||
<ToolBtn onClick={() => editor?.chain().focus().redo().run()}>↪</ToolBtn>
|
<ToolBtn onClick={() => editor?.chain().focus().redo().run()}>↪</ToolBtn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Editor content */}
|
{/* Editor content */}
|
||||||
<div className="border border-slate-200 rounded-b-lg bg-white">
|
<div style={{ border: "2px solid var(--border)", borderTop: "none", background: "var(--background)" }}>
|
||||||
<EditorContent editor={editor} />
|
<EditorContent editor={editor} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -173,9 +213,14 @@ function ToolBtn({
|
|||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={`px-2 py-1 text-sm rounded transition-colors ${
|
className="px-2 py-1 text-xs transition-colors disabled:opacity-50"
|
||||||
active ? "bg-slate-700 text-white" : "hover:bg-slate-200 text-slate-700"
|
style={{
|
||||||
} disabled:opacity-50`}
|
background: active ? "var(--foreground)" : "transparent",
|
||||||
|
color: active ? "var(--background)" : "var(--foreground)",
|
||||||
|
border: "1px solid transparent",
|
||||||
|
}}
|
||||||
|
onMouseEnter={(e) => { if (!active) e.currentTarget.style.background = "var(--border)"; }}
|
||||||
|
onMouseLeave={(e) => { if (!active) e.currentTarget.style.background = "transparent"; }}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ import {
|
|||||||
} from "@dnd-kit/sortable";
|
} from "@dnd-kit/sortable";
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { createLesson, deleteLesson, updateLesson, reorderLessons } from "@/app/admin/courses/[courseId]/modules/[moduleId]/actions";
|
import { createLesson, deleteLesson, updateLesson, reorderLessons } from "@/app/admin/courses/[courseId]/modules/[moduleId]/actions";
|
||||||
|
|
||||||
interface Lesson {
|
interface Lesson {
|
||||||
@@ -39,6 +36,7 @@ function SortableLesson({
|
|||||||
moduleId: string;
|
moduleId: string;
|
||||||
}) {
|
}) {
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
|
const [editValue, setEditValue] = useState(lesson.title);
|
||||||
const [pending, startTransition] = useTransition();
|
const [pending, startTransition] = useTransition();
|
||||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
||||||
useSortable({ id: lesson.id });
|
useSortable({ id: lesson.id });
|
||||||
@@ -46,7 +44,7 @@ function SortableLesson({
|
|||||||
const style = {
|
const style = {
|
||||||
transform: CSS.Transform.toString(transform),
|
transform: CSS.Transform.toString(transform),
|
||||||
transition,
|
transition,
|
||||||
opacity: isDragging ? 0.5 : 1,
|
opacity: isDragging ? 0.4 : 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleUpdate(e: React.FormEvent<HTMLFormElement>) {
|
function handleUpdate(e: React.FormEvent<HTMLFormElement>) {
|
||||||
@@ -62,32 +60,79 @@ function SortableLesson({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={setNodeRef} style={style} className="flex items-center gap-3 bg-slate-50 border border-slate-200 rounded-xl px-4 py-3">
|
<div
|
||||||
<button type="button" {...attributes} {...listeners} className="text-slate-300 hover:text-slate-500 cursor-grab active:cursor-grabbing">
|
ref={setNodeRef}
|
||||||
⋮⋮
|
style={{ ...style, border: "2px solid var(--border)", background: "var(--color-surface)" }}
|
||||||
|
className="flex items-center gap-3 px-4 py-3"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
{...attributes}
|
||||||
|
{...listeners}
|
||||||
|
className="cursor-grab active:cursor-grabbing text-lg select-none"
|
||||||
|
style={{ color: "var(--muted-foreground)" }}
|
||||||
|
aria-label="Перетащить"
|
||||||
|
>
|
||||||
|
⠿
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{editing ? (
|
{editing ? (
|
||||||
<form onSubmit={handleUpdate} className="flex items-center gap-2 flex-1">
|
<form onSubmit={handleUpdate} className="flex items-center gap-2 flex-1">
|
||||||
<Input name="title" defaultValue={lesson.title} autoFocus className="h-8 text-sm" />
|
<input
|
||||||
<Button type="submit" size="sm" disabled={pending}>Сохранить</Button>
|
name="title"
|
||||||
<Button type="button" variant="ghost" size="sm" onClick={() => setEditing(false)}>Отмена</Button>
|
value={editValue}
|
||||||
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
|
autoFocus
|
||||||
|
required
|
||||||
|
className="flex-1 px-2 py-1 text-sm"
|
||||||
|
style={{ border: "2px solid var(--foreground)", background: "var(--background)", outline: "none" }}
|
||||||
|
/>
|
||||||
|
<button type="submit" disabled={pending} className="btn-aubade text-xs px-3 py-1">
|
||||||
|
Сохранить
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => { setEditing(false); setEditValue(lesson.title); }}
|
||||||
|
className="text-xs px-3 py-1"
|
||||||
|
style={{ color: "var(--muted-foreground)" }}
|
||||||
|
>
|
||||||
|
Отмена
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<span className="flex-1 font-medium text-slate-700">{lesson.title}</span>
|
<span className="flex-1 font-medium text-sm">{lesson.title}</span>
|
||||||
<Badge variant={lesson.published ? "default" : "secondary"} className="text-xs">
|
<span
|
||||||
|
className="text-xs px-2 py-0.5"
|
||||||
|
style={{
|
||||||
|
border: "1px solid var(--border)",
|
||||||
|
color: lesson.published ? "var(--foreground)" : "var(--muted-foreground)",
|
||||||
|
background: lesson.published ? "var(--accent)" : "transparent",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{lesson.published ? "Опубликован" : "Черновик"}
|
{lesson.published ? "Опубликован" : "Черновик"}
|
||||||
</Badge>
|
</span>
|
||||||
<Link
|
<Link
|
||||||
href={`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lesson.id}`}
|
href={`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lesson.id}`}
|
||||||
className="text-xs text-amber-600 hover:underline"
|
className="btn-aubade text-xs px-3 py-1"
|
||||||
>
|
>
|
||||||
Редактировать
|
Редактировать →
|
||||||
</Link>
|
</Link>
|
||||||
<button type="button" onClick={() => setEditing(true)} className="text-xs text-slate-500 hover:text-slate-700">
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setEditing(true)}
|
||||||
|
className="text-xs"
|
||||||
|
style={{ color: "var(--muted-foreground)" }}
|
||||||
|
>
|
||||||
Переименовать
|
Переименовать
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onClick={handleDelete} disabled={pending} className="text-xs text-red-400 hover:text-red-600">
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleDelete}
|
||||||
|
disabled={pending}
|
||||||
|
className="text-xs"
|
||||||
|
style={{ color: "oklch(0.577 0.245 27.325)" }}
|
||||||
|
>
|
||||||
Удалить
|
Удалить
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
@@ -106,7 +151,7 @@ export function SortableLessons({
|
|||||||
lessons: Lesson[];
|
lessons: Lesson[];
|
||||||
}) {
|
}) {
|
||||||
const [items, setItems] = useState(lessons);
|
const [items, setItems] = useState(lessons);
|
||||||
const [, startTransition] = useTransition();
|
const [creating, startTransition] = useTransition();
|
||||||
|
|
||||||
const sensors = useSensors(useSensor(PointerSensor));
|
const sensors = useSensors(useSensor(PointerSensor));
|
||||||
|
|
||||||
@@ -129,7 +174,7 @@ export function SortableLessons({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-2">
|
||||||
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
||||||
<SortableContext items={items.map((l) => l.id)} strategy={verticalListSortingStrategy}>
|
<SortableContext items={items.map((l) => l.id)} strategy={verticalListSortingStrategy}>
|
||||||
{items.map((lesson) => (
|
{items.map((lesson) => (
|
||||||
@@ -139,12 +184,25 @@ export function SortableLessons({
|
|||||||
</DndContext>
|
</DndContext>
|
||||||
|
|
||||||
{items.length === 0 && (
|
{items.length === 0 && (
|
||||||
<p className="text-sm text-slate-400 py-2">Уроков пока нет. Добавьте первый.</p>
|
<p className="text-sm py-3" style={{ color: "var(--muted-foreground)" }}>
|
||||||
|
Уроков пока нет. Добавьте первый.
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<form onSubmit={handleCreate} className="flex gap-2 pt-2">
|
<form onSubmit={handleCreate} className="flex gap-2 pt-3">
|
||||||
<Input name="title" placeholder="Название нового урока" required className="max-w-xs" />
|
<input
|
||||||
<Button type="submit">+ Урок</Button>
|
name="title"
|
||||||
|
placeholder="Название нового урока"
|
||||||
|
required
|
||||||
|
disabled={creating}
|
||||||
|
className="flex-1 max-w-xs px-3 py-2 text-sm"
|
||||||
|
style={{ border: "2px solid var(--border)", background: "var(--background)", outline: "none" }}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
|
/>
|
||||||
|
<button type="submit" disabled={creating} className="btn-aubade text-xs px-4 py-2">
|
||||||
|
{creating ? "Создание..." : "+ Урок"}
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import {
|
|||||||
} from "@dnd-kit/sortable";
|
} from "@dnd-kit/sortable";
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { createModule, deleteModule, updateModule, reorderModules } from "@/app/admin/courses/[courseId]/actions";
|
import { createModule, deleteModule, updateModule, reorderModules } from "@/app/admin/courses/[courseId]/actions";
|
||||||
|
|
||||||
interface Module {
|
interface Module {
|
||||||
@@ -28,14 +26,9 @@ interface Module {
|
|||||||
_count: { lessons: number };
|
_count: { lessons: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
function SortableModule({
|
function SortableModule({ mod, courseId }: { mod: Module; courseId: string }) {
|
||||||
mod,
|
|
||||||
courseId,
|
|
||||||
}: {
|
|
||||||
mod: Module;
|
|
||||||
courseId: string;
|
|
||||||
}) {
|
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
|
const [editValue, setEditValue] = useState(mod.title);
|
||||||
const [pending, startTransition] = useTransition();
|
const [pending, startTransition] = useTransition();
|
||||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } =
|
||||||
useSortable({ id: mod.id });
|
useSortable({ id: mod.id });
|
||||||
@@ -43,7 +36,7 @@ function SortableModule({
|
|||||||
const style = {
|
const style = {
|
||||||
transform: CSS.Transform.toString(transform),
|
transform: CSS.Transform.toString(transform),
|
||||||
transition,
|
transition,
|
||||||
opacity: isDragging ? 0.5 : 1,
|
opacity: isDragging ? 0.4 : 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleUpdate(e: React.FormEvent<HTMLFormElement>) {
|
function handleUpdate(e: React.FormEvent<HTMLFormElement>) {
|
||||||
@@ -59,30 +52,72 @@ function SortableModule({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={setNodeRef} style={style} className="flex items-center gap-3 bg-slate-50 border border-slate-200 rounded-xl px-4 py-3">
|
<div
|
||||||
<button type="button" {...attributes} {...listeners} className="text-slate-300 hover:text-slate-500 cursor-grab active:cursor-grabbing">
|
ref={setNodeRef}
|
||||||
⋮⋮
|
style={{ ...style, border: "2px solid var(--border)", background: "var(--color-surface)" }}
|
||||||
|
className="flex items-center gap-3 px-4 py-3"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
{...attributes}
|
||||||
|
{...listeners}
|
||||||
|
className="cursor-grab active:cursor-grabbing text-lg select-none"
|
||||||
|
style={{ color: "var(--muted-foreground)" }}
|
||||||
|
aria-label="Перетащить"
|
||||||
|
>
|
||||||
|
⠿
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{editing ? (
|
{editing ? (
|
||||||
<form onSubmit={handleUpdate} className="flex items-center gap-2 flex-1">
|
<form onSubmit={handleUpdate} className="flex items-center gap-2 flex-1">
|
||||||
<Input name="title" defaultValue={mod.title} autoFocus className="h-8 text-sm" />
|
<input
|
||||||
<Button type="submit" size="sm" disabled={pending}>Сохранить</Button>
|
name="title"
|
||||||
<Button type="button" variant="ghost" size="sm" onClick={() => setEditing(false)}>Отмена</Button>
|
value={editValue}
|
||||||
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
|
autoFocus
|
||||||
|
required
|
||||||
|
className="flex-1 px-2 py-1 text-sm"
|
||||||
|
style={{ border: "2px solid var(--foreground)", background: "var(--background)", outline: "none" }}
|
||||||
|
/>
|
||||||
|
<button type="submit" disabled={pending} className="btn-aubade text-xs px-3 py-1">
|
||||||
|
Сохранить
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => { setEditing(false); setEditValue(mod.title); }}
|
||||||
|
className="text-xs px-3 py-1"
|
||||||
|
style={{ color: "var(--muted-foreground)" }}
|
||||||
|
>
|
||||||
|
Отмена
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<span className="flex-1 font-medium text-slate-700">{mod.title}</span>
|
<span className="flex-1 font-medium text-sm">{mod.title}</span>
|
||||||
<span className="text-sm text-slate-400">{mod._count.lessons} уроков</span>
|
<span className="text-xs" style={{ color: "var(--muted-foreground)" }}>
|
||||||
|
{mod._count.lessons} {mod._count.lessons === 1 ? "урок" : mod._count.lessons < 5 ? "урока" : "уроков"}
|
||||||
|
</span>
|
||||||
<Link
|
<Link
|
||||||
href={`/admin/courses/${courseId}/modules/${mod.id}`}
|
href={`/admin/courses/${courseId}/modules/${mod.id}`}
|
||||||
className="text-xs text-amber-600 hover:underline"
|
className="btn-aubade text-xs px-3 py-1"
|
||||||
>
|
>
|
||||||
Уроки
|
Уроки →
|
||||||
</Link>
|
</Link>
|
||||||
<button type="button" onClick={() => setEditing(true)} className="text-xs text-slate-500 hover:text-slate-700">
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setEditing(true)}
|
||||||
|
className="text-xs"
|
||||||
|
style={{ color: "var(--muted-foreground)" }}
|
||||||
|
>
|
||||||
Переименовать
|
Переименовать
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onClick={handleDelete} disabled={pending} className="text-xs text-red-400 hover:text-red-600">
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleDelete}
|
||||||
|
disabled={pending}
|
||||||
|
className="text-xs"
|
||||||
|
style={{ color: "oklch(0.577 0.245 27.325)" }}
|
||||||
|
>
|
||||||
Удалить
|
Удалить
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
@@ -93,7 +128,7 @@ function SortableModule({
|
|||||||
|
|
||||||
export function SortableModules({ courseId, modules }: { courseId: string; modules: Module[] }) {
|
export function SortableModules({ courseId, modules }: { courseId: string; modules: Module[] }) {
|
||||||
const [items, setItems] = useState(modules);
|
const [items, setItems] = useState(modules);
|
||||||
const [, startTransition] = useTransition();
|
const [creating, startTransition] = useTransition();
|
||||||
|
|
||||||
const sensors = useSensors(useSensor(PointerSensor));
|
const sensors = useSensors(useSensor(PointerSensor));
|
||||||
|
|
||||||
@@ -116,7 +151,7 @@ export function SortableModules({ courseId, modules }: { courseId: string; modul
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-2">
|
||||||
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
||||||
<SortableContext items={items.map((m) => m.id)} strategy={verticalListSortingStrategy}>
|
<SortableContext items={items.map((m) => m.id)} strategy={verticalListSortingStrategy}>
|
||||||
{items.map((mod) => (
|
{items.map((mod) => (
|
||||||
@@ -126,12 +161,25 @@ export function SortableModules({ courseId, modules }: { courseId: string; modul
|
|||||||
</DndContext>
|
</DndContext>
|
||||||
|
|
||||||
{items.length === 0 && (
|
{items.length === 0 && (
|
||||||
<p className="text-sm text-slate-400 py-2">Модулей пока нет. Добавьте первый.</p>
|
<p className="text-sm py-3" style={{ color: "var(--muted-foreground)" }}>
|
||||||
|
Модулей пока нет. Добавьте первый.
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<form onSubmit={handleCreate} className="flex gap-2 pt-2">
|
<form onSubmit={handleCreate} className="flex gap-2 pt-3">
|
||||||
<Input name="title" placeholder="Название нового модуля" required className="max-w-xs" />
|
<input
|
||||||
<Button type="submit">+ Модуль</Button>
|
name="title"
|
||||||
|
placeholder="Название нового модуля"
|
||||||
|
required
|
||||||
|
disabled={creating}
|
||||||
|
className="flex-1 max-w-xs px-3 py-2 text-sm"
|
||||||
|
style={{ border: "2px solid var(--border)", background: "var(--background)", outline: "none" }}
|
||||||
|
onFocus={(e) => (e.currentTarget.style.borderColor = "var(--foreground)")}
|
||||||
|
onBlur={(e) => (e.currentTarget.style.borderColor = "var(--border)")}
|
||||||
|
/>
|
||||||
|
<button type="submit" disabled={creating} className="btn-aubade text-xs px-4 py-2">
|
||||||
|
{creating ? "Создание..." : "+ Модуль"}
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user