From a580f2c199aa3347a79121fb611a72cbdd11c383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Sun, 27 Nov 2022 20:54:30 -0300 Subject: [PATCH] Initial structure for professor home screen --- src/app/ProfessorRoutes.js | 3 +- src/screens/professor/Home/View.js | 123 +++++++++++++++++++++++++++ src/screens/professor/Home/index.js | 38 +++++++++ src/screens/professor/Home/styles.js | 31 +++++++ 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 src/screens/professor/Home/View.js create mode 100644 src/screens/professor/Home/index.js create mode 100644 src/screens/professor/Home/styles.js 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/screens/professor/Home/View.js b/src/screens/professor/Home/View.js new file mode 100644 index 0000000..64046f5 --- /dev/null +++ b/src/screens/professor/Home/View.js @@ -0,0 +1,123 @@ +import { Grid, Skeleton, Stack } from '@mui/material'; +import { Container } from '@mui/system'; +import ClassCard from '../../../components/ClassCard'; +import { createArrayFrom1ToN } from '../../../utils/createArrayFrom1ToN'; +import styles from './styles'; + +function View({ layoutType, classrooms, onClickClassCard }) { + const { container, divider, assignmentsStack } = 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

+

Atribuídas

+ +

Atividade 1

+

Atividade 2

+
+
+
+ ); + } 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

+

Atribuídas

+ +

Atividade 1

+

Atividade 2

+
+
+ ); + } +} + +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..91eddc3 --- /dev/null +++ b/src/screens/professor/Home/index.js @@ -0,0 +1,38 @@ +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 { fetchClassrooms } = useUser(); + const [classrooms, setClassrooms] = useState(null); + + useEffect(() => { + async function getClassrooms() { + const result = await fetchClassrooms(); + setClassrooms(result.data); + } + getClassrooms(); + }, [fetchClassrooms]); + + const onClickClassCard = id => { + navigate(`/class/${id}`); + }; + + console.log(classrooms); + + 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..1a8a842 --- /dev/null +++ b/src/screens/professor/Home/styles.js @@ -0,0 +1,31 @@ +// ========== Desktop ========== +const desktopContainer = { + height: '100vh', + margin: 0, +}; + +const desktop = { + container: desktopContainer, +}; + +// ========== Mobile ========== +const mobileContainer = { + height: 'inherit', + width: '100%', + padding: '10px 20px ', + margin: 0, +}; + +const mobile = { + container: mobileContainer, +}; + +// ========== Unset ========== +const unset = { + container: null, + divider: null, + assignmentsStack: null, +}; + +const styles = { desktop, mobile, unset }; +export default styles;