diff --git a/src/app/ProfessorRoutes.js b/src/app/ProfessorRoutes.js index 419cb42..cec7984 100644 --- a/src/app/ProfessorRoutes.js +++ b/src/app/ProfessorRoutes.js @@ -1,4 +1,5 @@ import { Navigate, Route, Routes } from 'react-router-dom'; +import Home from '../screens/professor/Home'; function ProfessorRoutes() { return ( @@ -6,7 +7,7 @@ function ProfessorRoutes() { Calendar} /> Profile} /> Information} /> - Home} /> + } /> } /> } /> } /> diff --git a/src/components/AssignmentCard/index.js b/src/components/AssignmentCard/index.js index e893b3d..fc5758b 100644 --- a/src/components/AssignmentCard/index.js +++ b/src/components/AssignmentCard/index.js @@ -18,6 +18,10 @@ function AssignmentCard({ classrooms, dueDate, scores, + deliveredByStudents, + reviewed, + total, + isAssignmentToReview, layoutType, onClick, }) { @@ -61,16 +65,30 @@ function AssignmentCard({ {classrooms.map(c => c.name).join(', ')} + Data de entrega: {' '} {capitalizeFirstLetter( dayjs(dueDate).format('dddd, DD/MM | HH:mm[h]') )} - - Valor: - {scores.map(s => s.value).join(', ')} pts - + {deliveredByStudents >= 0 && total && ( + + Entregues: {' '} + {`${deliveredByStudents} de ${total}`} + + )} + {reviewed >= 0 && total && ( + + Corrigidas: {`${reviewed} de ${total}`} + + )} + {!isAssignmentToReview && ( + + Valor: + {scores.map(s => s.value).join(', ')} pts + + )} @@ -110,10 +128,23 @@ function AssignmentCard({ dayjs(dueDate).format('dddd, DD/MM | HH:mm[h]') )} - - Valor: - {scores.map(s => s.value).join(', ')} pts - + {deliveredByStudents >= 0 && total && ( + + Entregues: {' '} + {`${deliveredByStudents} de ${total}`} + + )} + {reviewed >= 0 && total && ( + + Corrigidas: {`${reviewed} de ${total}`} + + )} + {!isAssignmentToReview && ( + + Valor: + {scores.map(s => s.value).join(', ')} pts + + )} diff --git a/src/components/ClassCard/index.js b/src/components/ClassCard/index.js index 79bf495..6c78254 100644 --- a/src/components/ClassCard/index.js +++ b/src/components/ClassCard/index.js @@ -17,6 +17,7 @@ function ClassCard({ title, color, teachers, + course, layoutType, onClick, }) { @@ -45,23 +46,30 @@ function ClassCard({ > {title} - - - {teachers.map(t => ( - - ))} - - t.name).join(', ')}> - - {teachers.map(t => t.name).join(', ')} - - - + {teachers && ( + + + {teachers.map(t => ( + + ))} + + t.name).join(', ')}> + + {teachers.map(t => t.name).join(', ')} + + + + )} + {course && {course}} @@ -82,21 +90,24 @@ function ClassCard({ > {title} - - - {teachers.map(t => ( - - ))} - - - {teachers.map(t => t.name).join(', ')} - - + {teachers && ( + + + {teachers.map(t => ( + + ))} + + + {teachers.map(t => t.name).join(', ')} + + + )} + {course && {course}} diff --git a/src/context/auth.js b/src/context/auth.js index fd5104b..59ccd82 100644 --- a/src/context/auth.js +++ b/src/context/auth.js @@ -1,5 +1,5 @@ import { createContext, useContext, useEffect, useState } from 'react'; -import { getUser, registerUser } from '../services/user-service'; +import { CommonApi } from '../utils/mocks/api'; const AuthContext = createContext(); @@ -23,7 +23,7 @@ function AuthProvider(props) { const register = data => { setState({ ...state, status: 'pending' }); - return registerUser(data).then(data => { + return CommonApi.registerUser(data).then(data => { if (data.message) { return setState({ status: 'error', user: null, error: data }); } else { @@ -35,7 +35,7 @@ function AuthProvider(props) { const login = (email, password) => { setState({ ...state, status: 'pending' }); - return getUser(email, password).then(data => { + return CommonApi.getUser(email, password).then(data => { if (data.message) { return setState({ status: 'error', user: null, error: data }); } else { diff --git a/src/context/user.js b/src/context/user.js index 23a3df4..4225201 100644 --- a/src/context/user.js +++ b/src/context/user.js @@ -1,23 +1,14 @@ import { createContext, useContext, useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; +import { UserServiceProvider } from '../services/provider'; import { useAuthState } from './auth'; -import { - getAllAssignments, - getAssignmentById, - getAssignmentsByClassId, - getClassroomAnnouncementsById, - getClassroomById, - getClassrooms, - getFaq, - getPeopleByClassId, - getUpcomingAssignmentsByClassId, -} from '../services/user-service'; const UserContext = createContext(); function UserProvider(props) { const { user } = useAuthState(); const { pathname } = useLocation(); + const [userService, setUserService] = useState(null); const [state, setState] = useState({ user: null, error: null, @@ -26,73 +17,23 @@ function UserProvider(props) { useEffect(() => { setState({ user, pathname }); + + async function initUserService() { + if (user) { + const instance = await UserServiceProvider.getInstance(user); + setUserService(instance); + } + } + initUserService(); }, [user, pathname]); - const fetchClassrooms = () => getClassrooms(user.id); - - const fetchAllAssignments = () => getAllAssignments(user.id); - - const fetchAssignmentById = assignmentId => getAssignmentById(assignmentId); - - const fetchAssignmentsByClassId = classId => getAssignmentsByClassId(classId); - - const fetchClassroomById = classId => getClassroomById(classId); - - const fetchFAQ = () => getFaq(); - - const fetchClassroomAnnouncements = classId => - getClassroomAnnouncementsById(classId); - - const fetchUpcomingAssignmentsByClassId = classId => - getUpcomingAssignmentsByClassId(classId); - - const fetchPeopleByClassId = classId => getPeopleByClassId(classId); - - return ( - - ); + return ; } function useUser() { - const { - state, - fetchClassrooms, - fetchAssignmentById, - fetchAllAssignments, - fetchAssignmentsByClassId, - fetchClassroomById, - fetchFAQ, - fetchClassroomAnnouncements, - fetchUpcomingAssignmentsByClassId, - fetchPeopleByClassId, - } = useContext(UserContext); + const { state, userService } = useContext(UserContext); - return { - state, - fetchClassrooms, - fetchAllAssignments, - fetchAssignmentById, - fetchAssignmentsByClassId, - fetchClassroomById, - fetchFAQ, - fetchClassroomAnnouncements, - fetchUpcomingAssignmentsByClassId, - fetchPeopleByClassId, - }; + return { state, userService }; } export { UserProvider, useUser }; diff --git a/src/screens/Assignment/index.js b/src/screens/Assignment/index.js index 3559d3b..3357c2b 100644 --- a/src/screens/Assignment/index.js +++ b/src/screens/Assignment/index.js @@ -8,14 +8,14 @@ import View from './View'; function Assignment() { const params = useParams(); const layoutType = useLayoutType(); - const { fetchAssignmentById } = useUser(); + const { userService } = useUser(); const [assignment, setAssignment] = useState(null); const dropzone = useDropzone({ maxFiles: 5 }); useEffect(() => { async function getAssignmentById(assignmentId) { document.title = 'Carregando...'; - const result = await fetchAssignmentById(assignmentId); + const result = await userService.fetchAssignmentById(assignmentId); setAssignment(result.data); } @@ -27,7 +27,7 @@ function Assignment() { getAssignmentById(params.id); updateDocumentTitle(); - }, [params, fetchAssignmentById, assignment]); + }, [params, userService, userService.fetchAssignmentById, assignment]); return ( diff --git a/src/screens/Classroom/index.js b/src/screens/Classroom/index.js index 7410515..10fc044 100644 --- a/src/screens/Classroom/index.js +++ b/src/screens/Classroom/index.js @@ -8,13 +8,7 @@ import View from './View'; function Classroom() { const params = useParams(); const layoutType = useLayoutType(); - const { - fetchClassroomById, - fetchClassroomAnnouncements, - fetchUpcomingAssignmentsByClassId, - fetchAssignmentsByClassId, - fetchPeopleByClassId, - } = useUser(); + const { userService } = useUser(); const [classroom, setClassroom] = useState(null); const [tabData, setTabData] = useState(null); const [selectedTabOption, setSelectedTabOption] = useState( @@ -23,10 +17,11 @@ function Classroom() { const fetchAndPopulateAnnouncementsTabData = useCallback(async () => { setTabData({ tab: 'announcements', state: 'loading' }); - const announcements = await fetchClassroomAnnouncements(params.id); - const upcomingAssignments = await fetchUpcomingAssignmentsByClassId( + const announcements = await userService.fetchClassroomAnnouncements( params.id ); + const upcomingAssignments = + await userService.fetchUpcomingAssignmentsByClassId(params.id); setTabData({ tab: 'announcements', @@ -34,33 +29,29 @@ function Classroom() { announcements: [...announcements.data], upcomingAssignments: [...upcomingAssignments.data], }); - }, [ - fetchClassroomAnnouncements, - fetchUpcomingAssignmentsByClassId, - params.id, - ]); + }, [userService, params.id]); const fetchAndPopulateAssignmentsTabData = useCallback(async () => { setTabData({ tab: 'assignments', state: 'loading' }); - const assignments = await fetchAssignmentsByClassId(params.id); + const assignments = await userService.fetchAssignmentsByClassId(params.id); setTabData({ tab: 'assignments', state: 'idle', assignments: [...assignments.data], }); - }, [fetchAssignmentsByClassId, params.id]); + }, [userService, params.id]); const fetchAndPopulatePoepleTabData = useCallback(async () => { setTabData({ tab: 'people', state: 'loading' }); - const people = await fetchPeopleByClassId(params.id); + const people = await userService.fetchPeopleByClassId(params.id); setTabData({ tab: 'people', state: 'idle', people: [...people.data], }); - }, [fetchPeopleByClassId, params.id]); + }, [userService, params.id]); useEffect(() => { async function getSelectedTabData() { @@ -90,7 +81,7 @@ function Classroom() { useEffect(() => { async function getClassroomById(classId) { document.title = 'Carregando...'; - const result = await fetchClassroomById(classId); + const result = await userService.fetchClassroomById(classId); setClassroom(result.data); } @@ -102,7 +93,7 @@ function Classroom() { getClassroomById(params.id); updateDocumentTitle(); - }, [fetchClassroomById, params, classroom]); + }, [userService, userService.fetchClassroomById, params, classroom]); return ( { async function getClassrooms() { - const result = await fetchClassrooms(); + const result = await userService.fetchClassrooms(); setClassrooms(result.data); } getClassrooms(); - }, [fetchClassrooms]); + }, [userService, userService.fetchClassrooms]); useEffect(() => { async function getAssignments() { - const result = await fetchAllAssignments(); + const result = await userService.fetchAllAssignments(); setAssignments(result.data); } getAssignments(); - }, [fetchAllAssignments]); + }, [userService, userService.fetchAllAssignments]); const onClickClassCard = id => { navigate(`/class/${id}`); diff --git a/src/screens/Information/index.js b/src/screens/Information/index.js index b1f7965..1042060 100644 --- a/src/screens/Information/index.js +++ b/src/screens/Information/index.js @@ -9,16 +9,16 @@ import { sectors } from './data'; function Information() { useDocumentTitle('Informações'); const layoutType = useLayoutType(); - const { fetchFAQ } = useUser(); + const { userService } = useUser(); const [faq, setFaq] = useState(null); useEffect(() => { async function getClassrooms() { - const result = await fetchFAQ(); + const result = await userService.fetchFAQ(); setFaq(result.data); } getClassrooms(); - }, [fetchFAQ]); + }, [userService, userService.fetchFAQ]); return ; } diff --git a/src/screens/professor/Home/View.js b/src/screens/professor/Home/View.js new file mode 100644 index 0000000..0651aea --- /dev/null +++ b/src/screens/professor/Home/View.js @@ -0,0 +1,200 @@ +import { Grid, Skeleton, Stack } from '@mui/material'; +import { Container } from '@mui/system'; +import AssignmentCard from '../../../components/AssignmentCard'; +import ClassCard from '../../../components/ClassCard'; +import { createArrayFrom1ToN } from '../../../utils/createArrayFrom1ToN'; +import styles from './styles'; + +function View({ + layoutType, + classrooms, + assignmentsToReview, + onClickClassCard, +}) { + const { container, divider, assignmentsStack, onClickAssignmentCard } = + styles[layoutType]; + + if (layoutType === 'desktop') { + return ( + + +

Minhas Turmas

+ + {classrooms === null ? ( + createArrayFrom1ToN(6).map(i => ( + + )) + ) : classrooms.length !== 0 ? ( + classrooms.map(classroom => ( + onClickClassCard(classroom.id)} + /> + )) + ) : ( + +

Nenhuma sala de aula encontrada!

+
+ )} +
+
+ +

Atividades para corrigir

+ + {assignmentsToReview === null ? ( + createArrayFrom1ToN(6).map(i => ( + + )) + ) : assignmentsToReview.length !== 0 ? ( + assignmentsToReview.map(assignment => ( + onClickAssignmentCard(assignment.id)} + /> + )) + ) : ( + +

Nenhuma atividade encontrada!

+
+ )} +
+
+
+ ); + } else if (layoutType === 'mobile') { + return ( + +

Minhas Turmas

+ + {classrooms === null ? ( + createArrayFrom1ToN(6).map(i => ( + + )) + ) : classrooms.length !== 0 ? ( + classrooms.map(classroom => ( + onClickClassCard(classroom.id)} + /> + )) + ) : ( + +

Nenhuma sala de aula encontrada!

+
+ )} +
+

Atividades para corrigir

+ + {assignmentsToReview === null ? ( + createArrayFrom1ToN(6).map(i => ( + + )) + ) : assignmentsToReview.length !== 0 ? ( + assignmentsToReview.map(assignment => ( + onClickAssignmentCard(assignment.id)} + /> + )) + ) : ( + +

Nenhuma atividade encontrada!

+
+ )} +
+
+ ); + } +} + +export default View; diff --git a/src/screens/professor/Home/index.js b/src/screens/professor/Home/index.js new file mode 100644 index 0000000..d16c20d --- /dev/null +++ b/src/screens/professor/Home/index.js @@ -0,0 +1,51 @@ +import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { useUser } from '../../../context/user'; +import { useDocumentTitle } from '../../../hooks/useDocumentTitle'; +import useLayoutType from '../../../hooks/useLayoutType'; +import View from './View'; + +function Home() { + useDocumentTitle('Página Inicial'); + const navigate = useNavigate(); + const layoutType = useLayoutType(); + const { userService } = useUser(); + const [classrooms, setClassrooms] = useState(null); + const [assignmentsToReview, setAssignmentsToReview] = useState(null); + + useEffect(() => { + async function getClassrooms() { + const result = await userService.fetchClassrooms(); + setClassrooms(result.data); + } + getClassrooms(); + }, [userService, userService.fetchClassrooms]); + + useEffect(() => { + async function getAssignmentsToReview() { + const result = await userService.fetchAssignmentsToReview(); + setAssignmentsToReview(result.data); + } + getAssignmentsToReview(); + }, [userService, userService.fetchAllAssignments]); + + const onClickClassCard = id => { + navigate(`/class/${id}`); + }; + + const onClickAssignmentCard = id => { + navigate(`/assignment/${id}`); + }; + + return ( + + ); +} + +export default Home; diff --git a/src/screens/professor/Home/styles.js b/src/screens/professor/Home/styles.js new file mode 100644 index 0000000..cd02a41 --- /dev/null +++ b/src/screens/professor/Home/styles.js @@ -0,0 +1,42 @@ +// ========== Desktop ========== +const desktopContainer = { + height: '100vh', + margin: 0, +}; + +const desktopDivider = { + borderLeft: '4px solid #CFCFCF', +}; + +const desktop = { + container: desktopContainer, + divider: desktopDivider, +}; + +// ========== Mobile ========== +const mobileContainer = { + height: 'inherit', + width: '100%', + padding: '10px 20px ', + margin: 0, +}; + +const mobileDivider = { + borderTop: '2px solid #CFCFCF', + paddingTop: '15px', +}; + +const mobile = { + container: mobileContainer, + divider: mobileDivider, +}; + +// ========== Unset ========== +const unset = { + container: null, + divider: null, + assignmentsStack: null, +}; + +const styles = { desktop, mobile, unset }; +export default styles; diff --git a/src/services/professor.js b/src/services/professor.js new file mode 100644 index 0000000..3599f67 --- /dev/null +++ b/src/services/professor.js @@ -0,0 +1,12 @@ +import { ProfessorApi } from '../utils/mocks/api'; + +export default class ProfessorService { + constructor(user) { + this.user = user; + } + + fetchClassrooms = () => ProfessorApi.getClassrooms(this.user.id); + + fetchAssignmentsToReview = () => + ProfessorApi.getAssignmentsToReview(this.user.id); +} diff --git a/src/services/provider.js b/src/services/provider.js new file mode 100644 index 0000000..038bf5c --- /dev/null +++ b/src/services/provider.js @@ -0,0 +1,31 @@ +export const UserServiceProvider = (function () { + let instance; + + async function createInstance(user) { + switch (user.role) { + case 'STUDENT': + const studentService = await import('./student'); + if (studentService) { + return new studentService.default(user); + } + break; + case 'PROFESSOR': + const professorService = await import('./professor'); + if (professorService) { + return new professorService.default(user); + } + break; + default: + throw new Error('Invalid Role!'); + } + } + + return { + getInstance: async function (user) { + if (!instance) { + instance = await createInstance(user); + } + return instance; + }, + }; +})(); diff --git a/src/services/student.js b/src/services/student.js new file mode 100644 index 0000000..294edd3 --- /dev/null +++ b/src/services/student.js @@ -0,0 +1,29 @@ +import { StudentApi } from '../utils/mocks/api'; + +export default class StudentService { + constructor(user) { + this.user = user; + } + + fetchClassrooms = () => StudentApi.getClassrooms(this.user.id); + + fetchAllAssignments = () => StudentApi.getAllAssignments(this.user.id); + + fetchAssignmentById = assignmentId => + StudentApi.getAssignmentById(assignmentId); + + fetchAssignmentsByClassId = classId => + StudentApi.getAssignmentsByClassId(classId); + + fetchClassroomById = classId => StudentApi.getClassroomById(classId); + + fetchFAQ = () => StudentApi.getFaq(); + + fetchClassroomAnnouncements = classId => + StudentApi.getClassroomAnnouncementsById(classId); + + fetchUpcomingAssignmentsByClassId = classId => + StudentApi.getUpcomingAssignmentsByClassId(classId); + + fetchPeopleByClassId = classId => StudentApi.getPeopleByClassId(classId); +} diff --git a/src/services/user-service.js b/src/services/user-service.js deleted file mode 100644 index 0f0fb92..0000000 --- a/src/services/user-service.js +++ /dev/null @@ -1,128 +0,0 @@ -import { sleep } from '../utils/sleep'; -import { - allClassrooms, - allAssignments, - faq, - studentUser, - professorUser, - authFailure, - allClassroomAnnouncements, - allUpcomingAssignments, - allPeople, -} from './mocks'; - -const getClassrooms = userId => - sleep(300).then(() => { - console.log('Get classrooms ' + userId); - return { - data: allClassrooms, - }; - }); - -const getClassroomById = classId => - sleep(300).then(() => { - console.log('Get classroom by id ' + classId); - return { - data: allClassrooms.filter(c => c.id === classId)[0], - }; - }); - -const getClassroomAnnouncementsById = classId => - sleep(300).then(() => { - console.log('Get classroon announcements by id ' + classId); - return { - data: allClassroomAnnouncements.filter(c => c.classroom.id === classId), - }; - }); - -const getUpcomingAssignmentsByClassId = classId => - sleep(300).then(() => { - console.log('Getting upcoming assignments by class id ' + classId); - return { - data: allUpcomingAssignments.filter( - a => a.classrooms.filter(c => c.id === classId)[0] - ), - }; - }); - -const getAllAssignments = userId => - sleep(400).then(() => { - console.log('Getting all assignments ' + userId); - return { - data: allAssignments, - }; - }); - -const getAssignmentById = assignmentId => - sleep(400).then(() => { - console.log('Getting assignment by id ' + assignmentId); - return { - data: allAssignments.filter(a => a.id === assignmentId)[0], - }; - }); - -const getAssignmentsByClassId = classId => - sleep(300).then(() => { - console.log('Getting assignments by class id ' + classId); - return { - data: allAssignments.filter(a => a.classrooms[0].id === classId), - }; - }); - -const getPeopleByClassId = classId => - sleep(400).then(() => { - console.log('Getting people by class id ' + classId); - return { - data: allPeople.filter(p => p.classes[0].id === classId), - }; - }); - -const getFaq = () => - sleep(300).then(() => { - console.log('Fetching FAQ...'); - return { - data: faq, - }; - }); - -const getUser = (email, password) => - sleep(300).then(() => { - let user; - if (email === 'p@test.com' && password === 'p123') { - user = professorUser; - } else if (email === 's@test.com' && password === 's123') { - user = studentUser; - } else { - return authFailure; - } - window.localStorage.setItem('$USER', JSON.stringify(user)); - return user; - }); - -const registerUser = data => - sleep(300).then(() => { - let userData; - if (data.email === 'p@test.com') { - userData = { ...data, role: 'PROFESSOR' }; - } else if (data.email === 's@test.com') { - userData = { ...data, role: 'STUDENT' }; - } else { - return authFailure; - } - window.localStorage.setItem('$USER', JSON.stringify(data)); - return userData; - }); - -export { - getClassrooms, - getClassroomById, - getAllAssignments, - getAssignmentById, - getAssignmentsByClassId, - getClassroomAnnouncementsById, - getUpcomingAssignmentsByClassId, - getPeopleByClassId, - getFaq, - getUser, - registerUser, -}; diff --git a/src/utils/mocks/api.js b/src/utils/mocks/api.js new file mode 100644 index 0000000..08009c0 --- /dev/null +++ b/src/utils/mocks/api.js @@ -0,0 +1,141 @@ +import { sleep } from '../sleep'; +import { + allClassrooms, + allAssignments, + faq, + studentUser, + professorUser, + authFailure, + allClassroomAnnouncements, + allUpcomingAssignments, + allPeople, + professorClassrooms, + assignmentsToReview, +} from './responses'; + +const CommonApi = { + getUser: (email, password) => + sleep(300).then(() => { + let user; + if (email === 'p@test.com' && password === 'p123') { + user = professorUser; + } else if (email === 's@test.com' && password === 's123') { + user = studentUser; + } else { + return authFailure; + } + window.localStorage.setItem('$USER', JSON.stringify(user)); + return user; + }), + + registerUser: data => + sleep(300).then(() => { + let userData; + if (data.email === 'p@test.com') { + userData = { ...data, role: 'PROFESSOR' }; + } else if (data.email === 's@test.com') { + userData = { ...data, role: 'STUDENT' }; + } else { + return authFailure; + } + window.localStorage.setItem('$USER', JSON.stringify(data)); + return userData; + }), +}; + +const StudentApi = { + ...CommonApi, + getClassrooms: userId => + sleep(300).then(() => { + console.log('Get classrooms ' + userId); + return { + data: allClassrooms, + }; + }), + + getClassroomById: classId => + sleep(300).then(() => { + console.log('Get classroom by id ' + classId); + return { + data: allClassrooms.filter(c => c.id === classId)[0], + }; + }), + + getClassroomAnnouncementsById: classId => + sleep(300).then(() => { + console.log('Get classroon announcements by id ' + classId); + return { + data: allClassroomAnnouncements.filter(c => c.classroom.id === classId), + }; + }), + + getUpcomingAssignmentsByClassId: classId => + sleep(300).then(() => { + console.log('Getting upcoming assignments by class id ' + classId); + return { + data: allUpcomingAssignments.filter( + a => a.classrooms.filter(c => c.id === classId)[0] + ), + }; + }), + + getAllAssignments: userId => + sleep(400).then(() => { + console.log('Getting all assignments ' + userId); + return { + data: allAssignments, + }; + }), + + getAssignmentById: assignmentId => + sleep(400).then(() => { + console.log('Getting assignment by id ' + assignmentId); + return { + data: allAssignments.filter(a => a.id === assignmentId)[0], + }; + }), + + getAssignmentsByClassId: classId => + sleep(300).then(() => { + console.log('Getting assignments by class id ' + classId); + return { + data: allAssignments.filter(a => a.classrooms[0].id === classId), + }; + }), + + getPeopleByClassId: classId => + sleep(400).then(() => { + console.log('Getting people by class id ' + classId); + return { + data: allPeople.filter(p => p.classes[0].id === classId), + }; + }), + + getFaq: () => + sleep(300).then(() => { + console.log('Fetching FAQ...'); + return { + data: faq, + }; + }), +}; + +const ProfessorApi = { + ...CommonApi, + getClassrooms: userId => + sleep(300).then(() => { + console.log('Get classrooms ' + userId); + return { + data: professorClassrooms, + }; + }), + getAssignmentsToReview: userId => + sleep(400).then(() => { + console.log('Getting assignments to review' + userId); + return { + data: assignmentsToReview, + }; + }), +}; + +export { StudentApi, ProfessorApi, CommonApi }; diff --git a/src/services/mocks.js b/src/utils/mocks/responses.js similarity index 89% rename from src/services/mocks.js rename to src/utils/mocks/responses.js index a3bfb97..25eadd3 100644 --- a/src/services/mocks.js +++ b/src/utils/mocks/responses.js @@ -95,6 +95,41 @@ const allClassrooms = [ }, ]; +const professorClassrooms = [ + { + id: '321', + name: 'Introdução à Ciência de Dados', + abbreviation: 'ICD', + color: '#006FF2', + course: 'BSI 2020', + appointmentSlots: [ + { weekDay: 'Quarta-feira', start: '10:00', end: '11:40' }, + { weekDay: 'Sexta-feira', start: '10:00', end: '11:40' }, + ], + }, + { + id: '123', + name: 'Teoria dos Grafos', + abbreviation: 'TDG', + color: '#d30000', + course: 'BSI 2018', + appointmentSlots: [ + { weekDay: 'Quarta-feira', start: '11:00', end: '12:00' }, + { weekDay: 'Segunda-feira', start: '10:00', end: '11:40' }, + ], + }, + { + id: '666', + name: 'Matemática Discreta', + abbreviation: 'MD', + color: '#149b00', + course: 'BSI 2020', + appointmentSlots: [ + { weekDay: 'Quarta-feira', start: '9:00', end: '10:00' }, + ], + }, +]; + const allAssignments = [ { id: '5435', @@ -309,6 +344,80 @@ const allClassroomAnnouncements = [ }, ]; +const assignmentsToReview = [ + { + id: '0123', + type: 'assessment', + title: + 'Prova 1 - Armazenamento de Dados. Python em CD. Armazenamento Analítico', + dueDate: '2022-07-01 23:59', + scores: [ + { + classroomId: '321', + value: 30, + }, + ], + classrooms: professorClassrooms.filter(c => c.id === '321'), + status: 'OPEN', + deliveredByStudents: 10, + reviewed: 6, + total: 30, + }, + { + id: '0128', + type: 'assessment', + title: + 'Prova 2 - Visualização de Dados. Matemática e Estatística em CD. Análise de Dados', + dueDate: '2022-09-01 23:59', + scores: [ + { + classroomId: '321', + value: 30, + }, + ], + classrooms: professorClassrooms.filter(c => c.id === '321'), + status: 'CLOSED', + deliveredByStudents: 30, + reviewed: 1, + total: 30, + }, + { + id: '0129', + type: 'assessment', + title: 'Lista de Exercícios 1 - Caminhos e circuitos', + dueDate: '2022-09-01 23:59', + scores: [ + { + classroomId: '123', + value: 30, + }, + ], + classrooms: professorClassrooms.filter(c => c.id === '123'), + status: 'CLOSED', + deliveredByStudents: 30, + reviewed: 0, + total: 30, + }, + + { + id: '0130', + type: 'assessment', + title: 'Lista de Exercícios 2 - Tabela verdade', + dueDate: '2022-09-01 23:59', + scores: [ + { + classroomId: '666', + value: 30, + }, + ], + classrooms: professorClassrooms.filter(c => c.id === '666'), + status: 'OPEN', + deliveredByStudents: 0, + reviewed: 0, + total: 30, + }, +]; + const allUpcomingAssignments = [ { id: '5435', @@ -582,4 +691,6 @@ export { professorUser, authFailure, allUpcomingAssignments, + professorClassrooms, + assignmentsToReview, };