From ddbf35e1616b7baca0d5ac3baae6bdb147b9cb1d Mon Sep 17 00:00:00 2001 From: pm3512 <42977183+pm3512@users.noreply.github.com> Date: Tue, 26 Dec 2023 03:00:40 -0500 Subject: [PATCH] Update /user/application (#138) updated for new application --- src/_types/Profile.d.ts | 11 ++++++----- src/controllers/ProfileController.ts | 6 +----- src/models/Profile.ts | 9 ++++++--- src/routes/user.ts | 28 +++++++++++++++++++--------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/_types/Profile.d.ts b/src/_types/Profile.d.ts index ec22f8d..cbef297 100644 --- a/src/_types/Profile.d.ts +++ b/src/_types/Profile.d.ts @@ -12,6 +12,7 @@ export interface IProfile extends Document { event: ObjectId; user: ObjectId; firstName: string; + middleName?: string; lastName: string; displayName: string; age: number; @@ -24,20 +25,19 @@ export interface IProfile extends Document { ethnicityOther?: string; phoneNumber: string; major?: string; - coursework?: string; - languages?: string; + courses?: string[]; + programmingLanguages?: string[]; + otherSkills?: string[]; hackathonExperience?: Profile.HackathonExperience; workPermission?: Profile.WorkPermission; workLocation?: string; - workStrengths?: string; - sponsorRanking?: ObjectId[]; resume?: string; profilePicture?: string; github: string; design?: string; website?: string; essays?: string[]; - dietaryRestrictions?: string; + dietaryRestrictions?: string[]; shirtSize?: Profile.ShirtSize; wantsHardware?: boolean; address?: string; @@ -47,6 +47,7 @@ export interface IProfile extends Document { updatedAt?: Date; totalPoints: number; attendingPhysically: boolean; + notes?: string; team?: ITeam; diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 26369b8..76d599a 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -123,11 +123,6 @@ export const submitProfile = async ( delete profileArgs.resume; // Filter out invalid object IDs in sponsor ranking - if (profileArgs.sponsorRanking) { - profileArgs.sponsorRanking = profileArgs.sponsorRanking.filter((id) => - ObjectId.isValid(id) - ); - } // Check if user has uploaded a resume yet const resumeExists = await hasResume(user._id); @@ -148,6 +143,7 @@ export const submitProfile = async ( return bad(res, `Display name ${displayName} is taken!`); } + console.log('upserting', profileArgs) await Profile.findOneAndUpdate( { user: user._id, event: tartanhacks._id }, { diff --git a/src/models/Profile.ts b/src/models/Profile.ts index 77c546b..f31b42e 100644 --- a/src/models/Profile.ts +++ b/src/models/Profile.ts @@ -52,6 +52,7 @@ const Profile: Schema = new Schema( required: true, }, firstName: { type: String, required: true }, + middleName: { type: String }, lastName: { type: String, required: true }, displayName: { type: String, required: true }, age: { type: Number }, @@ -108,8 +109,9 @@ const Profile: Schema = new Schema( }, }, major: String, - coursework: String, - languages: String, + courses: Array, + programmingLanguages: Array, + otherSkills: Array, hackathonExperience: { type: String, enum: Object.values(HackathonExperience).concat([null]), @@ -133,7 +135,7 @@ const Profile: Schema = new Schema( design: String, website: String, essays: [String], - dietaryRestrictions: String, + dietaryRestrictions: Array, shirtSize: { type: String, enum: Object.values(ShirtSize).concat([null]), @@ -150,6 +152,7 @@ const Profile: Schema = new Schema( required: true, default: false, }, + notes: String, }, { timestamps: { diff --git a/src/routes/user.ts b/src/routes/user.ts index 67fbdd6..32dda50 100644 --- a/src/routes/user.ts +++ b/src/routes/user.ts @@ -141,8 +141,8 @@ router.get("/team", isAuthenticated, asyncCatch(getOwnTeam)); * enum: [Undergraduate, Masters, Doctorate, Other] * graduationYear: * type: integer - * minimum: 2022 - * maximum: 2027 + * minimum: 2023 + * maximum: 2028 * required: true * gender: * type: string @@ -160,10 +160,18 @@ router.get("/team", isAuthenticated, asyncCatch(getOwnTeam)); * validation: '^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$' * major: * type: string - * coursework: - * type: string - * languages: - * type: string + * courses: + * type: array + * items: + * type: string + * programmingLanguages: + * type: array + * items: + * type: string + * otherSkills: + * type: array + * items: + * type: string * hackathonExperience: * type: string * enum: [0, 0-3, 4+] @@ -174,8 +182,6 @@ router.get("/team", isAuthenticated, asyncCatch(getOwnTeam)); * type: string * workStrengths: * type: string - * sponsorRanking: - * type: array * items: * type: string * github: @@ -190,7 +196,9 @@ router.get("/team", isAuthenticated, asyncCatch(getOwnTeam)); * items: * type: string * dietaryRestrictions: - * type: string + * type: array + * items: + * type: string * shirtSize: * type: string * enum: [XS, S, M, L, XL, XXL, WXS, WS, WM, WL, WXL, WXXL] @@ -203,6 +211,8 @@ router.get("/team", isAuthenticated, asyncCatch(getOwnTeam)); * enum: [Rural, Suburban, Urban] * attendingPhysically: * type: boolean + * notes: + * type: string * responses: * 200: * description: Success.