Purpose: To add a component to your React app that uses your AuthContext to protect unauthorized content. In Exercise 6.3, you created an @access_required route on the back end that gives an API error response when a user's authorization is beneath a certain level. Since the front end is a UI, not an API, two useful functions for unauthorized content are (1) hiding content, and (2) redirecting pages. You will create a component that can do either and can be placed anywhere.
The AccessRequired component below has two props: minLevel (setting the minimum access level) and redirect (specifying where to redirect). When the redirect prop is empty, it simply hides any content wrapped within it when access is less than minLevel. When the redirect prop has a value, a <Navigate> component is used to redirect when access is less than minLevel.