quivr/backend/modules/onboarding/controller/onboarding_routes.py
Zineb El Bachiri f578b2fa00
refactor: onboarding module (#1702)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2023-11-24 10:25:02 +01:00

45 lines
1.3 KiB
Python

from fastapi import APIRouter, Depends
from middlewares.auth import ( # Assuming you have a get_current_user function
AuthBearer,
get_current_user,
)
from modules.onboarding.dto.inputs import OnboardingUpdatableProperties
from modules.onboarding.entity.onboarding import OnboardingStates
from modules.onboarding.service.onboarding_service import OnboardingService
from modules.user.entity.user_identity import UserIdentity
onboarding_router = APIRouter()
onboardingService = OnboardingService()
@onboarding_router.get(
"/onboarding",
dependencies=[Depends(AuthBearer())],
tags=["Onboarding"],
)
async def get_user_onboarding_handler(
current_user: UserIdentity = Depends(get_current_user),
) -> OnboardingStates | None:
"""
Get user onboarding information for the current user
"""
return onboardingService.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),
) -> OnboardingStates:
"""
Update user onboarding information for the current user
"""
return onboardingService.update_user_onboarding(current_user.id, onboarding)