from pathlib import Path

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


router = APIRouter()
templates = Jinja2Templates(directory=str(Path(__file__).resolve().parent.parent / "templates"))


@router.get("/", response_class=HTMLResponse)
async def dashboard(request: Request):
    return templates.TemplateResponse("dashboard.html", {"request": request, "title": "Doris Kitchen"})


@router.get("/search", response_class=HTMLResponse)
async def search(request: Request):
    return templates.TemplateResponse("search.html", {"request": request, "title": "Recipe Search"})


@router.get("/planner", response_class=HTMLResponse)
async def planner_page(request: Request):
    return templates.TemplateResponse("planner.html", {"request": request, "title": "Meal Planner"})


@router.get("/failures", response_class=HTMLResponse)
async def failures_page(request: Request):
    return templates.TemplateResponse("failures.html", {"request": request, "title": "Failed Searches"})


@router.get("/imports", response_class=HTMLResponse)
async def imports_page(request: Request):
    return templates.TemplateResponse("imports.html", {"request": request, "title": "Import Review"})
