""" Client endpoints for viewing organization info. """ from typing import Annotated from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.ext.asyncio import AsyncSession from app.api.deps import get_current_user from app.core.database import get_db from app.models.user import User from app.schemas.organization import OrganizationResponse from app.services import organization_service router = APIRouter() @router.get("/me", response_model=OrganizationResponse) async def get_my_organization( db: Annotated[AsyncSession, Depends(get_db)], current_user: Annotated[User, Depends(get_current_user)], ): """ Get current user's organization. Returns organization details for the current user. """ if not current_user.organization_id: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail="User is not assigned to any organization", ) org = await organization_service.get_organization( db, current_user.organization_id ) if not org: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail="Organization not found", ) return org