2023-10-05 10:47:29 +03:00
|
|
|
from fastapi import APIRouter, Depends
|
2023-11-14 16:31:02 +03:00
|
|
|
from middlewares.auth import (
|
|
|
|
get_current_user,
|
|
|
|
) # Assuming you have a get_current_user function
|
|
|
|
from middlewares.auth import AuthBearer
|
2023-10-05 12:31:26 +03:00
|
|
|
from models.databases.supabase.onboarding import (
|
2023-10-06 13:37:12 +03:00
|
|
|
OnboardingStates,
|
2023-10-05 12:31:26 +03:00
|
|
|
OnboardingUpdatableProperties,
|
|
|
|
)
|
2023-10-05 10:47:29 +03:00
|
|
|
from models.user_identity import UserIdentity
|
|
|
|
from repository.onboarding.get_user_onboarding import get_user_onboarding
|
2023-10-11 10:46:57 +03:00
|
|
|
from repository.onboarding.update_user_onboarding import update_user_onboarding
|
2023-10-05 10:47:29 +03:00
|
|
|
|
|
|
|
onboarding_router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
@onboarding_router.get(
|
|
|
|
"/onboarding",
|
|
|
|
dependencies=[Depends(AuthBearer())],
|
|
|
|
tags=["Onboarding"],
|
|
|
|
)
|
|
|
|
async def get_user_onboarding_handler(
|
|
|
|
current_user: UserIdentity = Depends(get_current_user),
|
2023-10-06 13:37:12 +03:00
|
|
|
) -> OnboardingStates | None:
|
2023-10-05 10:47:29 +03:00
|
|
|
"""
|
|
|
|
Get user onboarding information for the current user
|
|
|
|
"""
|
|
|
|
|
|
|
|
return get_user_onboarding(current_user.id)
|
|
|
|
|
|
|
|
|
|
|
|
@onboarding_router.put(
|
|
|
|
"/onboarding",
|
|
|
|
dependencies=[Depends(AuthBearer())],
|
|
|
|
tags=["Onboarding"],
|
|
|
|
)
|
|
|
|
async def update_user_onboarding_handler(
|
|
|
|
onboarding: OnboardingUpdatableProperties,
|
|
|
|
current_user: UserIdentity = Depends(get_current_user),
|
2023-10-06 13:37:12 +03:00
|
|
|
) -> OnboardingStates:
|
2023-10-05 10:47:29 +03:00
|
|
|
"""
|
|
|
|
Update user onboarding information for the current user
|
|
|
|
"""
|
|
|
|
|
|
|
|
return update_user_onboarding(current_user.id, onboarding)
|