How to call the validateRecruiters function in the following code depending on the interview type (TECHNICAL_INTERVIEW or HR_INTERVIEW). Notice that the validateRecruiters function takes more parameters in the HR_INTERVIEW call. Could you suggest which design pattern to use so that will be universal in every case?
import { getHrRecruiters, getRecruiters } from '../queue';
import { validateTechnicalInterview } from './validateTechnicalInterview';
import { matchHrRecruiters } from './matchHrRecruiters';
import { THrInterviewer, THrRecruit, TRecruit } from '../../types';
export const recruitersCategoryHandlers = {
TECHNICAL_INTERVIEW: {
getter: getRecruiters,
setter: {
validateRecruiters: (
recruiters: THrInterviewer[],
recruit: TRecruit | THrRecruit
) => validateTechnicalInterview(recruiters, recruit),
},
},
HR_INTERVIEW: {
getter: getHrRecruiters,
setter: {
validateRecruiters: (
recruiters: THrInterviewer[],
recruit: TRecruit | THrRecruit,
param3: any,
param4: any
) => matchHrRecruiters(recruiters, recruit as THrRecruit, param3, param4),
},
},
};
const matchedSlots = getMatchingSlots(
recruitersCategoryHandlers[
interviewCategory as EInterviewCategory
].setter.validateRecruiters(???),
slotsWithEmail
);
The solution works when I have the same parameters. Unfortunately, I’m not sure how to do this with different parameters.