"""Reusable job detail rendering helpers."""

from __future__ import annotations

from nicegui import ui

from transcription.models import Document
from transcription.models import Job
from transcription.models import Transcript


def render_job_detail(*, job: Job, document: Document | None, transcript: Transcript | None) -> None:
    """Render all sections for the job detail page."""
    ui.label(f"Job ID: {job.id}")
    ui.label(f"Status: {job.status.value}")
    ui.label(f"Created: {job.created_at.isoformat()}")
    ui.label(f"Updated: {job.updated_at.isoformat()}")

    if document is not None:
        ui.label(f"Filename: {document.filename}")
        ui.label(f"File path: {document.file_path}")

    if transcript is None:
        ui.label("Transcript not available yet.")
    elif transcript.text:
        ui.label("Transcript:")
        ui.markdown(transcript.text)
    elif transcript.error_detail:
        ui.label("Failure detail:")
        ui.label(transcript.error_detail)
