April 2020
Intermediate to advanced
716 pages
18h 55m
English
The Enroll component will simply contain a button that initiates the enrollment call to the backend, and redirects the user if the server returns successfully with the new enrollment document's ID. This component takes the ID of the associated course as a prop from the parent component from where it is added. This prop will be used while making the create enrollment API call. The Enroll component is defined as shown in the following code.
mern-classroom/client/enrollment/Enroll.js:
export default function Enroll(props) { const [values, setValues] = useState({ enrollmentId: '', error: '', redirect: false }) if(values.redirect){ return (<Redirect to={'/learn/'+values.enrollmentId}/>) } return ( <Button variant="contained" ...Read now
Unlock full access