From c531031da78cadd08fa013df180c2774579ae528 Mon Sep 17 00:00:00 2001 From: Devdeep Ghosh Date: Fri, 26 Apr 2024 13:18:44 +0530 Subject: [PATCH 1/4] courtesyTitle function added --- src/Components/Facility/DoctorVideoSlideover.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Components/Facility/DoctorVideoSlideover.tsx b/src/Components/Facility/DoctorVideoSlideover.tsx index 5c1e421917a..ca1e05337c9 100644 --- a/src/Components/Facility/DoctorVideoSlideover.tsx +++ b/src/Components/Facility/DoctorVideoSlideover.tsx @@ -18,6 +18,14 @@ enum FilterTypes { TELEICU = "TeleICU Hub", } +const courtesyTitle = (user: UserAssignedModel) => { + /* TODO: Discuss courtesy title for gender number 2 appropirately */ + const genderSalutation = + user.gender === 0 ? "Mr" : user.gender === 1 ? "Ms" : "Hey"; + console.log(genderSalutation); + return user.user_type === "Doctor" ? "Dr" : genderSalutation; +}; + const isHomeUser = (user: UserAssignedModel, facilityId: string) => user.home_facility_object?.id === facilityId; @@ -128,7 +136,7 @@ function UserListItem(props: { user: UserAssignedModel; facilityId: string }) { e.stopPropagation(); if (!user.alt_phone_number) return; const phoneNumber = user.alt_phone_number; - const message = `Hey ${user.first_name} ${user.last_name}, I have a query regarding a patient.\n\nPatient Link: ${window.location.href}`; + const message = `${courtesyTitle(user)} ${user.first_name} ${user.last_name}, I have a query regarding a patient.\n\nPatient Link: ${window.location.href}`; const encodedMessage = encodeURIComponent(message); const whatsappAppURL = `whatsapp://send?phone=${phoneNumber}&text=${encodedMessage}`; const whatsappWebURL = `https://web.whatsapp.com/send?phone=${phoneNumber}&text=${encodedMessage}`; From 54e69474e10dda43e29c5cae4e2ebe45956e9e69 Mon Sep 17 00:00:00 2001 From: Devdeep Ghosh Date: Fri, 26 Apr 2024 13:27:46 +0530 Subject: [PATCH 2/4] removed unncessary console.log --- src/Components/Facility/DoctorVideoSlideover.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Facility/DoctorVideoSlideover.tsx b/src/Components/Facility/DoctorVideoSlideover.tsx index f23a18d553b..9e1e64bb610 100644 --- a/src/Components/Facility/DoctorVideoSlideover.tsx +++ b/src/Components/Facility/DoctorVideoSlideover.tsx @@ -22,7 +22,6 @@ const courtesyTitle = (user: UserAssignedModel) => { /* TODO: Discuss courtesy title for gender number 2 appropirately */ const genderSalutation = user.gender === 0 ? "Mr" : user.gender === 1 ? "Ms" : "Hey"; - console.log(genderSalutation); return user.user_type === "Doctor" ? "Dr" : genderSalutation; }; From 98afe0411b9fc118879d17f42f403e4bb9aa5235 Mon Sep 17 00:00:00 2001 From: Devdeep Ghosh Date: Tue, 30 Apr 2024 01:14:47 +0530 Subject: [PATCH 3/4] replaced genderSalutation with switch statement --- src/Components/Facility/DoctorVideoSlideover.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/DoctorVideoSlideover.tsx b/src/Components/Facility/DoctorVideoSlideover.tsx index 3f266fdd494..6969c55a51a 100644 --- a/src/Components/Facility/DoctorVideoSlideover.tsx +++ b/src/Components/Facility/DoctorVideoSlideover.tsx @@ -20,9 +20,17 @@ const UserGroups = { }; const courtesyTitle = (user: UserAssignedModel) => { - /* TODO: Discuss courtesy title for gender number 2 appropirately */ - const genderSalutation = - user.gender === 0 ? "Mr" : user.gender === 1 ? "Ms" : "Hey"; + let genderSalutation; + switch (user.gender) { + case 0: + genderSalutation = "Mr"; + break; + case 1: + genderSalutation = "Ms"; + break; + default: + genderSalutation = "Hey"; + } return user.user_type === "Doctor" ? "Dr" : genderSalutation; }; From e5150cf9fdaf60fdec6e1d7a5df0ca7431db741c Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 6 May 2024 17:22:57 +0530 Subject: [PATCH 4/4] 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;