Skip to content

Commit 6ea3b42

Browse files
Ticket 211 unknown user review (#214)
* fixing the merge conflicts so that you can refresh on reload * ticket_211 --------- Co-authored-by: Jayden Carvajal <carvajal.ja@northeastern.edu>
1 parent b66ab3b commit 6ea3b42

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

apps/backend/src/applications/applications.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export class ApplicationsService {
409409
const allApplicationsDto = await Promise.all(
410410
applications.map(async (app) => {
411411
const ratings = this.calculateAllRatings(app.reviews);
412-
const stageProgress = this.determineStageProgress(app, app.reviews);
412+
const stageProgress = this.determineStageProgress(app, app.reviews);
413413
const assignedRecruiters =
414414
await this.getAssignedRecruitersForApplication(app);
415415

@@ -500,7 +500,10 @@ export class ApplicationsService {
500500
* submitted a review for that stage. If no recruiters are assigned, the
501501
* stage remains PENDING even if admins or others submit reviews.
502502
*/
503-
private determineStageProgress(app: Application, reviews: any[]): StageProgress {
503+
private determineStageProgress(
504+
app: Application,
505+
reviews: any[],
506+
): StageProgress {
504507
const stage = app.stage;
505508

506509
// Terminal stages are always completed
@@ -530,7 +533,9 @@ export class ApplicationsService {
530533
reviewerIdsForStage.has(id),
531534
);
532535

533-
return allAssignedReviewed ? StageProgress.COMPLETED : StageProgress.PENDING;
536+
return allAssignedReviewed
537+
? StageProgress.COMPLETED
538+
: StageProgress.PENDING;
534539
}
535540

536541
/**

apps/backend/src/reviews/review.entity.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ export class Review {
1818
@JoinColumn({ name: 'applicationId' })
1919
application: Application;
2020

21-
@ManyToOne(() => User, (user) => user.id)
21+
// The relationship to User
22+
@ManyToOne(() => User, { nullable: false })
23+
@JoinColumn({ name: 'reviewerId' })
24+
reviewer: User;
25+
26+
// The foreign key column
27+
@Column({ nullable: false })
2228
reviewerId: number;
2329

2430
@Column({ type: 'double precision', nullable: false })

apps/backend/src/testing/factories/user.factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const defaultUser: User = {
1515
team: null,
1616
role: null,
1717
applications: [],
18-
review: null,
18+
reviews: [],
1919
};
2020

2121
export const userFactory = (user: Partial<User> = {}): User =>

apps/backend/src/users/user.entity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ export class User {
7575
@OneToMany(() => Application, (application) => application.user)
7676
applications: Application[];
7777

78-
@OneToMany(() => Review, (review) => review.reviewerId)
79-
review: Review;
78+
@OneToMany(() => Review, (review) => review.reviewer)
79+
reviews: Review[];
8080
}

apps/frontend/src/features/applications/components/ApplicationTables/individualApplication.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ const IndividualApplicationDetails = ({
4747
accessToken,
4848
onRefreshApplication,
4949
}: IndividualApplicationDetailsProps) => {
50+
console.log('Full selectedApplication:', selectedApplication);
51+
console.log('Reviews array:', selectedApplication.reviews);
52+
5053
// Lighter purple accent tuned to match Figma palette
5154
const ACCENT = '#9B6CFF';
5255
// Assigned recruiters are managed by the AssignedRecruiters child component
@@ -90,6 +93,12 @@ const IndividualApplicationDetails = ({
9093
}
9194

9295
try {
96+
if (currentUser == null) {
97+
throw new Error(
98+
'the current user should not be null when trying to submit a review',
99+
);
100+
}
101+
93102
// Submit review
94103
if (reviewRating && trimmedComment) {
95104
await apiClient.submitReview(accessToken, {

0 commit comments

Comments
 (0)