from fastapi import FastAPI
from sqladmin import Admin

from app.database.session import engine
from app.home.api.home_admin import ImageAdmin, ProjectAdmin
from app.lyric.api.lyrics_admin import LyricAdmin
from app.song.api.song_admin import SongAdmin
from app.video.api.video_admin import VideoAdmin
from config import prj_settings

# https://github.com/aminalaee/sqladmin


def init_admin(
    app: FastAPI,
    db_engine: engine,
    base_url: str = prj_settings.ADMIN_BASE_URL,
) -> Admin:
    admin = Admin(
        app,
        db_engine,
        base_url=base_url,
    )

    # 프로젝트 관리
    admin.add_view(ProjectAdmin)
    admin.add_view(ImageAdmin)

    # 가사 관리
    admin.add_view(LyricAdmin)

    # 노래 관리
    admin.add_view(SongAdmin)

    # 영상 관리
    admin.add_view(VideoAdmin)

    return admin
