from fastapi import Request
from folkugat_web.api import router
from folkugat_web.fragments import set_page
from folkugat_web.services import auth
from folkugat_web.templates import templates


@router.get("/sessio/{session_id}/set/{set_id}")
def page(
    request: Request,
    logged_in: auth.LoggedIn,
    session_id: int,
    set_id: int,
):
    return templates.TemplateResponse(
        "index.html",
        {
            "request": request,
            "page_title": "Folkugat",
            "content": f"/api/content/sessio/{session_id}/set/{set_id}",
            "logged_in": logged_in,
        }
    )


@router.get("/api/content/sessio/{session_id}/set/{set_id}")
def contingut(
    request: Request,
    logged_in: auth.LoggedIn,
    session_id: int,
    set_id: int,
):
    return set_page.pagina(request, session_id, set_id, logged_in)
