import logging

from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates

logger = logging.getLogger(__name__)
router = APIRouter()
templates = Jinja2Templates(directory="app")


@router.get("/ordre/create/new", response_class=HTMLResponse)
async def ordre_create(request: Request):
    """Opret ny ordre (gammel funktionalitet)."""
    return templates.TemplateResponse("modules/orders/templates/create.html", {"request": request})


@router.get("/ordre/{draft_id}", response_class=HTMLResponse)
async def ordre_detail(request: Request, draft_id: int):
    """Detaljeret visning af en specifik ordre."""
    return templates.TemplateResponse("modules/orders/templates/detail.html", {
        "request": request,
        "draft_id": draft_id
    })


@router.get("/ordre", response_class=HTMLResponse)
async def ordre_index(request: Request):
    """Liste over alle ordre drafts."""
    return templates.TemplateResponse("modules/orders/templates/list.html", {"request": request})
