from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select

from app.db.session import get_db
from app.schemas.user import UserResponse
from app.models.user import User

router = APIRouter()

# Ideiglenes mock user, amíg nincs JWT auth
async def get_mock_current_user_id():
    return 2  # Good Guy ID

@router.get("/me", response_model=UserResponse)
async def read_users_me(
    db: AsyncSession = Depends(get_db),
    user_id: int = Depends(get_mock_current_user_id)
):
    """Visszaadja a bejelentkezett felhasználó profilját (Hírnévvel!)"""
    result = await db.execute(select(User).where(User.id == user_id))
    user = result.scalars().first()
    
    if not user:
        raise HTTPException(status_code=404, detail="User not found")
        
    return user