From 0713973671ff29cfc401649a5af2fcdaed137cda Mon Sep 17 00:00:00 2001 From: David MENDY Date: Fri, 9 Aug 2024 16:38:07 +0200 Subject: [PATCH] refactor: :recycle: use env variable for contact numbers --- backend/src/config.py | 4 ++ backend/src/router.py | 9 ++- frontend/src/api/api-client.ts | 10 +++ frontend/src/api/api-routes.ts | 1 + .../GuideContactExpert/ExpertSituation.vue | 61 +++++++++++++++---- 5 files changed, 71 insertions(+), 14 deletions(-) diff --git a/backend/src/config.py b/backend/src/config.py index d95433058..068ec3b18 100644 --- a/backend/src/config.py +++ b/backend/src/config.py @@ -148,3 +148,7 @@ def get_base_logs(user_agent, user_id: str) -> dict: ) OAUTH2_SCHEME = OpenIdConnect(openIdConnectUrl=os.environ["OIDC_CONFIG_URL"]) + +# Phone numbers +PHONE_NUMBER = os.environ.get("IRCGN_PHONE") +CELLPHONE_NUMBER = os.environ.get("IRCGN_CELLPHONE") diff --git a/backend/src/router.py b/backend/src/router.py index 2add27ae0..64374a887 100644 --- a/backend/src/router.py +++ b/backend/src/router.py @@ -21,7 +21,8 @@ from fastapi.responses import PlainTextResponse from user_agents import parse -from .config import APP_VERSION, S3_PREFIX, TYPOLOGIES_MEASURED, get_base_logs +from .config import APP_VERSION, S3_PREFIX, TYPOLOGIES_MEASURED, get_base_logs, PHONE_NUMBER, CELLPHONE_NUMBER +from .models import EmailData from .utils import get_current_user, send_mail, upload_image router = APIRouter(prefix="/api") @@ -36,6 +37,12 @@ def home(): def version(): return APP_VERSION +@router.get("/contact-details") +async def phone_number( + current_user: Annotated[dict, Depends(get_current_user)], +): + return PHONE_NUMBER, CELLPHONE_NUMBER + @router.post("/upload") async def imageupload( diff --git a/frontend/src/api/api-client.ts b/frontend/src/api/api-client.ts index 99900ce7b..df39c7b55 100644 --- a/frontend/src/api/api-client.ts +++ b/frontend/src/api/api-client.ts @@ -6,6 +6,7 @@ import { IDENTIFICATION_FEEDBACK_ROUTE, TUTORIAL_FEEDBACK_ROUTE, UPLOAD_PHOTO_FOR_DETECTION_ROUTE, + GET_IRCGN_NUMBERS_ROUTE, } from "./api-routes"; export const uploadPhotoForDetection = async (file: File) => { @@ -46,3 +47,12 @@ export const sendExpertiseForm = async (data: any, accessToken: string) => { }, }); }; + +export const getContactDetails = async (accessToken: string) => { + const { data } = await axios.get(GET_IRCGN_NUMBERS_ROUTE, { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); + return data; +}; diff --git a/frontend/src/api/api-routes.ts b/frontend/src/api/api-routes.ts index f134236c8..9d9eb42f8 100644 --- a/frontend/src/api/api-routes.ts +++ b/frontend/src/api/api-routes.ts @@ -3,3 +3,4 @@ export const TUTORIAL_FEEDBACK_ROUTE = "/tutorial-feedback"; export const IDENTIFICATION_FEEDBACK_ROUTE = "/identification-feedback"; export const IDENTIFICATION_DUMMY_ROUTE = "/identification-dummy"; export const ASK_FOR_OPINION_ROUTE = "/expert-contact"; +export const GET_IRCGN_NUMBERS_ROUTE = "/contact-details"; diff --git a/frontend/src/views/GuideContactExpert/ExpertSituation.vue b/frontend/src/views/GuideContactExpert/ExpertSituation.vue index b4037a0de..8577a62e6 100644 --- a/frontend/src/views/GuideContactExpert/ExpertSituation.vue +++ b/frontend/src/views/GuideContactExpert/ExpertSituation.vue @@ -1,19 +1,54 @@