Skip to content

Commit

Permalink
refactor: assessment types
Browse files Browse the repository at this point in the history
  • Loading branch information
RRanath committed Sep 10, 2024
1 parent 66affd3 commit 2ebe0b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
15 changes: 2 additions & 13 deletions app/backend/lib/emails/templates/assesmentSecondReviewChange.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
import ASSESSMENT_TYPES from 'data/assessmentTypes';
import {
EmailTemplate,
EmailTemplateProvider,
} from '../handleEmailNotification';

const formats = {
projectManagement: {
type: 'Project Management assessment',
slug: 'project-management',
},
permitting: { type: 'Permitting assessment', slug: 'permitting' },
technical: { type: 'Technical assessment', slug: 'technical' },
gis: { type: 'GIS assessment', slug: 'gis' },
financialRisk: { type: 'Financial Risk assessment', slug: 'financial-risk' },
screening: { type: 'Eligibility Screening', slug: 'screening' },
};

const assesmentSecondReviewChange: EmailTemplateProvider = (
applicationId: string,
url: string,
initiator: any,
params: any
): EmailTemplate => {
const { ccbcNumber, assessmentType } = params;
const { type, slug } = formats[assessmentType];
const { type, slug } = ASSESSMENT_TYPES[assessmentType];

return {
emailTo: [34, 71], // Temporary IDs to handle email recipients
Expand Down
8 changes: 2 additions & 6 deletions app/backend/lib/emails/templates/assessmentAssigneeChange.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Context } from 'backend/lib/ches/sendEmailMerge';

import ASSESSMENT_TYPES from 'data/assessmentTypes';
import {
EmailTemplate,
EmailTemplateProvider,
Expand All @@ -20,11 +21,6 @@ const getCCBCUsersByIds = `
}
`;

const ASSESSMENT_TYPES = {
technical: 'Technical Assessment',
financialRisk: 'Financial Risk Assessment',
};

// Return users by their row IDs
const getUsers = async (ids: number[], req: any) => {
const results = await performQuery(getCCBCUsersByIds, { _rowIds: ids }, req);
Expand Down Expand Up @@ -83,7 +79,7 @@ const assessmentAssigneeChange: EmailTemplateProvider = async (
const alerts = (assignments as Array<any>).map((assignment) => {
return {
url: `${url}/analyst/application/${assignment.applicationId}/assessments/${assignment.assessmentType}`,
type: ASSESSMENT_TYPES[assignment.assessmentType],
type: ASSESSMENT_TYPES[assignment.assessmentType]?.type,
ccbcNumber: assignment.ccbcNumber,
applicationId: assignment.applicationId,
};
Expand Down
13 changes: 13 additions & 0 deletions app/data/assessmentTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const ASSESSMENT_TYPES = {
projectManagement: {
type: 'Project Management assessment',
slug: 'project-management',
},
permitting: { type: 'Permitting assessment', slug: 'permitting' },
technical: { type: 'Technical assessment', slug: 'technical' },
gis: { type: 'GIS assessment', slug: 'gis' },
financialRisk: { type: 'Financial Risk assessment', slug: 'financial-risk' },
screening: { type: 'Eligibility Screening', slug: 'screening' },
};

export default ASSESSMENT_TYPES;

0 comments on commit 2ebe0b8

Please sign in to comment.