From f1ff1253b764ff99dff3462d713e0fb1fb444e6a Mon Sep 17 00:00:00 2001 From: Devdeep Ghosh <63492939+thedevildude@users.noreply.github.com> Date: Thu, 9 May 2024 12:24:46 +0530 Subject: [PATCH] Changed WhatsApp message: doctor connect (#7715) * courtesyTitle function added * removed unncessary console.log * replaced genderSalutation with switch statement * fixes issues --------- Co-authored-by: rithviknishad --- src/Common/constants.tsx | 2 +- src/Components/Facility/DoctorVideoSlideover.tsx | 14 +++++++++++++- src/Components/Users/models.tsx | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index fd19ca85dc1..d552b882a34 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -335,7 +335,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 d2591bf3600..a77a1017b6b 100644 --- a/src/Components/Facility/DoctorVideoSlideover.tsx +++ b/src/Components/Facility/DoctorVideoSlideover.tsx @@ -19,6 +19,18 @@ const UserGroups = { TELEICU: "TeleICU Doctor", }; +const courtesyTitle = (user: UserAssignedModel) => { + if (user.user_type === "Doctor") { + return "Dr." as const; + } + + return { + 1: "Mr.", + 2: "Ms.", + 3: "Hey", + }[user.gender!]; +}; + type UserGroup = keyof typeof UserGroups; type UserAnnotatedWithGroup = UserAssignedModel & { group?: UserGroup }; @@ -161,7 +173,7 @@ function UserListItem({ user }: { user: UserAnnotatedWithGroup }) { 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}`; 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;