From 42af509e0a99fc750b61877de526aace4d156f87 Mon Sep 17 00:00:00 2001 From: Serena Romano Date: Thu, 16 May 2024 17:24:10 -0400 Subject: [PATCH 01/76] CHE-139 added nickName to profileModel & added type to IProfile --- server/models/profileModel.ts | 9 +++++---- server/types/profile.ts | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/server/models/profileModel.ts b/server/models/profileModel.ts index 499eabd..c3849f3 100644 --- a/server/models/profileModel.ts +++ b/server/models/profileModel.ts @@ -1,10 +1,11 @@ -import mongoose, { Schema } from "mongoose"; -import { IProfile } from "../types/profile"; +import mongoose, { Schema } from 'mongoose'; +import { IProfile } from '../types/profile'; const profileSchema = new Schema({ - user: { type: Schema.Types.ObjectId, ref: "User", required: true }, + user: { type: Schema.Types.ObjectId, ref: 'User', required: true }, firstName: { type: String, required: true }, lastName: { type: String, required: true }, + nickName: { type: String, required: false }, profilePhoto: String, cohort: String, graduationYear: Number, @@ -70,6 +71,6 @@ const profileSchema = new Schema({ ], }); -const Profile = mongoose.model("profiles", profileSchema); +const Profile = mongoose.model('profiles', profileSchema); export default Profile; diff --git a/server/types/profile.ts b/server/types/profile.ts index 3fafd05..da9600c 100644 --- a/server/types/profile.ts +++ b/server/types/profile.ts @@ -1,4 +1,4 @@ -import { Document, ObjectId } from "mongoose"; +import { Document, ObjectId } from 'mongoose'; interface ISocialLinks { twitter?: string; @@ -42,6 +42,7 @@ export interface IProfile extends Document { user: ObjectId; firstName: string; lastName: string; + nickName: string; profilePhoto?: string; cohort?: string; graduationYear?: number; From 78bacb497d3858b8bda78ce47db76cf0af1699e6 Mon Sep 17 00:00:00 2001 From: Mnelson98 <138735614+Mnelson98@users.noreply.github.com> Date: Tue, 21 May 2024 18:44:32 -0400 Subject: [PATCH 02/76] CHE-147 Micahs first commit --- client/src/pages/EditProfilePage/EditProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/pages/EditProfilePage/EditProfilePage.tsx b/client/src/pages/EditProfilePage/EditProfilePage.tsx index 838551f..b77b98c 100644 --- a/client/src/pages/EditProfilePage/EditProfilePage.tsx +++ b/client/src/pages/EditProfilePage/EditProfilePage.tsx @@ -28,7 +28,7 @@ const EditProfilePage = () => { useEffect(() => { if (userID) dispatch(fetchUserProfile(userID as string)); }, [dispatch]); - + // Micah was here useEffect(() => { if (profile) { setFormData({ From acb58f3cd1099cd68b65f37292a0fed6f07f53ed Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 22 May 2024 09:03:07 -0400 Subject: [PATCH 03/76] CHE-148 Updated EditProfilePage handleSubmit dispatch and userprofileSlice to support redirect after submit --- client/src/features/userProfile/userProfileSlice.ts | 10 +++++++++- client/src/pages/EditProfilePage/EditProfilePage.tsx | 4 +++- client/src/pages/Profile/Profile.tsx | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/src/features/userProfile/userProfileSlice.ts b/client/src/features/userProfile/userProfileSlice.ts index 57f4543..b3ea3a1 100644 --- a/client/src/features/userProfile/userProfileSlice.ts +++ b/client/src/features/userProfile/userProfileSlice.ts @@ -1,6 +1,7 @@ import { createSlice, createAsyncThunk } from "@reduxjs/toolkit"; import axios from "axios"; import { IProfile } from "../../../types/profile"; +import { NavigateFunction } from "react-router-dom"; export interface ProfileState { profile: IProfile | null; @@ -31,14 +32,21 @@ export const fetchUserProfile = createAsyncThunk( } ); +interface UpdateUserProfileArgs extends Partial { + userID: string; + navigate: NavigateFunction; +} + export const updateUserProfile = createAsyncThunk( "profile/updateUserProfile", async ( - { userID, ...updateData }: Partial & { userID: string }, + { userID, navigate, ...updateData }: UpdateUserProfileArgs, thunkAPI ) => { try { + console.log("userId before axios call: ", userID); const response = await axios.put(`/api/profiles/${userID}`, updateData); + navigate(`/app/profile/${userID}`); return response.data; } catch (error) { let errorMessage = "An error occurred during profile update"; diff --git a/client/src/pages/EditProfilePage/EditProfilePage.tsx b/client/src/pages/EditProfilePage/EditProfilePage.tsx index 838551f..66f981a 100644 --- a/client/src/pages/EditProfilePage/EditProfilePage.tsx +++ b/client/src/pages/EditProfilePage/EditProfilePage.tsx @@ -6,6 +6,7 @@ import React, { FormEvent, } from "react"; import { useAppSelector, useAppDispatch } from "../../app/hooks"; +import { useNavigate } from "react-router-dom"; import { fetchUserProfile, updateUserProfile, @@ -14,6 +15,7 @@ import { const EditProfilePage = () => { const dispatch = useAppDispatch(); + const navigate = useNavigate(); const { profile, status } = useAppSelector((state) => state.userProfile); const userID = useAppSelector((state) => state.user.userData?._id); const fileInputRef = useRef(null); @@ -58,7 +60,7 @@ const EditProfilePage = () => { console.error("UserID is undefined."); return; } - dispatch(updateUserProfile({ ...formData, userID })); + dispatch(updateUserProfile({ ...formData, userID, navigate })); }; const handleImageUpload = () => { diff --git a/client/src/pages/Profile/Profile.tsx b/client/src/pages/Profile/Profile.tsx index a8485b0..f7ceae8 100644 --- a/client/src/pages/Profile/Profile.tsx +++ b/client/src/pages/Profile/Profile.tsx @@ -9,7 +9,6 @@ const Profile = (): JSX.Element => { const userProfile = useAppSelector((state) => state.userProfile.profile); useEffect(() => { - console.log("userId", userId); if (userId) dispatch(fetchUserProfile(userId)); }, [dispatch]); return ( From 480289f208000a8971c59f1250e7b1bc9d828aca Mon Sep 17 00:00:00 2001 From: Mnelson98 <138735614+Mnelson98@users.noreply.github.com> Date: Wed, 22 May 2024 19:23:25 -0400 Subject: [PATCH 04/76] CHE-147 updated style for account button within the header --- client/src/components/Header/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/Header/Header.tsx b/client/src/components/Header/Header.tsx index 9229940..9768585 100644 --- a/client/src/components/Header/Header.tsx +++ b/client/src/components/Header/Header.tsx @@ -77,7 +77,7 @@ const Header = (): JSX.Element => {
From a7cafa1ae626e76e644581788571825f3c82edb4 Mon Sep 17 00:00:00 2001 From: Mnelson98 <138735614+Mnelson98@users.noreply.github.com> Date: Wed, 22 May 2024 19:36:48 -0400 Subject: [PATCH 05/76] CHE-147 restyled buttons on the edit profile page --- client/src/pages/EditProfilePage/EditProfilePage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/pages/EditProfilePage/EditProfilePage.tsx b/client/src/pages/EditProfilePage/EditProfilePage.tsx index b77b98c..f67f780 100644 --- a/client/src/pages/EditProfilePage/EditProfilePage.tsx +++ b/client/src/pages/EditProfilePage/EditProfilePage.tsx @@ -119,7 +119,7 @@ const EditProfilePage = () => { /> diff --git a/client/src/pages/EditProfilePage/EditProfilePage.tsx b/client/src/pages/EditProfilePage/EditProfilePage.tsx index d147f02..7ef81c7 100644 --- a/client/src/pages/EditProfilePage/EditProfilePage.tsx +++ b/client/src/pages/EditProfilePage/EditProfilePage.tsx @@ -30,7 +30,6 @@ const EditProfilePage = () => { useEffect(() => { if (userID) dispatch(fetchUserProfile(userID as string)); }, [dispatch]); - // Micah was here useEffect(() => { if (profile) { setFormData({ From 39d8e13cd2f9649e1352fef4d1b10fea59061280 Mon Sep 17 00:00:00 2001 From: Mnelson98 <138735614+Mnelson98@users.noreply.github.com> Date: Fri, 24 May 2024 12:43:28 -0400 Subject: [PATCH 07/76] Restyle all header classes to meet style guide requirements --- client/src/components/Header/Header.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/components/Header/Header.tsx b/client/src/components/Header/Header.tsx index 1ec7768..942d23b 100644 --- a/client/src/components/Header/Header.tsx +++ b/client/src/components/Header/Header.tsx @@ -36,16 +36,16 @@ const Header = (): JSX.Element => { return (
Code Hammers Logo -

Code Hammers

+

Code Hammers

-
+
{ { @@ -84,11 +84,11 @@ const Header = (): JSX.Element => { {showDropdown && (
{ navigate("/app/editProfile"); setShowDropdown(false); @@ -98,7 +98,7 @@ const Header = (): JSX.Element => { Logout From 938d89ef49a9b9717ec6c378578eb0bc97c328f5 Mon Sep 17 00:00:00 2001 From: Mnelson98 <138735614+Mnelson98@users.noreply.github.com> Date: Fri, 24 May 2024 13:02:30 -0400 Subject: [PATCH 08/76] udpate all classes in the EditProfilePage to meet style guide requirements --- .../pages/EditProfilePage/EditProfilePage.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/client/src/pages/EditProfilePage/EditProfilePage.tsx b/client/src/pages/EditProfilePage/EditProfilePage.tsx index 7ef81c7..471b567 100644 --- a/client/src/pages/EditProfilePage/EditProfilePage.tsx +++ b/client/src/pages/EditProfilePage/EditProfilePage.tsx @@ -83,24 +83,24 @@ const EditProfilePage = () => { } return ( -
-

Edit Profile

-
+
+

Edit Profile

+
{profile?.profilePhoto && (
Profile
)} -
)} -
+ ))} +
)} - -