Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const Header = () => {

<div className="post-user-name">
<p>{name}</p>
<small>{user.specialism}, Cohort 3</small>
<small>
{user.specialism}, {user.cohort.title}
</small>
</div>
</section>

Expand Down
7 changes: 4 additions & 3 deletions src/pages/profile/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}
/>
Expand Down
18 changes: 9 additions & 9 deletions src/pages/profile/trainingInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@ 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)}
/>

<TextInput
label="Cohort"
name="cohort"
value={cohort}
value={cohort.title}
onChange={(e) => 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)}
/>

<TextInput
label="Start Date"
name="startDate"
value={startDate}
onChange={(e) => 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)}
/>

<TextInput
label="End Date"
name="endDate"
value={endDate}
onChange={(e) => 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)}
/>
</div>
</section>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/search/StudentSearchView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const StudentSearchView = () => {
{u.firstName} {u.lastName}
</p>
{/* Empty cohorts get a random cohort to ensure nice formatting */}
<p>{u.cohort ? u.cohort : 'Software Developer, Cohort 69'}</p>
<p>{u.cohort.title ? u.cohort.title : 'Software Developer, Cohort 69'}</p>
</div>
<div style={{ cursor: 'pointer' }} onClick={() => navigate(`/profile/${u.id}`)}>
Profile
Expand All @@ -133,7 +133,7 @@ const StudentSearchView = () => {
{u.firstName} {u.lastName}
</p>
{/* Empty cohorts get a random cohort to ensure nice formatting */}
<p>{u.cohort ? u.cohort : 'Software Developer, Cohort 69'}</p>
<p>{u.cohort.title ? u.cohort.title : 'Software Developer, Cohort 69'}</p>
</div>
</div>
<div
Expand Down
22 changes: 14 additions & 8 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ export interface TestUserData {
mobile: string;
role: number;
specialism: string;
cohort: string;
startDate: Date;
endDate: Date;
cohort: {
id:number,
title:string,
startDate: Date,
endDate: Date
};
bio: string;
}

Expand All @@ -24,8 +27,8 @@ export const getNewTestUser = (overrides: Partial<TestUserData> = {}): 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}`;

Expand All @@ -39,9 +42,12 @@ export const getNewTestUser = (overrides: Partial<TestUserData> = {}): 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}`
};
};
Expand Down
Loading