From 3da8e74d51d98abb4676964adf3aa1b0536e0729 Mon Sep 17 00:00:00 2001 From: Max Weng Date: Wed, 30 Oct 2024 22:55:22 -0700 Subject: [PATCH] add onboarding seen --- api/validators/UserControllerRequests.ts | 3 +++ migrations/0047-add-onboarding-seen.ts | 25 ++++++++++++++++++++++++ models/UserModel.ts | 7 +++++++ types/ApiRequests.ts | 1 + types/ApiResponses.ts | 1 + 5 files changed, 37 insertions(+) create mode 100644 migrations/0047-add-onboarding-seen.ts diff --git a/api/validators/UserControllerRequests.ts b/api/validators/UserControllerRequests.ts index f0b03f9be..f3ba77ce4 100644 --- a/api/validators/UserControllerRequests.ts +++ b/api/validators/UserControllerRequests.ts @@ -47,6 +47,9 @@ export class UserPatches implements IUserPatches { @Allow() isAttendancePublic?: boolean; + @Allow() + onboardingSeen?: boolean; + @Type(() => PasswordUpdate) @ValidateNested() @HasMatchingPasswords() diff --git a/migrations/0047-add-onboarding-seen.ts b/migrations/0047-add-onboarding-seen.ts new file mode 100644 index 000000000..afcb15851 --- /dev/null +++ b/migrations/0047-add-onboarding-seen.ts @@ -0,0 +1,25 @@ +import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; + +const TABLE_NAME = 'Users'; + +export class AddOnboardingSeen1730353019494 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn(TABLE_NAME, + new TableColumn({ + name: 'onboardingSeen', + type: 'boolean', + isNullable: true, + default: false, + })); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn(TABLE_NAME, + new TableColumn({ + name: 'onboardingSeen', + type: 'boolean', + isNullable: true, + default: false, + })); + } +} diff --git a/models/UserModel.ts b/models/UserModel.ts index 677ec3f10..0b594c2a9 100644 --- a/models/UserModel.ts +++ b/models/UserModel.ts @@ -65,6 +65,9 @@ export class UserModel extends BaseEntity { @Column('integer', { default: 0 }) credits: number; + @Column('boolean', { default: false }) + onboardingSeen: boolean; + @OneToMany((type) => ActivityModel, (activity) => activity.user, { cascade: true }) activities: ActivityModel[]; @@ -154,10 +157,14 @@ export class UserModel extends BaseEntity { points: this.points, credits: this.credits, isAttendancePublic: this.isAttendancePublic, + onboardingSeen: this.onboardingSeen, }; if (this.userSocialMedia) { fullUserProfile.userSocialMedia = this.userSocialMedia.map((sm) => sm.getPublicSocialMedia()); } + if (this.resumes) { + fullUserProfile.resumes = this.resumes.map((rm) => rm.getPublicResume()); + } return fullUserProfile; } } diff --git a/types/ApiRequests.ts b/types/ApiRequests.ts index ed571143e..a09860ea7 100644 --- a/types/ApiRequests.ts +++ b/types/ApiRequests.ts @@ -68,6 +68,7 @@ export interface UserPatches { graduationYear?: number; bio?: string; isAttendancePublic?: boolean; + onboardingSeen?: boolean; passwordChange?: PasswordUpdate; } diff --git a/types/ApiResponses.ts b/types/ApiResponses.ts index 275d6e77d..1cf3d2eee 100644 --- a/types/ApiResponses.ts +++ b/types/ApiResponses.ts @@ -359,6 +359,7 @@ export interface PrivateProfile extends PublicProfile { state: string, credits: number, resumes?: PublicResume[], + onboardingSeen: boolean, } export interface PublicFeedback {