Skip to content

Commit

Permalink
feat(con): add new profile status (#845)
Browse files Browse the repository at this point in the history
* Add SUBMITTED_FOR_REVIEW status for CON profile

* Rename PENDING status to DRAFTING_PROFILE for ConnectProfileStatus
  • Loading branch information
katamatata authored Jan 25, 2024
1 parent 5fa596e commit 44aab1b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Injectable } from '@nestjs/common'
import { OnEvent } from '@nestjs/event-emitter'
import { ConnectProfileStatus, ConProfileEntity, UserType } from '@talent-connect/common-types'
import {
ConnectProfileStatus,
ConProfileEntity,
UserType,
} from '@talent-connect/common-types'
import {
ConProfileCreatedInternalEventDto,
ConProfileStatusChangedInternalEventDto,
SalesforceRecordEvents
SalesforceRecordEvents,
} from '@talent-connect/salesforce-record-events'
import { EmailService } from '../email/email.service'
import { ConProfilesService } from './con-profiles.service'
Expand All @@ -25,14 +29,14 @@ export class ConProfilesSalesforceEventHandlerService {
payload.conProfileId
)

const isStatusPendingToApproved =
payload.oldStatus === ConnectProfileStatus.PENDING &&
const isStatusDraftingToApproved =
payload.oldStatus === ConnectProfileStatus.DRAFTING_PROFILE &&
payload.newStatus === ConnectProfileStatus.APPROVED
const isStatusPendingToRejected =
payload.oldStatus === ConnectProfileStatus.PENDING &&
const isStatusDraftingToRejected =
payload.oldStatus === ConnectProfileStatus.DRAFTING_PROFILE &&
payload.newStatus === ConnectProfileStatus.REJECTED

if (isStatusPendingToApproved) {
if (isStatusDraftingToApproved) {
const conProfile = await this.service.findOneById(payload.conProfileId)
const updatedConProfileProps = Object.assign({}, conProfile.props, {
userActivatedAt: new Date().toISOString(),
Expand All @@ -43,13 +47,13 @@ export class ConProfilesSalesforceEventHandlerService {
const conProfile = await this.service.findOneById(payload.conProfileId)
switch (conProfile.props.userType) {
case UserType.MENTEE:
if (isStatusPendingToApproved)
if (isStatusDraftingToApproved)
this.emailService.sendMenteePendingReviewAcceptedEmail({
recipient: conProfile.props.email,
firstName: conProfile.props.firstName,
rediLocation: conProfile.props.rediLocation,
})
if (isStatusPendingToRejected)
if (isStatusDraftingToRejected)
this.emailService.sendPendingReviewDeclinedEmail({
recipient: conProfile.props.email,
firstName: conProfile.props.firstName,
Expand All @@ -58,13 +62,13 @@ export class ConProfilesSalesforceEventHandlerService {
break

case UserType.MENTOR:
if (isStatusPendingToApproved)
if (isStatusDraftingToApproved)
this.emailService.sendMentorPendingReviewAcceptedEmail({
recipient: conProfile.props.email,
firstName: conProfile.props.firstName,
rediLocation: conProfile.props.rediLocation,
})
if (isStatusPendingToRejected)
if (isStatusDraftingToRejected)
this.emailService.sendPendingReviewDeclinedEmail({
recipient: conProfile.props.email,
firstName: conProfile.props.firstName,
Expand All @@ -87,7 +91,7 @@ export class ConProfilesSalesforceEventHandlerService {
this.emailService.sendMenteeSignupCompleteEmail({
recipient: conProfile.props.email,
firstName: conProfile.props.firstName,
rediLocation: conProfile.props.rediLocation
rediLocation: conProfile.props.rediLocation,
})
break

Expand Down
4 changes: 2 additions & 2 deletions apps/nestjs-api/src/con-profiles/con-profiles.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable, NotFoundException } from '@nestjs/common'
import {
ConnectProfileStatus,
ConProfileEntity,
ConProfileMapper,
ConnectProfileStatus,
UserType,
} from '@talent-connect/common-types'
import { deleteUndefinedProperties } from '@talent-connect/shared-utils'
Expand All @@ -26,7 +26,7 @@ export class ConProfilesService {
return await this.api.createConProfileForSignUp({
userId: user.userId,
loopbackUserId: user.loopbackUserId,
profileStatus: ConnectProfileStatus.PENDING,
profileStatus: ConnectProfileStatus.DRAFTING_PROFILE,
rediLocation: input.rediLocation,
userType: input.userType,
menteeCountCapacity: input.userType === UserType.MENTOR ? 1 : 0,
Expand Down
3 changes: 2 additions & 1 deletion apps/redi-connect/src/components/organisms/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const SideMenu = () => {
const isMentee = profile?.userType === UserType.Mentee

const isActivated = profile?.profileStatus === ConnectProfileStatus.Approved
const isNotPending = profile?.profileStatus !== ConnectProfileStatus.Pending
const isNotDrafting =
profile?.profileStatus !== ConnectProfileStatus.DraftingProfile

const isActivatedMentor = isMentor && isActivated

Expand Down
6 changes: 4 additions & 2 deletions apps/redi-connect/src/components/templates/LoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ function LoggedIn({ children }: Props) {
className="column--main-content"
>
{profile?.userType === 'MENTEE' &&
profile?.profileStatus === ConnectProfileStatus.Pending && (
profile?.profileStatus ===
ConnectProfileStatus.DraftingProfile && (
<RediNotification>
{t('loggedInArea.profile.notification.pendingMentee')}
</RediNotification>
)}
{profile?.userType === 'MENTOR' &&
profile?.profileStatus === ConnectProfileStatus.Pending && (
profile?.profileStatus ===
ConnectProfileStatus.DraftingProfile && (
<RediNotification>
{t('loggedInArea.profile.notification.pendingMentor')}
</RediNotification>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { registerEnumType } from '@nestjs/graphql'

export enum ConnectProfileStatus {
PENDING = 'PENDING',
DRAFTING_PROFILE = 'DRAFTING_PROFILE',
SUBMITTED_FOR_REVIEW = 'SUBMITTED_FOR_REVIEW',
APPROVED = 'APPROVED',
REJECTED = 'REJECTED',
DEACTIVATED = 'DEACTIVATED',
Expand Down
5 changes: 3 additions & 2 deletions libs/data-access/src/lib/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ export type ConProfileSignUpInput = {
export enum ConnectProfileStatus {
Approved = 'APPROVED',
Deactivated = 'DEACTIVATED',
Pending = 'PENDING',
Rejected = 'REJECTED'
DraftingProfile = 'DRAFTING_PROFILE',
Rejected = 'REJECTED',
SubmittedForReview = 'SUBMITTED_FOR_REVIEW'
}

export type CreateConMentoringSessionInput = {
Expand Down
3 changes: 2 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ input ConProfileSignUpInput {
enum ConnectProfileStatus {
APPROVED
DEACTIVATED
PENDING
DRAFTING_PROFILE
REJECTED
SUBMITTED_FOR_REVIEW
}

input CreateConMentoringSessionInput {
Expand Down

0 comments on commit 44aab1b

Please sign in to comment.