-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reject teacher from joinig own course + add is teacher checkbox * serve two different interfaces based on premissions * modify tests to pass with isTeacher * Update users.js Fix indentation inconsistency * remove comment in seeder --------- Co-authored-by: Nils Streedain <tannins_berets_0@icloud.com>
- Loading branch information
1 parent
fe24e77
commit d05c9e4
Showing
18 changed files
with
171 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ function useCourses() { | |
populateCourses() | ||
} | ||
}, []) | ||
|
||
|
||
return [courses, message, error, loading] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,21 @@ | ||
import React from 'react'; | ||
import CourseCard from '../components/CourseCard' | ||
import { Button, Card } from "react-bootstrap" | ||
import useCourses from '../hooks/useCourses' | ||
import Notice from '../components/Notice' | ||
import JoinCourse from '../components/JoinCourse' | ||
import { Link } from 'react-router-dom'; | ||
import { TailSpin } from 'react-loader-spinner' | ||
import TeacherLanding from './TeacherLanding'; | ||
import StudentLanding from './StudentLanding'; | ||
import apiUtil from '../utils/apiUtil' | ||
import { useSelector, useDispatch } from 'react-redux' | ||
import { getUserState } from '../redux/selectors' | ||
|
||
function Landing(props) { | ||
// Will implement ability to hide/show once we figure out best way to modify the | ||
|
||
const [ courses, message, error, loading ] = useCourses() | ||
|
||
// cards for student and teacher courses | ||
return( | ||
//const { user } = useAuth(); // Assuming you have access to the user's role through an authentication context | ||
//const user = await apiUtil('post', 'users/#', { dispatch: dispatch, navigate: navigate }, user) | ||
const user = useSelector(getUserState) | ||
console.log(user ) | ||
console.log(user.user.isTeacher) | ||
return ( | ||
<div className="landing-page"> | ||
{/*No Courses*/} | ||
{ message ? <Notice error={error ? "error" : ""} message={message}/> : (!courses.studentCourses && !courses.instructorCourses) ? <Notice message={"You do not have any courses yet"}/> : <></>} | ||
{/*Join Course button for all users*/} | ||
<JoinCourse className="buttons"/> | ||
|
||
{/*Student Courses*/} | ||
{ loading ? <TailSpin visible={true}/> : <div className="all-courses"> | ||
{courses.studentCourses != null && <div id="student-courses"> | ||
<p id="landing-subtitle" >Student Courses</p> | ||
<hr></hr> | ||
|
||
<div className='courses'> | ||
{courses.studentCourses.map((studentCourse) => { | ||
return <CourseCard key={studentCourse.id} course={studentCourse} role={"student"} /> | ||
})} | ||
</div> | ||
</div>} | ||
|
||
{/*Teacher Courses*/} | ||
{courses.teacherCourses && <div id="teacher-courses"> | ||
<Link id="create-course-btn" to={`/createcourse`}> | ||
<Button variant="primary" className='btn-add'>Create Course</Button> | ||
</Link> | ||
|
||
<p id="landing-subtitle">Instructor Courses</p> | ||
<hr></hr> | ||
|
||
<div className='courses'> | ||
{courses.teacherCourses.map((teacherCourse) => { | ||
return <CourseCard key={teacherCourse.id} course={teacherCourse} role={"teacher"} /> | ||
})} | ||
</div> | ||
</div>} | ||
</div>} | ||
{user && user.user.isTeacher ? <TeacherLanding /> : <StudentLanding />} | ||
</div> | ||
) | ||
); | ||
} | ||
|
||
export default Landing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,14 +170,10 @@ function #(props){ | |
<p className='mainText'> # </p> | ||
|
||
<#Form /> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
|
||
|
||
export default # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import CourseCard from '../components/CourseCard' | ||
import useCourses from '../hooks/useCourses' | ||
import Notice from '../components/Notice' | ||
import JoinCourse from '../components/JoinCourse' | ||
import { TailSpin } from 'react-loader-spinner' | ||
|
||
function StudentLanding(props) { | ||
|
||
const [courses, message, error, loading] = useCourses() | ||
|
||
// cards for student and teacher courses | ||
return ( | ||
<div className="Student-landing-page"> | ||
{/*No Courses*/} | ||
{message ? <Notice error={error ? "error" : ""} message={message} /> : (!courses.studentCourses && !courses.instructorCourses) ? <Notice message={"You do not have any courses yet"} /> : <></>} | ||
{/*Join Course button for all users*/} | ||
<JoinCourse className="buttons" /> | ||
|
||
{/*Student Courses*/} | ||
{loading ? <TailSpin visible={true} /> : <div className="all-courses"> | ||
{courses.studentCourses != null && <div id="student-courses"> | ||
<p id="landing-subtitle" >Student Courses</p> | ||
<hr></hr> | ||
|
||
<div className='courses'> | ||
{courses.studentCourses.map((studentCourse) => { | ||
return <CourseCard key={studentCourse.id} course={studentCourse} role={"student"} /> | ||
})} | ||
</div> | ||
</div>} | ||
</div>} | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default StudentLanding; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import CourseCard from '../components/CourseCard' | ||
import { Button, Card } from "react-bootstrap" | ||
import useCourses from '../hooks/useCourses' | ||
import Notice from '../components/Notice' | ||
import { Link } from 'react-router-dom'; | ||
|
||
function TeacherLanding(props) { | ||
|
||
const [courses, message, error, loading] = useCourses() | ||
|
||
return ( | ||
<div className="Teacher-landing-page"> | ||
{/*No Courses*/} | ||
{message ? <Notice error={error ? "error" : ""} message={message} /> : (!courses.studentCourses && !courses.instructorCourses) ? <Notice message={"You do not have any courses yet"} /> : <></>} | ||
|
||
{/*Teacher Courses*/} | ||
{courses.teacherCourses && <div id="teacher-courses"> | ||
<Link id="create-course-btn" to={`/createcourse`}> | ||
<Button variant="primary" className='btn-add'>Create Course</Button> | ||
</Link> | ||
|
||
<p id="landing-subtitle">Instructor Courses</p> | ||
<hr></hr> | ||
|
||
<div className='courses'> | ||
{courses.teacherCourses.map((teacherCourse) => { | ||
return <CourseCard key={teacherCourse.id} course={teacherCourse} role={"teacher"} /> | ||
})} | ||
</div> | ||
</div>} | ||
</div> | ||
) | ||
} | ||
|
||
export default TeacherLanding; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.