Components

Profile

<Profile />

Constructor

# <Profile />

Functional component for displaying the student's profile page

Parameters:
Name Type Description
props React.FC.<Props>

React props object

View Source components/users/Profile.js, line 21

The profile page of the user

React.ReactElement

Methods

# async inner deleteUser(e)

Asynchronous function for deleting the user's profile. This function is called when the user clicks on the delete account button.

Parameters:
Name Type Description
e React.MouseEvent.<HTMLButtonElement, MouseEvent>

The event object of the form

View Source components/users/Profile.js, line 190

# async inner getUser() → {Object}

Asynchronous function for fetching the user's profile based on the URL parameter containing the user's ID

View Source components/users/Profile.js, line 43

The user's object

Object

# inner handleInstructorProfileChange(event)

Function that handles the change between user's profile and instructor's profile. This function dispatches a reducer action with a 'SET_INSTRUCTOR_PROFILE' type and a payload of the field name and value that was changed.

Parameters:
Name Type Description
event React.ChangeEvent.<HTMLInputElement>

The event object of the click event

View Source components/users/Profile.js, line 257

Example
const handleInstructorProfileChange = (event) => {
	instructor.dispatch({
		type: 'SET_INSTRUCTOR_PROFILE',
		payload: { [event.target.name]: event.target.value },
	})
}
//returns [...{title: "Chair of the Department of Computer Science"}]

return (
<input
	type="text"
	name="title"
	value="Chair of the Department of Computer Science"
	onChange={(event) => handleInstructorProfileChange(event)}
/>
)

# inner toggleInstructor(usr)

Helper function for checking if the user has any enrollments as an instructor.

Parameters:
Name Type Description
usr Object

The user's profile object

View Source components/users/Profile.js, line 221

# async inner updateUser(e)

Asynchronous function for updating the user's profile. This function is called when the user submits the update profile form.

Parameters:
Name Type Description
e React.MouseEvent.<HTMLButtonElement, MouseEvent>

The event object of the form

View Source components/users/Profile.js, line 87