Skip to content

Commit

Permalink
Capitalize first letter on Signup, Mentor & Mentee Applications (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Disura-Randunu authored Sep 15, 2024
1 parent 2712f07 commit d1d6d7a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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: ''
})

Expand Down
8 changes: 7 additions & 1 deletion src/services/mentee.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { MenteeApplicationStatus } from '../enums'
import {
getEmailContent,
getMentorNotifyEmailContent,
getMenteePublicData
getMenteePublicData,
capitalizeFirstLetter
} from '../utils'
import { sendEmail } from './admin/email.service'

Expand Down Expand Up @@ -78,6 +79,11 @@ 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,
Expand Down
11 changes: 10 additions & 1 deletion src/services/mentor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { getEmailContent, getMentorPublicData } from '../utils'
import {
capitalizeFirstLetter,
getEmailContent,
getMentorPublicData
} from '../utils'
import { sendEmail } from './admin/email.service'

export const createMentor = async (
Expand Down Expand Up @@ -72,6 +76,11 @@ 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,
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,7 @@ export const getPasswordChangedEmailContent = (
`
}
}

export const capitalizeFirstLetter = (word: string): string => {
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
}

0 comments on commit d1d6d7a

Please sign in to comment.