from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session

from auth import get_current_user
from database import get_db
from models import User
from schemas import TranslateRequest, TranslateResponse
from services.translation_service import translation_service

router = APIRouter(prefix="/api", tags=["translate"])


@router.post("/translate", response_model=TranslateResponse)
def translate(
    data: TranslateRequest,
    db: Session = Depends(get_db),
    current_user: User = Depends(get_current_user),
):
    result = translation_service.translate(db, data.text)
    return TranslateResponse(**result)
