Because if the teacher presses a cohort item (In the CohortsList component), it would take the teacher to /cohorts/:cohortId.
And the StudentList only renders the url /cohorts/:cohortId based on the user prop that it receives. And the Teacher does not have a user.cohortId, cause the button was pressed (So the url is dynamic).
Solution
Inside the useEffect. add the following condition to the first client.get:
If student: get the cohort based on the user.cohortId
(else) if teacher: get the cohort based on the urlParams.id
console.log the urlParams to see the key name.
Todo
[ ] Add useParams to StudentList.
[ ] create a condition to check if user is either Student or Teacher.
[ ] Remove const cohortId because it will not be as readable as user.cohortId. (Replace basically)
[ ] Update the function updateStudentsList from issue #120
Wait for issue #120 to be merged, then update respectively - Look at lest todo
Reason
Because if the
teacher
presses a cohort item (In the CohortsList component), it would take theteacher
to/cohorts/:cohortId
.And the StudentList only renders the url /cohorts/:cohortId based on the user prop that it receives. And the
Teacher
does not have a user.cohortId, cause the button was pressed (So the url is dynamic).Solution
Inside the
useEffect
. add the following condition to the firstclient.get
:If student
: get the cohort based on theuser.cohortId
if teacher
: get the cohort based on theurlParams.id
Todo
updateStudentsList
from issue #120Wait for issue #120 to be merged, then update respectively - Look at lest todo