import React, { useState, useEffect } from 'react' import { Loader2, RefreshCw, Plus, X, Play, BookOpen, ChevronDown, ChevronUp } from 'lucide-react' function ProgressBar({ value, max }) { const pct = max > 0 ? Math.min(100, Math.round(value / max * 100)) : 0 const color = pct >= 80 ? '#3a7d5c' : pct >= 40 ? '#c8a84e' : '#4a5abf' return (
{value} / {max} 화 {pct}%
) } function NewNovelModal({ onClose, onCreated }) { const [form, setForm] = useState({ novel_id: '', title: '', title_ko: '', genre: '', setting: '', characters: '', base_story: '', publish_schedule: '매주 월/목 09:00', episode_count_target: 50, }) const [loading, setLoading] = useState(false) const [error, setError] = useState('') const handleSubmit = async (e) => { e.preventDefault() setLoading(true) setError('') try { const res = await fetch('/api/novels', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...form, episode_count_target: Number(form.episode_count_target) }), }) if (!res.ok) { const err = await res.json() throw new Error(err.detail || '생성 실패') } const data = await res.json() onCreated(data) onClose() } catch (e) { setError(e.message) } finally { setLoading(false) } } const field = (name, label, placeholder = '', type = 'text', rows = 0) => (
{rows > 0 ? (