Skip to content

Commit adced8a

Browse files
committed
#4148: fixed organization parameter
1 parent b97ce6e commit adced8a

5 files changed

Lines changed: 36 additions & 10 deletions

File tree

src/backend/src/controllers/recruitment.controllers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ export default class RecruitmentController {
118118

119119
static async getGuestDefinition(req: Request, res: Response, next: NextFunction) {
120120
try {
121-
const definition = await RecruitmentServices.getGuestDefinition(
122-
req.organization.organizationId,
123-
req.params.definitionId as string
124-
);
121+
const definition = await RecruitmentServices.getGuestDefinition(req.organization, req.params.definitionId as string);
125122
res.status(200).json(definition);
126123
} catch (error: unknown) {
127124
next(error);

src/backend/src/services/recruitment.services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ export default class RecruitmentServices {
346346
* @returns a definition
347347
* @throws if the definition is not found in the db
348348
*/
349-
static async getGuestDefinition(organizationId: string, definitionId: string) {
349+
static async getGuestDefinition(organization: Organization, definitionId: string) {
350350
const guest = await prisma.guest_Definition.findUnique({
351-
where: { organizationId, definitionId }
351+
where: { organization, definitionId }
352352
});
353353

354354
if (!guest) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Prisma } from '@prisma/client';
2+
import { FrequentlyAskedQuestion } from 'shared';
3+
import { FaqQueryArgs } from '../prisma-query-args/faq.query-args.js';
4+
import { userTransformer } from './user.transformer.js';
5+
6+
export const faqTransformer = (faq: Prisma.FrequentlyAskedQuestionGetPayload<FaqQueryArgs>): FrequentlyAskedQuestion => ({
7+
faqId: faq.faqId,
8+
question: faq.question,
9+
answer: faq.answer,
10+
userCreated: userTransformer(faq.userCreated),
11+
dateCreated: faq.dateCreated,
12+
dateDeleted: faq.dateDeleted ?? undefined
13+
});

src/backend/tests/unit/recruitment.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,15 @@ describe('Recruitment Tests', () => {
392392
'buttonTxt',
393393
'buttonLink'
394394
);
395-
const result = await RecruitmentServices.getGuestDefinition(orgId, guestDefinition.definitionId);
395+
const result = await RecruitmentServices.getGuestDefinition(organization, guestDefinition.definitionId);
396396
expect(result).toStrictEqual(guestDefinition);
397397
});
398398

399399
it('Get a single guest definition fails', async () => {
400400
const nonExistingDefinitionId = 'nonExistingDefinition';
401-
await expect(async () => RecruitmentServices.getGuestDefinition(orgId, nonExistingDefinitionId)).rejects.toThrow(
402-
new NotFoundException('Guest Definition', nonExistingDefinitionId)
403-
);
401+
await expect(async () =>
402+
RecruitmentServices.getGuestDefinition(organization, nonExistingDefinitionId)
403+
).rejects.toThrow(new NotFoundException('Guest Definition', nonExistingDefinitionId));
404404
});
405405
});
406406
describe('Edit Guest Definition', () => {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3+
* See the LICENSE file in the repository root folder for details.
4+
*/
5+
6+
import { User } from './user-types.js';
7+
8+
export interface FrequentlyAskedQuestion {
9+
faqId: string;
10+
question: string;
11+
answer: string;
12+
userCreated: User;
13+
userDeleted?: User;
14+
dateCreated: Date;
15+
dateDeleted?: Date;
16+
}

0 commit comments

Comments
 (0)