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

from src.webapps.admin import route_admin
from src.webapps.auth import route_login
from src.webapps.comic import route_comics, route_worktype, route_artists
from src.webapps.media import route_actors, route_media, route_videos

templates = Jinja2Templates(directory="src/templates")

api_router = APIRouter()
api_router.include_router(route_comics.router, tags=["webapp"])
api_router.include_router(route_artists.router, tags=["webapp"])
api_router.include_router(route_worktype.router, tags=["webapp"])
api_router.include_router(route_media.router, tags=["webapp"])
api_router.include_router(route_actors.router, tags=["webapp"])
api_router.include_router(route_videos.router, tags=["webapp"])
api_router.include_router(route_login.router, tags=["webapp"])
api_router.include_router(route_admin.router, tags=["webapp"])

@api_router.get("/", tags=["webapp"])
def home(request: Request, msg: str | None = None):
    return templates.TemplateResponse("index.html", {"request": request, "msg": msg})
