Skip to content

Commit

Permalink
fastapi-migration: Update Intake Profile endpoints
Browse files Browse the repository at this point in the history
Matches the Intake Profile endpoints on the frontend and backend.
  • Loading branch information
paulespinosa committed Sep 29, 2024
1 parent f969ac1 commit cc530ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
28 changes: 14 additions & 14 deletions backend/app/modules/intake_profile/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
router = APIRouter()


@router.put("/{intake_profile_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
def put_intake_profile(body, db_session: DbSessionDep):
@router.put("/responses/{user_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
def update_intake_profile_responses(user_id, body, db_session: DbSessionDep):
pass
# TODO: Implement update intake profile responses
# with db_session.begin() as session:
Expand All @@ -30,10 +30,10 @@ def put_intake_profile(body, db_session: DbSessionDep):
# return {}, 204


@router.get("/{intake_profile_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
def get_intake_profile(intake_profile_id, db_session: DbSessionDep):
@router.get("/responses/{user_id}", status_code=status.HTTP_501_NOT_IMPLEMENTED)
def get_intake_profile_responses(user_id, db_session: DbSessionDep):
pass
# TODO: Implement get Intake Profile
# TODO: Implement get Intake Profile responses
# with db_session.begin() as session:
# user_repo = UserRepository(session)
# forms_repo = FormsRepository(session)
Expand All @@ -49,15 +49,15 @@ def get_intake_profile(intake_profile_id, db_session: DbSessionDep):
# return [], 202


@router.get("/form/{form_id}", status_code=status.HTTP_200_OK)
def get_intake_profile_form(form_id: int,
form_1: Annotated[str, Depends(get_form_1)],
form_2: Annotated[str, Depends(get_form_2)]):
@router.get("/form/{profile_id}", status_code=status.HTTP_200_OK)
def get_intake_profile_form(profile_id: int,
profile_form_1: Annotated[str, Depends(get_form_1)],
profile_form_2: Annotated[str, Depends(get_form_2)]):
"""Get the Intake Profile form definition."""
if form_id == 1:
return form_1
if form_id == 2:
return form_2
if profile_id == 1:
return profile_form_1
if profile_id == 2:
return profile_form_2

raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail=f"Form with id {form_id} does not exist.")
detail=f"Form with id {profile_id} does not exist.")
4 changes: 2 additions & 2 deletions frontend/src/services/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ const injectedRtkApi = api.injectEndpoints({
endpoints: build => ({
getProfile: build.query<GetProfileApiResponse, GetProfileApiArg>({
query: queryArg => ({
url: `/profile/${queryArg.profileId}`,
url: `/intake-profile/form/${queryArg.profileId}`,
}),
}),
getResponses: build.query<
GetProfileResponsesApiResponse,
GetProfileResponsesApiArg
>({
query: queryArg => ({
url: `/profile/responses/${queryArg.userId}`,
url: `/intake-profile/responses/${queryArg.userId}`,
}),
}),
}),
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/testing/handlers/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface GetResponsesParams {
}

export const handlers = [
http.get('/api/profile/:profileId', req => {
http.get('/api/intake-profile/form/:profileId', req => {
const id = req.params.profileId;
const profile = intakeProfiles.find(p => p.id === id);

Expand All @@ -20,7 +20,7 @@ export const handlers = [
}),

http.get<GetResponsesParams, GetProfileResponsesApiResponse>(
'/api/profile/responses/:userId',
'/api/intake-profile/responses/:userId',
() => {
const fields = intakeProfiles[0].fieldGroups
.map(fieldGroup => fieldGroup.fields)
Expand Down

0 comments on commit cc530ec

Please sign in to comment.