diff --git a/package.json b/package.json index c191a48e..089c24ef 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "typeorm:db": "npm run build && npx typeorm -d dist/src/configs/dbConfig.js", "migration:generate": "npm run typeorm:db -- migration:generate", "migration:run": "npm run typeorm:db -- migration:run", + "sync:db": "npm run typeorm:db schema:sync", "seed": "npm run build && node dist/src/scripts/seed-db.js" }, "author": "", diff --git a/src/configs/dbConfig.ts b/src/configs/dbConfig.ts index 05c6069e..319efc92 100644 --- a/src/configs/dbConfig.ts +++ b/src/configs/dbConfig.ts @@ -1,6 +1,6 @@ -import { DataSource } from 'typeorm' -import { DB_PASSWORD, DB_HOST, DB_PORT, DB_USER, DB_NAME } from './envConfig' import path from 'path' +import { DataSource } from 'typeorm' +import { DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER } from './envConfig' export const dataSource = new DataSource({ type: 'postgres', diff --git a/src/entities/mentee.entity.ts b/src/entities/mentee.entity.ts index 9490c1c7..0773ee0e 100644 --- a/src/entities/mentee.entity.ts +++ b/src/entities/mentee.entity.ts @@ -1,4 +1,4 @@ -import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from 'typeorm' +import { Column, Entity, ManyToOne } from 'typeorm' import Mentor from './mentor.entity' import profileEntity from './profile.entity' import { ApplicationStatus, StatusUpdatedBy } from '../enums' @@ -28,8 +28,7 @@ class Mentee extends BaseEntity { @Column({ default: null, nullable: true }) journal!: string - @OneToOne(() => profileEntity) - @JoinColumn() + @ManyToOne(() => profileEntity, (profile) => profile.mentee) profile: profileEntity @ManyToOne(() => Mentor, (mentor) => mentor.mentees) diff --git a/src/entities/profile.entity.ts b/src/entities/profile.entity.ts index 170044d1..84c1ad66 100644 --- a/src/entities/profile.entity.ts +++ b/src/entities/profile.entity.ts @@ -37,7 +37,6 @@ class Profile extends BaseEntity { first_name: string, last_name: string, image_uri: string, - linkedin_uri: string, type: ProfileTypes, password: string ) { diff --git a/src/migrations/1722051742722-RemoveUniqueConstraintFromProfileUuid.ts b/src/migrations/1722051742722-RemoveUniqueConstraintFromProfileUuid.ts new file mode 100644 index 00000000..936370df --- /dev/null +++ b/src/migrations/1722051742722-RemoveUniqueConstraintFromProfileUuid.ts @@ -0,0 +1,31 @@ +import { type MigrationInterface, type QueryRunner } from 'typeorm' + +export class RemoveUniqueConstraintFromProfileUuid1722051742722 + implements MigrationInterface +{ + name = 'RemoveUniqueConstraintFromProfileUuid1722051742722' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "mentee" DROP CONSTRAINT "FK_f671cf2220d1bd0621a1a5e92e7"` + ) + await queryRunner.query( + `ALTER TABLE "mentee" DROP CONSTRAINT "REL_f671cf2220d1bd0621a1a5e92e"` + ) + await queryRunner.query( + `ALTER TABLE "mentee" ADD CONSTRAINT "FK_f671cf2220d1bd0621a1a5e92e7" FOREIGN KEY ("profileUuid") REFERENCES "profile"("uuid") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "mentee" DROP CONSTRAINT "FK_f671cf2220d1bd0621a1a5e92e7"` + ) + await queryRunner.query( + `ALTER TABLE "mentee" ADD CONSTRAINT "REL_f671cf2220d1bd0621a1a5e92e" UNIQUE ("profileUuid")` + ) + await queryRunner.query( + `ALTER TABLE "mentee" ADD CONSTRAINT "FK_f671cf2220d1bd0621a1a5e92e7" FOREIGN KEY ("profileUuid") REFERENCES "profile"("uuid") ON DELETE NO ACTION ON UPDATE NO ACTION` + ) + } +} diff --git a/src/scripts/seed-db.ts b/src/scripts/seed-db.ts index 6a8ec338..b97a8f70 100644 --- a/src/scripts/seed-db.ts +++ b/src/scripts/seed-db.ts @@ -126,7 +126,7 @@ const createRandomProfile = (): Partial => { const createMentor = (category: Category, profile: Profile): Mentor => { return { state: faker.helpers.enumValue(ApplicationStatus), - category: category, + category, application: { firstName: faker.person.firstName(), lastName: faker.person.firstName(), @@ -154,7 +154,7 @@ const createMentor = (category: Category, profile: Profile): Mentor => { email: faker.internet.email() }, availability: faker.datatype.boolean(), - profile: profile + profile } as unknown as Mentor } diff --git a/src/services/admin.service.test.ts b/src/services/admin.service.test.ts index 40d75a71..a5a87328 100644 --- a/src/services/admin.service.test.ts +++ b/src/services/admin.service.test.ts @@ -17,7 +17,6 @@ describe('getAllUsers', () => { 'User1', 'Last1', 'image1.jpg', - 'linkedin1', ProfileTypes.DEFAULT, 'hashedPassword1' ) @@ -28,7 +27,6 @@ describe('getAllUsers', () => { 'User2', 'Last2', 'image2.jpg', - 'linkedin2', ProfileTypes.ADMIN, 'hashedPassword2' ) diff --git a/src/services/admin/user.service.test.ts b/src/services/admin/user.service.test.ts index e6aef74d..360306f9 100644 --- a/src/services/admin/user.service.test.ts +++ b/src/services/admin/user.service.test.ts @@ -17,7 +17,6 @@ describe('getAllUsers', () => { 'User1', 'Last1', 'image1.jpg', - 'linkedin1', ProfileTypes.DEFAULT, 'hashedPassword1' ) @@ -28,7 +27,6 @@ describe('getAllUsers', () => { 'User2', 'Last2', 'image2.jpg', - 'linkedin2', ProfileTypes.ADMIN, 'hashedPassword2' ) diff --git a/src/templates/emailTemplate.ejs b/src/templates/emailTemplate.ejs index 07475d57..ee6969f4 100644 --- a/src/templates/emailTemplate.ejs +++ b/src/templates/emailTemplate.ejs @@ -170,24 +170,6 @@ >View Dashboard - - Join our Slack -

diff --git a/src/utils.ts b/src/utils.ts index befdbf55..6ea0d917 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -98,12 +98,23 @@ export const getEmailContent = ( subject: 'Congratulations! You have been selected as a ScholarX Mentor', message: `Dear ${name},

- I hope this email finds you in high spirits! I am delighted to inform you that you have been selected as a mentor for ScholarX, and we extend our heartfelt congratulations to you!

- We received a large number of qualified applicants, and after a thorough review of all candidates, we are thrilled to invite you to accept a place in our program. Your profile stood out amongst the others, and we are confident that you will contribute positively to our program.

- We understand that your hard work and dedication have brought you to this moment, and we recognize your exceptional talent, experience, and potential in your respective fields. We are excited to have you join our community of learners and scholars.

- We look forward to seeing the unique perspective and insights you will bring to the mentees and to the program. We believe that you will flourish in this year's edition of ScholarX, and we are thrilled to be a part of your academic or professional journey.

- Once again, congratulations on your selection! We cannot wait to have you on board. We will keep you informed on the next steps, and in the meantime would like to invite you to go through some of the resources that would be useful to thrive as a great mentor in ScholarX.` + I hope this email finds you in high spirits! I am delighted to inform you that you have been selected as a mentor for ScholarX, and we extend our heartfelt congratulations to you!

+ We received a large number of qualified applicants, and after a thorough review of all candidates, we are thrilled to invite you to accept a place in our program. Your profile stood out amongst the others, and we are confident that you will contribute positively to our program.

+ We understand that your hard work and dedication have brought you to this moment, and we recognize your exceptional talent, experience, and potential in your respective fields. We are excited to have you join our community of learners and scholars.

+ We look forward to seeing the unique perspective and insights you will bring to the mentees and to the program. We believe that you will flourish in this year's edition of ScholarX, and we are thrilled to be a part of your academic or professional journey.

+ Once again, congratulations on your selection! We cannot wait to have you on board. We will keep you informed on the next steps, and in the meantime, we would like to invite you to go through some of the resources that would be useful to thrive as a great mentor in ScholarX.

+ Important: To help you get started and to provide all the necessary information you will need, please carefully read the Mentor Guide. This guide contains crucial details about the program and your responsibilities. You can access the Mentor Guide using the link below:

+ + Read the Mentor Guide +

+ Please ensure you review this guide thoroughly to understand the next steps and to prepare for your journey with us.` } + case ApplicationStatus.REJECTED: return { subject: 'Thank You for Your Interest in the ScholarX Program', @@ -129,11 +140,21 @@ export const getEmailContent = ( return { subject: 'Congratulations! You have been selected for ScholarX', message: `Dear ${name},

- We are delighted to inform you that you have been selected for our undergraduate program, and we extend our heartfelt congratulations to you!

- We received a large number of qualified applicants, and after a thorough review of all candidates, we are thrilled to offer you a place in our program. Your application stood out amongst the others, and we are confident that you will contribute positively to our program.

- We believe that you have great potential to succeed in your academic and professional pursuits, and we are excited to have you join our community of learners and scholars.

- To emphasize the importance of completing the program, you have received a valuable opportunity. If, for any reason, you are uncertain about completing the program within the 6-month timeline, please inform our admissions team as soon as possible, so we can provide the opportunity to another deserving student.

- Once again, congratulations on your selection! We cannot wait to have you on board. ` + We are delighted to inform you that you have been selected for our undergraduate program, and we extend our heartfelt congratulations to you!

+ We received a large number of qualified applicants, and after a thorough review of all candidates, we are thrilled to offer you a place in our program. Your application stood out amongst the others, and we are confident that you will contribute positively to our program.

+ We believe that you have great potential to succeed in your academic and professional pursuits, and we are excited to have you join our community of learners and scholars.

+ To emphasize the importance of completing the program, you have received a valuable opportunity. If, for any reason, you are uncertain about completing the program within the 6-month timeline, please inform our admissions team as soon as possible, so we can provide the opportunity to another deserving student.

+ Once again, congratulations on your selection! We cannot wait to have you on board.

+ Important: To help you get started and to provide all the necessary information you will need, please carefully read the Mentee Guide. This guide contains crucial details about the program, your responsibilities, and how to make the most of this opportunity. You can access the Mentee Guide using the link below:

+ + Read the Mentee Guide +

+ Please ensure you review this guide thoroughly to understand the next steps and to prepare for your journey with us.` } case ApplicationStatus.REJECTED: return {