Routing configuration - MukeshKumar101/IPL_Auction GitHub Wiki

Problem Statement:

To write routing configuration for application	

Jobs to be Done

  1. Create Protected Route
  2. Validate route based on permission

Implementation Plan

Create Protected Route

  1. Create add.route.js
  2. Create component ProtectedRoute
  3. Pass arguments like component as Component, role, path, properties of component using rest operator ..rest
  4. ProtectedRoute should return a Route

Validate route based on permission

  1. Import 'path.json' file as permission
  2. Define a validatePath method in add.route.js
  3. Pass permission, role, path as arguments to validatePath method
  4. In validatePath(permission, role, path)
    1. Get index of given path by indexOf() and store it in a variable index
    2. If index is not equal to -1, return true
    3. Else return false
  5. Get the return value by invoking validatePath(permission, role, path) and store in a variable isAllowed
  6. Pass path and properties of component to Route in render() method of ProtectedRoute component.
  7. If isAllowed is true, then render <Component>
  8. And Pass props to <Component {..props}>
  9. Else Redirect to '/' page