import React, { useEffect, useState } from "react"; import { api, subscribeState } from "./api.js"; import { StatusChip, ProgressBar, Spinner } from "./ui.jsx"; import Chapters from "./Chapters.jsx"; import AnalysisEditor from "./AnalysisEditor.jsx"; import CastEditor from "./CastEditor.jsx"; import PronunciationEditor from "./PronunciationEditor.jsx"; const STAGES = [ { key: "analyze", label: "Analyse", action: (s) => api.analyze(s), hint: "Découpe le texte, détecte les locuteurs et le casting." }, { key: "cast", label: "Casting", action: (s) => api.castAuto(s), hint: "Attribue une voix à chaque personnage." }, { key: "pronounce", label: "Prononciations", action: (s) => api.pronounce(s), hint: "Repère les mots à risque de mauvaise prononciation." }, ]; export default function BookView({ slug, onBack }) { const [data, setData] = useState(null); const [state, setState] = useState(null); const [tab, setTab] = useState("chapters"); useEffect(() => { api.getBook(slug).then((d) => { setData(d); setState(d.state); }); const unsub = subscribeState(slug, setState); return unsub; }, [slug]); if (!data) return

chargement…

; const { book } = data; const st = state || data.state; const busy = !!st.active_stage; return (
{book.cover_file && ( )}

{book.title}

{book.author}

{book.chapters.filter((c) => c.render).length} chapitres à narrer

{busy && (
{st.active_detail || st.active_stage} {Math.round((st.active_progress || 0) * 100)}%
)}
{/* Pipeline */}
{STAGES.map((stage) => { const status = st.stages?.[stage.key] || "pending"; return (
{stage.label}

{stage.hint}

); })}
{/* Onglets */}
{[ ["chapters", "Chapitres"], ["analysis", "Analyse"], ["cast", "Casting"], ["pron", "Prononciation"], ].map(([key, label]) => ( ))}
{tab === "chapters" && } {tab === "analysis" && } {tab === "cast" && } {tab === "pron" && }
); }