From 0f71d70099433860610b63b972567a34a9349dc1 Mon Sep 17 00:00:00 2001 From: Disura Randunu Date: Sun, 15 Sep 2024 13:38:34 +0530 Subject: [PATCH 1/2] Capitalize first letter on Signup, Mentor & Mentee Applications --- src/services/auth.service.ts | 5 +++-- src/services/mentee.service.ts | 6 +++++- src/services/mentor.service.ts | 5 ++++- src/utils.ts | 6 ++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/services/auth.service.ts b/src/services/auth.service.ts index b478e984..3c0eb501 100644 --- a/src/services/auth.service.ts +++ b/src/services/auth.service.ts @@ -5,6 +5,7 @@ import { JWT_SECRET } from '../configs/envConfig' import Profile from '../entities/profile.entity' import { type CreateProfile, type ApiResponse } from '../types' import { + capitalizeFirstLetter, getPasswordChangedEmailContent, getPasswordResetEmailContent } from '../utils' @@ -35,8 +36,8 @@ export const registerUser = async ( const newProfile = profileRepository.create({ primary_email: email, password: hashedPassword, - first_name, - last_name, + first_name: capitalizeFirstLetter(first_name), + last_name: capitalizeFirstLetter(last_name), image_url: '' }) diff --git a/src/services/mentee.service.ts b/src/services/mentee.service.ts index c9912ff2..d7220037 100644 --- a/src/services/mentee.service.ts +++ b/src/services/mentee.service.ts @@ -6,7 +6,8 @@ import { MenteeApplicationStatus } from '../enums' import { getEmailContent, getMentorNotifyEmailContent, - getMenteePublicData + getMenteePublicData, + capitalizeFirstLetter } from '../utils' import { sendEmail } from './admin/email.service' @@ -78,6 +79,9 @@ export const addMentee = async ( } } + application.firstName = capitalizeFirstLetter(application.firstName as string) + application.lastName = capitalizeFirstLetter(application.lastName as string) + const newMentee = new Mentee( MenteeApplicationStatus.PENDING, application, diff --git a/src/services/mentor.service.ts b/src/services/mentor.service.ts index 9178fc54..9cd6794c 100644 --- a/src/services/mentor.service.ts +++ b/src/services/mentor.service.ts @@ -5,7 +5,7 @@ import Mentor from '../entities/mentor.entity' import type Profile from '../entities/profile.entity' import { MentorApplicationStatus } from '../enums' import { type PaginatedApiResponse } from '../types' -import { getEmailContent, getMentorPublicData } from '../utils' +import { capitalizeFirstLetter, getEmailContent, getMentorPublicData } from '../utils' import { sendEmail } from './admin/email.service' export const createMentor = async ( @@ -72,6 +72,9 @@ export const createMentor = async ( } } + application.firstName = capitalizeFirstLetter(application.firstName as string) + application.lastName = capitalizeFirstLetter(application.lastName as string) + const newMentor = new Mentor( MentorApplicationStatus.PENDING, category, diff --git a/src/utils.ts b/src/utils.ts index a7f30f66..5b4a1f21 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -286,3 +286,9 @@ export const getPasswordChangedEmailContent = ( ` } } + +export const capitalizeFirstLetter = ( + word: string +): string => { + return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() +} \ No newline at end of file From 98ad512a26048ebbe013de756e5f9dbdfc063c30 Mon Sep 17 00:00:00 2001 From: Disura Randunu Date: Sun, 15 Sep 2024 16:46:56 +0530 Subject: [PATCH 2/2] lint issues fixed --- src/services/mentee.service.ts | 6 ++++-- src/services/mentor.service.ts | 10 ++++++++-- src/utils.ts | 6 ++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/services/mentee.service.ts b/src/services/mentee.service.ts index d7220037..d16c8541 100644 --- a/src/services/mentee.service.ts +++ b/src/services/mentee.service.ts @@ -79,9 +79,11 @@ export const addMentee = async ( } } - application.firstName = capitalizeFirstLetter(application.firstName as string) + application.firstName = capitalizeFirstLetter( + application.firstName as string + ) application.lastName = capitalizeFirstLetter(application.lastName as string) - + const newMentee = new Mentee( MenteeApplicationStatus.PENDING, application, diff --git a/src/services/mentor.service.ts b/src/services/mentor.service.ts index 9cd6794c..dd7f4fa0 100644 --- a/src/services/mentor.service.ts +++ b/src/services/mentor.service.ts @@ -5,7 +5,11 @@ import Mentor from '../entities/mentor.entity' import type Profile from '../entities/profile.entity' import { MentorApplicationStatus } from '../enums' import { type PaginatedApiResponse } from '../types' -import { capitalizeFirstLetter, getEmailContent, getMentorPublicData } from '../utils' +import { + capitalizeFirstLetter, + getEmailContent, + getMentorPublicData +} from '../utils' import { sendEmail } from './admin/email.service' export const createMentor = async ( @@ -72,7 +76,9 @@ export const createMentor = async ( } } - application.firstName = capitalizeFirstLetter(application.firstName as string) + application.firstName = capitalizeFirstLetter( + application.firstName as string + ) application.lastName = capitalizeFirstLetter(application.lastName as string) const newMentor = new Mentor( diff --git a/src/utils.ts b/src/utils.ts index 5b4a1f21..839e4232 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -287,8 +287,6 @@ export const getPasswordChangedEmailContent = ( } } -export const capitalizeFirstLetter = ( - word: string -): string => { +export const capitalizeFirstLetter = (word: string): string => { return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() -} \ No newline at end of file +}