from  fastapi import APIRouter,Depends

from core.security.authentication import get_user
from schema import GenericResponse
from schema.parent import ParentProfile
from schema.participant import ParticipantProfileUpdateSchema
from schema.user import GuestProfileSchema, StaffProfileUpdateSchema
from services.guest import GuestService
from services.parent import ParentService
from services.participant import ParticipantService
from services.staff import StaffService
from services.user import UserService

profile_router = APIRouter(prefix="/profile")

@profile_router.post("/parent/{parent_id}",response_model=GenericResponse)
async def parent_profile_update(parent_id:int,request:ParentProfile,user=Depends(get_user)):
    ParentService().update_profile(parent_id,request)
    return {"message": "Profile updated successfully"}


@profile_router.get("/parent/{parent_id}",response_model=GenericResponse)
async def get_parent_profile(parent_id:int,user=Depends(get_user)):
    data=ParentService().get_parent_profile(parent_id)
    return {"message": "Profile fetched successfully","data":data}


# Guest

@profile_router.post("/guest/{guest_id}",response_model=GenericResponse)
async def guest_profile_update(guest_id:int,request:GuestProfileSchema,user=Depends(get_user)):
    GuestService().update_profile(guest_id,request)
    return {"message": "Profile updated successfully"}

@profile_router.get("/guest/{guest_id}",response_model=GenericResponse)
async def get_guest_profile(guest_id:int,user=Depends(get_user)):
    data=GuestService().get_guest_profile(guest_id)
    return {"message": "Profile updated successfully","data":data}

@profile_router.post("/participant/{participant_id}",response_model=GenericResponse)
async def participant_profile_update(participant_id:int,request:ParticipantProfileUpdateSchema,user=Depends(get_user)):
    ParticipantService().update_participant_from_self_user(participant_id,request)
    return {"message": "Profile updated successfully"}


@profile_router.get("/participant/{participant_id}",response_model=GenericResponse)
async def get_participant_profile(participant_id:int,user=Depends(get_user)):
    data=ParticipantService().get_participant_profile(participant_id)
    return {"message": "Profile updated successfully","data":data}

@profile_router.post("/staff/{staff_id}",response_model=GenericResponse)
async def staff_profile_update(staff_id:int,request:StaffProfileUpdateSchema,user=Depends(get_user)):
    StaffService().update_staff_profile(staff_id,request)
    return {"message": "Profile updated successfully"}

@profile_router.get("/staff/{staff_id}",response_model=GenericResponse)
async def get_staff_profile_detail(staff_id:int,user=Depends(get_user)):
    data=StaffService().get_staff_profile_detail(staff_id)
    return {"message": "Profile fetched successfully","data":data}

