-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
515 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import type { Request, Response } from 'express' | ||
import { type ApiResponse } from '../types' | ||
import type MonthlyCheckIn from '../entities/checkin.entity' | ||
|
||
import { | ||
addFeedbackByMentor, | ||
addMonthlyCheckInByMentee, | ||
fetchMonthlyCheckIns | ||
} from '../services/monthlyChecking.service' | ||
|
||
export const postMonthlyCheckIn = async ( | ||
req: Request, | ||
res: Response | ||
): Promise<Response<ApiResponse<MonthlyCheckIn>>> => { | ||
try { | ||
const { | ||
menteeId, | ||
title, | ||
generalUpdatesAndFeedback, | ||
progressTowardsGoals, | ||
mediaContentLinks | ||
} = req.body | ||
|
||
const newCheckIn = await addMonthlyCheckInByMentee( | ||
menteeId, | ||
title, | ||
generalUpdatesAndFeedback, | ||
progressTowardsGoals, | ||
mediaContentLinks | ||
) | ||
|
||
return res | ||
.status(201) | ||
.json({ checkIn: newCheckIn, message: 'Check-in added successfully' }) | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
console.error('Error executing query', err) | ||
return res | ||
.status(500) | ||
.json({ error: 'Internal server error', message: err.message }) | ||
} | ||
throw err | ||
} | ||
} | ||
|
||
export const getMonthlyCheckIns = async ( | ||
req: Request, | ||
res: Response | ||
): Promise<Response<ApiResponse<MonthlyCheckIn>>> => { | ||
try { | ||
const { menteeId } = req.params | ||
|
||
const { statusCode, checkIns, message } = await fetchMonthlyCheckIns( | ||
menteeId | ||
) | ||
|
||
return res.status(statusCode).json({ checkIns, message }) | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
console.error('Error executing query', err) | ||
return res | ||
.status(500) | ||
.json({ error: 'Internal server error', message: err.message }) | ||
} | ||
throw err | ||
} | ||
} | ||
|
||
export const addFeedbackMonthlyCheckIn = async ( | ||
req: Request, | ||
res: Response | ||
): Promise<void> => { | ||
try { | ||
const { checkInId, menteeId, mentorFeedback, isCheckedByMentor } = req.body | ||
|
||
const newMentorFeedbackCheckIn = await addFeedbackByMentor( | ||
menteeId, | ||
checkInId, | ||
mentorFeedback, | ||
isCheckedByMentor | ||
) | ||
|
||
res.status(201).json({ | ||
feedbackCheckIn: newMentorFeedbackCheckIn | ||
}) | ||
} catch (err) { | ||
if (err instanceof Error) { | ||
console.error('Error executing query', err) | ||
res | ||
.status(500) | ||
.json({ error: 'Internal server error', message: err.message }) | ||
} | ||
throw err | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm' | ||
import BaseEntity from './baseEntity' | ||
import Mentee from './mentee.entity' | ||
|
||
@Entity('monthly-check-in') | ||
class MonthlyCheckIn extends BaseEntity { | ||
@Column({ type: 'text' }) | ||
title: string | ||
|
||
@Column({ type: 'text' }) | ||
generalUpdatesAndFeedback: string | ||
|
||
@Column({ type: 'text' }) | ||
progressTowardsGoals: string | ||
|
||
@Column({ type: 'json' }) | ||
mediaContentLinks: string[] | ||
|
||
@Column({ type: 'text', nullable: true }) | ||
mentorFeedback: string | ||
|
||
@Column({ type: 'boolean', default: false }) | ||
isCheckedByMentor: boolean | ||
|
||
@Column({ type: 'timestamp', nullable: true }) | ||
mentorCheckedDate: Date | ||
|
||
@Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }) | ||
checkInDate: Date | ||
|
||
@ManyToOne(() => Mentee, (mentee) => mentee.checkIns) | ||
@JoinColumn({ name: 'menteeId' }) | ||
mentee: Mentee | ||
|
||
constructor( | ||
title: string, | ||
generalUpdatesAndFeedback: string, | ||
progressTowardsGoals: string, | ||
mediaContentLinks: string[], | ||
mentorFeedback: string, | ||
isCheckedByMentor: boolean, | ||
mentorCheckedDate: Date, | ||
checkInDate: Date, | ||
mentee: Mentee | ||
) { | ||
super() | ||
this.title = title | ||
this.generalUpdatesAndFeedback = generalUpdatesAndFeedback | ||
this.progressTowardsGoals = progressTowardsGoals | ||
this.mediaContentLinks = mediaContentLinks | ||
this.mentorFeedback = mentorFeedback | ||
this.isCheckedByMentor = isCheckedByMentor | ||
this.mentorCheckedDate = mentorCheckedDate | ||
this.checkInDate = checkInDate | ||
this.mentee = mentee | ||
} | ||
|
||
validate(): boolean { | ||
return this.mediaContentLinks.length >= 3 | ||
} | ||
} | ||
|
||
export default MonthlyCheckIn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/migrations/1726930041488-UpdateMentorTableWithCountry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm' | ||
|
||
export class UpdateMentorTableWithCountry1726930041488 | ||
implements MigrationInterface | ||
{ | ||
name = 'UpdateMentorTableWithCountry1726930041488' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "mentor" ADD "countryUuid" uuid`) | ||
await queryRunner.query( | ||
`ALTER TABLE "mentor" ADD CONSTRAINT "FK_3302c22eb1636f239d605eb61c3" FOREIGN KEY ("countryUuid") REFERENCES "country"("uuid") ON DELETE NO ACTION ON UPDATE NO ACTION` | ||
) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "mentor" DROP CONSTRAINT "FK_3302c22eb1636f239d605eb61c3"` | ||
) | ||
await queryRunner.query(`ALTER TABLE "mentor" DROP COLUMN "countryUuid"`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class MonthlyCheckingTags1727197270336 implements MigrationInterface { | ||
name = 'MonthlyCheckingTags1727197270336' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "monthly-check-in" ADD "tags" json`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "monthly-check-in" DROP COLUMN "tags"`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { type MigrationInterface, type QueryRunner } from 'typeorm' | ||
|
||
export class Monthlychecking1727636762101 implements MigrationInterface { | ||
name = 'Monthlychecking1727636762101' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "monthly-check-in" DROP COLUMN "tags"`) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "monthly-check-in" ADD "tags" json`) | ||
} | ||
} |
Oops, something went wrong.