from fastapi import Request
from folkugat_web.model import temes as model
from folkugat_web.templates import templates


def link(request: Request, logged_in: bool, link: model.Link):
    return templates.TemplateResponse(
        "fragments/tema/link.html",
        {
            "request": request,
            "logged_in": logged_in,
            "link": link,
            "LinkType": model.LinkType,
            "ContentType": model.ContentType,
        },
        headers={
            "HX-Trigger": f"reload-tema-{link.tema_id}-score"
        }
    )


def link_editor(request: Request, logged_in: bool, link: model.Link):
    return templates.TemplateResponse(
        "fragments/tema/editor/link.html",
        {
            "request": request,
            "logged_in": logged_in,
            "link": link,
            "LinkType": model.LinkType,
            "ContentType": model.ContentType,
        }
    )


def link_editor_url(request: Request, logged_in: bool, link: model.Link):
    return templates.TemplateResponse(
        "fragments/tema/editor/link_url.html",
        {
            "request": request,
            "logged_in": logged_in,
            "link": link,
            "LinkType": model.LinkType,
            "ContentType": model.ContentType,
        }
    )


def link_editor_file(request: Request, logged_in: bool, link: model.Link):
    return templates.TemplateResponse(
        "fragments/tema/editor/link_file.html",
        {
            "request": request,
            "logged_in": logged_in,
            "link": link,
            "LinkType": model.LinkType,
            "ContentType": model.ContentType,
        }
    )


def link_icon(request: Request, logged_in: bool, link: model.Link):
    return templates.TemplateResponse(
        "fragments/tema/link_icon.html",
        {
            "request": request,
            "logged_in": logged_in,
            "link": link,
            "LinkType": model.LinkType,
            "ContentType": model.ContentType,
        }
    )


def score(request: Request, logged_in: bool, tema: model.Tema):
    return templates.TemplateResponse(
        "fragments/tema/score.html",
        {
            "request": request,
            "logged_in": logged_in,
            "tema": tema,
            "LinkType": model.LinkType,
        }
    )
