From e5150cf9fdaf60fdec6e1d7a5df0ca7431db741c Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 6 May 2024 17:22:57 +0530 Subject: [PATCH] fixes issues --- src/Common/constants.tsx | 2 +- .../Facility/DoctorVideoSlideover.tsx | 19 ++++++++----------- src/Components/Users/models.tsx | 4 ++-- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 07768a16cee..426ac12198f 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -354,7 +354,7 @@ export const GENDER_TYPES = [ { id: 1, text: "Male", icon: "M" }, { id: 2, text: "Female", icon: "F" }, { id: 3, text: "Transgender", icon: "TRANS" }, -]; +] as const; export const SAMPLE_TEST_RESULT = [ { id: 1, text: "POSITIVE" }, diff --git a/src/Components/Facility/DoctorVideoSlideover.tsx b/src/Components/Facility/DoctorVideoSlideover.tsx index 6969c55a51a..a77a1017b6b 100644 --- a/src/Components/Facility/DoctorVideoSlideover.tsx +++ b/src/Components/Facility/DoctorVideoSlideover.tsx @@ -20,18 +20,15 @@ const UserGroups = { }; const courtesyTitle = (user: UserAssignedModel) => { - let genderSalutation; - switch (user.gender) { - case 0: - genderSalutation = "Mr"; - break; - case 1: - genderSalutation = "Ms"; - break; - default: - genderSalutation = "Hey"; + if (user.user_type === "Doctor") { + return "Dr." as const; } - return user.user_type === "Doctor" ? "Dr" : genderSalutation; + + return { + 1: "Mr.", + 2: "Ms.", + 3: "Hey", + }[user.gender!]; }; type UserGroup = keyof typeof UserGroups; diff --git a/src/Components/Users/models.tsx b/src/Components/Users/models.tsx index b0ef2b909cd..4aa315ea6f9 100644 --- a/src/Components/Users/models.tsx +++ b/src/Components/Users/models.tsx @@ -1,4 +1,4 @@ -import { UserRole } from "../../Common/constants"; +import { GENDER_TYPES, UserRole } from "../../Common/constants"; import { DistrictModel, LocalBodyModel, StateModel } from "../Facility/models"; interface HomeFacilityObjectModel { @@ -64,7 +64,7 @@ export interface UserAssignedModel extends UserBareMinimum { phone_number?: string; alt_phone_number?: string; video_connect_link: string; - gender?: number; + gender?: (typeof GENDER_TYPES)[number]["id"]; date_of_birth: Date | null; is_superuser?: boolean; verified?: boolean;