'use client'; /** * Панель выхода из LiveKit (выезжает справа, как на странице ДЗ): * 1) Выйти | Выйти и завершить занятие * 2) Если «завершить» — Выдать ДЗ? Да | Нет | Позже * 3) Если «Да» — форма: текст + файлы, кнопки Позже | Сохранить */ import React, { useState, useEffect } from 'react'; import { completeLesson, uploadLessonFile } from '@/api/schedule'; import { createHomework } from '@/api/homework'; const MAX_LESSON_FILES = 10; const MAX_FILE_SIZE_MB = 10; function formatSize(bytes: number): string { if (bytes >= 1024 * 1024) return `${(bytes / 1024 / 1024).toFixed(2)} МБ`; if (bytes >= 1024) return `${(bytes / 1024).toFixed(1)} КБ`; return `${bytes} Б`; } type FileKind = 'image' | 'video' | 'pdf' | 'other'; function getFileKind(file: File): FileKind { const t = file.type?.toLowerCase() ?? ''; const name = file.name.toLowerCase(); if (t.startsWith('image/') || /\.(jpe?g|png|gif|webp|bmp|svg|ico)$/i.test(name)) return 'image'; if (t.startsWith('video/') || /\.(mp4|webm|ogg|mov|avi|mkv)$/i.test(name)) return 'video'; if (t === 'application/pdf' || name.endsWith('.pdf')) return 'pdf'; return 'other'; } function FilePreviewChip({ file, onRemove, disabled }: { file: File; onRemove: () => void; disabled?: boolean }) { const kind = getFileKind(file); const [objectUrl, setObjectUrl] = useState(null); const name = file.name.length > 28 ? file.name.slice(0, 25) + '…' : file.name; useEffect(() => { if (kind === 'image' || kind === 'video' || kind === 'pdf') { const url = URL.createObjectURL(file); setObjectUrl(url); return () => URL.revokeObjectURL(url); } }, [file, kind]); const previewBlock = (() => { if (kind === 'image' && objectUrl) { return ( ); } if (kind === 'video' && objectUrl) { return (