diff --git a/src/components/header/index.js b/src/components/header/index.js index b407582..0f89717 100644 --- a/src/components/header/index.js +++ b/src/components/header/index.js @@ -60,7 +60,9 @@ 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..989cc85 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -70,7 +70,8 @@ const ProfilePage = () => { const toggleEdit = () => { if (isEditing) { tempCurrentUser.id = pathParamId || user.id; - onPatchProfile(tempCurrentUser); + const { cohort, ...tempCurrentUserWithoutCohort } = tempCurrentUser; + onPatchProfile(tempCurrentUserWithoutCohort); if (!pathParamId || String(pathParamId) === String(user.id)) { const { password, ...userWithoutPassword } = tempCurrentUser; @@ -118,8 +119,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/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)} /> 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}` }; };