Skip to content

Commit

Permalink
use applicantrole enum instead of str
Browse files Browse the repository at this point in the history
  • Loading branch information
Jess2772 committed Nov 15, 2023
1 parent 96ba897 commit 99e0779
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
9 changes: 5 additions & 4 deletions backend/typescript/graphql/resolvers/dashboardResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ApplicationDTO,
ApplicationDashboardInput,
ApplicationDashboardRowDTO,
ApplicantRole
} from "../../types";

const dashboardService: IAppDashboardService = new AppDashboardService();
Expand All @@ -20,7 +21,7 @@ const dashboardResolvers = {
},
applicationsByRole: async (
_parent: undefined,
{ firstChoice }: { firstChoice: string },
{ firstChoice }: { firstChoice: ApplicantRole },
): Promise<Array<ApplicationDTO>> => {
const applications = await dashboardService.getApplicationsByRole(
firstChoice,
Expand All @@ -29,7 +30,7 @@ const dashboardResolvers = {
},
applicationsBySecondChoiceRole: async (
_parent: undefined,
{ secondChoice }: { secondChoice: string },
{ secondChoice }: { secondChoice: ApplicantRole },
): Promise<Array<ApplicationDTO>> => {
const applications = await dashboardService.getApplicationsBySecondChoiceRole(
secondChoice,
Expand All @@ -47,13 +48,13 @@ const dashboardResolvers = {
},
applicationTable: async (
_parent: undefined,
{ role }: { role: string },
{ role }: { role: ApplicantRole },
): Promise<ApplicationDashboardRowDTO[]> => {
return dashboardService.getApplicationDashboardTable(role);
},
secondChoiceRoleApplicationTable: async (
_parent: undefined,
{ role }: { role: string },
{ role }: { role: ApplicantRole },
): Promise<ApplicationDashboardRowDTO[]> => {
return dashboardService.getApplicationBySecondChoiceRoleDashboardTable(role);
},
Expand Down
2 changes: 1 addition & 1 deletion backend/typescript/models/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Column, DataType, HasMany, Model, Table } from "sequelize-typescript";
import ApplicationDashboardTable from "./applicationDashboard.model";
import { DataTypes, Sequelize } from "sequelize";
import { statusType, secondChoiceStatusType } from "../types";
import { statusType, secondChoiceStatusType, ApplicantRole } from "../types";


@Table({ tableName: "applicantresponse" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ApplicationDTO,
ApplicationDashboardRowDTO,
UserDTO,
ApplicantRole
} from "../../types";
import { getErrorMessage } from "../../utilities/errorUtils";
import logger from "../../utilities/logger";
Expand Down Expand Up @@ -54,7 +55,7 @@ class AppDashboardService implements IAppDashboardService {
};
}

async getApplicationsByRole(role: string): Promise<Array<ApplicationDTO>> {
async getApplicationsByRole(role: ApplicantRole): Promise<Array<ApplicationDTO>> {
let applications: Array<Application> | null;
let applicationsByRole: Array<Application> | null;
let applicationsByRoleDTO: Array<ApplicationDTO> = [];
Expand Down Expand Up @@ -99,7 +100,7 @@ class AppDashboardService implements IAppDashboardService {
return applicationsByRoleDTO;
}

async getApplicationsBySecondChoiceRole(role: string): Promise<Array<ApplicationDTO>> {
async getApplicationsBySecondChoiceRole(role: ApplicantRole): Promise<Array<ApplicationDTO>> {
let applications: Array<Application> | null;
let applicationsBySecondChoiceRole: Array<Application> | null;
let applicationsBySecondChoiceRoleDTO: Array<ApplicationDTO> = [];
Expand Down Expand Up @@ -180,7 +181,7 @@ class AppDashboardService implements IAppDashboardService {
}

async getApplicationDashboardTable(
role: string,
role: ApplicantRole,
): Promise<ApplicationDashboardRowDTO[]> {
// get all the applications for the role
const applications: Array<ApplicationDTO> = await this.getApplicationsByRole(
Expand Down Expand Up @@ -208,7 +209,7 @@ class AppDashboardService implements IAppDashboardService {
}

async getApplicationBySecondChoiceRoleDashboardTable(
role: string,
role: ApplicantRole,
): Promise<ApplicationDashboardRowDTO[]> {
// get all the applications for the role
const applications: Array<ApplicationDTO> = await this.getApplicationsBySecondChoiceRole(
Expand Down
9 changes: 5 additions & 4 deletions backend/typescript/services/interfaces/appDashboardService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import {
ApplicationDashboardDTO,
ApplicationDTO,
ApplicationDashboardRowDTO,
ApplicantRole
} from "../../types";

interface IAppDashboardService {
getDashboardById(id: number): Promise<ApplicationDashboardDTO>;
getApplicationsByRole(role: string): Promise<ApplicationDTO[]>;
getApplicationsBySecondChoiceRole(role: string): Promise<ApplicationDTO[]>;
getApplicationsByRole(role: ApplicantRole): Promise<ApplicationDTO[]>;
getApplicationsBySecondChoiceRole(role: ApplicantRole): Promise<ApplicationDTO[]>;
getDashboardsByApplicationId(
applicationId: number,
): Promise<ApplicationDashboardDTO[]>;
getApplicationDashboardTable(
role: string,
role: ApplicantRole,
): Promise<ApplicationDashboardRowDTO[]>;
getApplicationBySecondChoiceRoleDashboardTable(
role: string,
role: ApplicantRole,
): Promise<ApplicationDashboardRowDTO[]>;
mutateRating(
id: number,
Expand Down
22 changes: 22 additions & 0 deletions backend/typescript/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,25 @@ export type NodemailerConfig = {
};

export type SignUpMethod = "PASSWORD" | "GOOGLE";

export enum ApplicantRole {
pres = "president", // community tab
int_dir = "internal director",
ext_dir = "external director",
vpe = "vp engineering", // eng tab
vpd = "vp design", // design tab
vpp = "vp product", // prod tab
vpt = "vp talent", // community tab
vp_ext = "vp external", // community tab
vp_int = "vp internal", // community tab
vp_comms = "vp communications", // community tab
vp_scoping = "vp scoping", // community tab
vp_finance = "vp finance & operations", // community tab
pm = "project manager", // prod tab
pl = "project lead", // eng tab
design_mentor = "design mentor", // design tab
graphic_design = "graphic designer", // design tab
product_design = "product designer", // design tab
uxr = "user researcher", // design tab
dev = "project developer", // eng tab
}

0 comments on commit 99e0779

Please sign in to comment.