from pathlib import Path
from typing import NamedTuple

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

from ..common.utils.template import build_templates


class Section(NamedTuple):
    link: str
    title: str
    icon: str


SECTIONS = [
    Section("weather", "Weather", "brightness-high"),
    Section("schedule", "TV program", "tv"),
]

base_dir = Path(__file__).parent

router = APIRouter()

templates = build_templates(Path(__file__).parent / "templates")


@router.get("/", response_class=HTMLResponse)
async def get_section_list(request: Request):
    return templates.TemplateResponse(
        request=request,
        name="root_index.html",
        context={
            "sections": SECTIONS,
        },
    )
