from __future__ import annotations

from fastapi import APIRouter, Depends

from backend.app.api.schemas import (
    BookmarkCreateRequest,
    BookmarkDeleteResponse,
    BookmarkItem,
    BookmarkListResponse,
)
from backend.app.dependencies import get_bookmark_service
from backend.app.services.bookmark_service import BookmarkService

router = APIRouter(prefix="/bookmarks")


@router.post("", response_model=BookmarkItem)
async def create_bookmark(
    request: BookmarkCreateRequest,
    service: BookmarkService = Depends(get_bookmark_service),
) -> BookmarkItem:
    return service.create_bookmark(path=request.path, label=request.label)


@router.get("", response_model=BookmarkListResponse)
async def list_bookmarks(service: BookmarkService = Depends(get_bookmark_service)) -> BookmarkListResponse:
    return service.list_bookmarks()


@router.delete("/{bookmark_id}", response_model=BookmarkDeleteResponse)
async def delete_bookmark(
    bookmark_id: int,
    service: BookmarkService = Depends(get_bookmark_service),
) -> BookmarkDeleteResponse:
    return service.delete_bookmark(bookmark_id)
