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

router = get_router()


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


@router.get("/api/content/live")
async def contingut(
    request: Request,
    logged_in: auth.LoggedIn,
):
    return await set_page.live(request, logged_in)


@router.get("/api/content/live/set")
async def get_set_page(
    request: Request,
    logged_in: auth.LoggedIn,
):
    return await set_page.live_set(request, logged_in)
