from fastapi import FastAPI
from fastapi.responses import RedirectResponse

from admin.routes import (
    bot_users,
    chat_log,
    intradesk_clients,
    organizations,
    org_users,
    sync,
    tickets,
)


def create_admin_app() -> FastAPI:
    app = FastAPI(title="Support Bot Admin")

    @app.get("/admin/")
    async def root():
        return RedirectResponse("/admin/orgs")

    app.include_router(organizations.router, prefix="/admin")
    app.include_router(org_users.router, prefix="/admin")
    app.include_router(bot_users.router, prefix="/admin")
    app.include_router(tickets.router, prefix="/admin")
    app.include_router(chat_log.router, prefix="/admin")
    app.include_router(sync.router, prefix="/admin")
    app.include_router(intradesk_clients.router, prefix="/admin")

    return app
