From ace19ff5d9a05beac1a4668ff18c2c38810fd333 Mon Sep 17 00:00:00 2001 From: Oyvind Timian Dokk Husveg Date: Thu, 25 Sep 2025 13:33:15 +0200 Subject: [PATCH 1/6] Accompanying changes to user object f from the backend --- src/components/header/index.js | 2 +- src/pages/profile/ProfilePage.jsx | 4 ++-- src/pages/search/StudentSearchView.jsx | 4 ++-- test/helpers.ts | 22 ++++++++++++++-------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/components/header/index.js b/src/components/header/index.js index b407582..b5a6a03 100644 --- a/src/components/header/index.js +++ b/src/components/header/index.js @@ -60,7 +60,7 @@ const Header = () => {

{name}

- {user.specialism}, Cohort 3 + {user.specialism}, {user.cohort.title}
diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index 79fcca6..3708e2c 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -118,8 +118,8 @@ const ProfilePage = () => { role={tempCurrentUser?.role || ''} specialism={tempCurrentUser?.specialism || ''} cohort={tempCurrentUser?.cohort || ''} - startDate={tempCurrentUser?.startDate || ''} - endDate={tempCurrentUser?.endDate || ''} + startDate={tempCurrentUser?.cohort.startDate || ''} + endDate={tempCurrentUser?.cohort.endDate || ''} isEditing={isEditing} onChange={handleChange} /> diff --git a/src/pages/search/StudentSearchView.jsx b/src/pages/search/StudentSearchView.jsx index b23d4b2..29f3654 100644 --- a/src/pages/search/StudentSearchView.jsx +++ b/src/pages/search/StudentSearchView.jsx @@ -107,7 +107,7 @@ const StudentSearchView = () => { {u.firstName} {u.lastName}

{/* Empty cohorts get a random cohort to ensure nice formatting */} -

{u.cohort ? u.cohort : 'Software Developer, Cohort 69'}

+

{u.cohort.title ? u.cohort.title : 'Software Developer, Cohort 69'}

navigate(`/profile/${u.id}`)}> Profile @@ -133,7 +133,7 @@ const StudentSearchView = () => { {u.firstName} {u.lastName}

{/* Empty cohorts get a random cohort to ensure nice formatting */} -

{u.cohort ? u.cohort : 'Software Developer, Cohort 69'}

+

{u.cohort.title ? u.cohort.title : 'Software Developer, Cohort 69'}

= {}): TestUserD // number of milliseconds in one day const ONE_DAY = 24 * 60 * 60 * 1000; - const startDate = overrides.startDate ?? new Date(saltSeed + 7 * ONE_DAY); // 7 days in the future - const endDate = overrides.endDate ?? new Date(saltSeed + 14 * ONE_DAY); // 14 days in the future + const startDate = overrides.cohort?.startDate ?? new Date(saltSeed + 7 * ONE_DAY); // 7 days in the future + const endDate = overrides.cohort?.endDate ?? new Date(saltSeed + 14 * ONE_DAY); // 14 days in the future const salt = overrides.username ?? `test-user-${saltSeed}`; @@ -39,9 +42,12 @@ export const getNewTestUser = (overrides: Partial = {}): TestUserD mobile: overrides.mobile ?? '+4712345678', role: overrides.role ?? 0, specialism: overrides.specialism ?? `Test-developer ${saltSeed}`, - cohort: overrides.cohort ?? 'Cohort 1', - startDate, - endDate, + cohort: { + id:1, + title: 'Cohort 1', + startDate: startDate, + endDate: endDate + }, bio: overrides.bio ?? `Test-developer bio with salt: ${saltSeed}` }; }; From b509784fc6a2513525fe6f8532be1c11ac70e653 Mon Sep 17 00:00:00 2001 From: otvegg <78576061+otvegg@users.noreply.github.com> Date: Thu, 25 Sep 2025 11:35:50 +0000 Subject: [PATCH 2/6] chore: apply linter autofixes --- src/components/header/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/header/index.js b/src/components/header/index.js index b5a6a03..0f89717 100644 --- a/src/components/header/index.js +++ b/src/components/header/index.js @@ -60,7 +60,9 @@ const Header = () => {

{name}

- {user.specialism}, {user.cohort.title} + + {user.specialism}, {user.cohort.title} +
From 50ddf67e62242b91589837e1e66d3218a1485f29 Mon Sep 17 00:00:00 2001 From: Oyvind Timian Dokk Husveg Date: Thu, 25 Sep 2025 14:20:56 +0200 Subject: [PATCH 3/6] Blala --- src/pages/profile/trainingInfo/index.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/profile/trainingInfo/index.jsx b/src/pages/profile/trainingInfo/index.jsx index a7f1545..2d1f9f0 100644 --- a/src/pages/profile/trainingInfo/index.jsx +++ b/src/pages/profile/trainingInfo/index.jsx @@ -39,17 +39,17 @@ const ProfileTrainingInfo = ({ name="specialism" value={specialism} onChange={(e) => onChange('specialism', e.target.value)} - className={getInputClass('specialism', isEditing, user.role)} - disabled={!canEditField('specialism', isEditing, user.role)} + className={getInputClass('specialism', isEditing, user.specialism)} + disabled={!canEditField('specialism', isEditing, user.specialism)} /> onChange('cohort', e.target.value)} - className={getInputClass('cohort', isEditing, user.role)} - disabled={!canEditField('cohort', isEditing, user.role)} + className={getInputClass('cohort', isEditing, user.cohort)} + disabled={!canEditField('cohort', isEditing, user.cohort)} /> onChange('startDate', e.target.value)} - className={getInputClass('startDate', isEditing, user.role)} - disabled={!canEditField('startDate', isEditing, user.role)} + className={getInputClass('startDate', isEditing, user.startDate)} + disabled={!canEditField('startDate', isEditing, user.startDate)} /> onChange('endDate', e.target.value)} - className={getInputClass('endDate', isEditing, user.role)} - disabled={!canEditField('endDate', isEditing, user.role)} + className={getInputClass('endDate', isEditing, user.endDate)} + disabled={!canEditField('endDate', isEditing, user.endDate)} />
From b42e30b4acd92a455e4503b9ed6d090ece081843 Mon Sep 17 00:00:00 2001 From: Oyvind Timian Dokk Husveg Date: Thu, 25 Sep 2025 14:29:13 +0200 Subject: [PATCH 4/6] Removed cohort from patch object --- src/pages/profile/ProfilePage.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index 3708e2c..3467a6d 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -70,7 +70,10 @@ const ProfilePage = () => { const toggleEdit = () => { if (isEditing) { tempCurrentUser.id = pathParamId || user.id; - onPatchProfile(tempCurrentUser); + const{ cohort, ...tempCurrentUserWithoutCohort} = tempCurrentUser; + + console.log(tempCurrentUserWithoutCohort); + onPatchProfile(tempCurrentUserWithoutCohort); if (!pathParamId || String(pathParamId) === String(user.id)) { const { password, ...userWithoutPassword } = tempCurrentUser; From 09322a70e7e24d1dc0866ea9adc06edc396c746e Mon Sep 17 00:00:00 2001 From: otvegg <78576061+otvegg@users.noreply.github.com> Date: Thu, 25 Sep 2025 12:29:45 +0000 Subject: [PATCH 5/6] chore: apply linter autofixes --- src/pages/profile/ProfilePage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index 3467a6d..2144118 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -70,7 +70,7 @@ const ProfilePage = () => { const toggleEdit = () => { if (isEditing) { tempCurrentUser.id = pathParamId || user.id; - const{ cohort, ...tempCurrentUserWithoutCohort} = tempCurrentUser; + const { cohort, ...tempCurrentUserWithoutCohort } = tempCurrentUser; console.log(tempCurrentUserWithoutCohort); onPatchProfile(tempCurrentUserWithoutCohort); From 77b91856608e0d323b3fa1423488eeb45b8b0399 Mon Sep 17 00:00:00 2001 From: reduan-azouaghe Date: Thu, 25 Sep 2025 14:33:44 +0200 Subject: [PATCH 6/6] Update ProfilePage.jsx --- src/pages/profile/ProfilePage.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index 2144118..989cc85 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -71,8 +71,6 @@ const ProfilePage = () => { if (isEditing) { tempCurrentUser.id = pathParamId || user.id; const { cohort, ...tempCurrentUserWithoutCohort } = tempCurrentUser; - - console.log(tempCurrentUserWithoutCohort); onPatchProfile(tempCurrentUserWithoutCohort); if (!pathParamId || String(pathParamId) === String(user.id)) {