Skip to content

Commit

Permalink
nova homepara cada tipo de usuário usuário
Browse files Browse the repository at this point in the history
  • Loading branch information
yaskisoba committed Dec 13, 2023
1 parent 2264df0 commit 806946c
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 50 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GlobalStyle from "./styles/global";
const App = () => (
<AuthProvider>
<RoutesApp />
<GlobalStyle />
{/* <GlobalStyle /> */}
</AuthProvider>
);

Expand Down
1 change: 1 addition & 0 deletions frontend/src/contexts/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const AuthProvider = ({ children }) => {

const isSuperUser = () => {
const userType = sessionStorage.getItem("superuser");
console.log(userType)
return userType
}

Expand Down
58 changes: 40 additions & 18 deletions frontend/src/pages/Home/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,57 @@
import React from "react";
import { Container, Flex, Stack, Box, Wrap, WrapItem, Button, Center } from "@chakra-ui/react";
import { Container, Flex, Text, HStack, Wrap, WrapItem, Button, Center } from "@chakra-ui/react";
import Header from "../../components/Header/index.js";
import Footer from "../../components/Footer/index.js";
import { ChakraProvider } from "@chakra-ui/react";

import * as C from "./styles";
import { Link } from "react-router-dom";

const Home = () => {
return (
<ChakraProvider>
<Flex direction="column" minH="100vh">
<Header />
<Container flex="1">
<Container flex="1" marginTop='5vh'>
<Center>
<C.titulo>
<Text
textAlign={"center"}
fontSize={"3xl"}
color={"#243A69"}
as={"b"}
>
Bem vindo, administrador!
</Text>
</C.titulo>
</Center>
<Center>
<Button colorScheme='blue' variant='ghost'>
<Link to='/criar-trilha'>Criar trilha</Link>
</Button>
<Button colorScheme='blue' variant='ghost'>
<Link to='/criar-eletiva'>Criar Eletiva </Link>
</Button>
<Button colorScheme='blue' variant='ghost'>
<Link to='/excluir-trilhas'>Excluir trilha</Link>
</Button>
<Button colorScheme='blue' variant='ghost'>
<Link to='/excluir-eletivas'>Excluir eletiva</Link>
</Button>
<Button colorScheme='blue' variant='ghost'>
<Link to='/recommendations'>Recomendações</Link>
</Button>
<HStack marginTop='2vh'>
<Button colorScheme='facebook'>
<Link to='/criar-trilha'>Criar trilha</Link>
</Button>
<Button colorScheme='facebook'>
<Link to='/criar-eletiva'>Criar Eletiva</Link>
</Button>
</HStack>
</Center>

<Center>
<HStack marginTop='2vh'>
<Button colorScheme='facebook'>
<Link to='/excluir-trilhas'>Excluir trilha</Link>
</Button>
<Button colorScheme='facebook'>
<Link to='/excluir-eletivas'>Excluir eletiva</Link>
</Button>
</HStack>
</Center>

<Center>
<HStack marginTop='2vh'>
<Button colorScheme='facebook'>
<Link to='/recommendations'>Recomendações</Link>
</Button>
</HStack>
</Center>
</Container>
<Footer />
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/pages/Home/styles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { chakra, MenuList, MenuItem, Image, Container } from '@chakra-ui/react';
import styled from "styled-components";

export const StyledMenuList = chakra(MenuList, {
baseStyle: {
Expand All @@ -8,6 +9,15 @@ export const StyledMenuList = chakra(MenuList, {
},
});

export const titulo = styled.div`
font-size: 150%;
font-weight: 600;
color: #243A69;
margin-left: 20px;
margin-top: 20px;
align: center;
`;

// export const StyledContainer = chakra( Container, {
// baseStyle: {
// gap:'15vh',
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/pages/Signin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ const Signin = () => {
sessionStorage.setItem("superuser", response.data.superuser);

signin();
console.log("oi")
console.log( sessionStorage.getItem("superuser"))
console.log(isSuperUser())
navigate("/home");
let typeUser = isSuperUser()

if(typeUser == "true"){
console.log("é adm ")
navigate("/home");
} else {
console.log("é aluno ")
navigate('/home')
}

} else {
setError("Credenciais inválidas");
Expand Down
51 changes: 51 additions & 0 deletions frontend/src/pages/StudentHome/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from "react";
import { Container, Flex, Text, HStack, Wrap, WrapItem, Button, Center } from "@chakra-ui/react";
import Header from "../../components/Header/index.js";
import Footer from "../../components/Footer/index.js";
import { ChakraProvider } from "@chakra-ui/react";
import * as C from "./styles";


import { Link } from "react-router-dom";

const StudentHome = () => {
return (
<ChakraProvider>
<Flex direction="column" minH="100vh">
<Header />
<Container flex="1" marginTop='5vh'>
<Center>
<C.titulo>
<Text
textAlign={"center"}
fontSize={"3xl"}
color={"#243A69"}
as={"b"}
>
Bem vindo, estudante!
</Text>
</C.titulo>
</Center>
<Center>
<HStack marginTop='2vh'>
<Button colorScheme='facebook'>
<Link to='/eletivas'>Nova matrícula</Link>
</Button>
<Button colorScheme='facebook'>
<Link to='/trilhas'>Visualizar grade</Link>
</Button>
</HStack>
</Center>




</Container>
<Footer />
</Flex>
</ChakraProvider>

);
};

export default StudentHome;
10 changes: 10 additions & 0 deletions frontend/src/pages/StudentHome/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from "styled-components";

export const titulo = styled.div`
font-size: 150%;
font-weight: 600;
color: #243A69;
margin-left: 20px;
margin-top: 20px;
align: center;
`;
36 changes: 9 additions & 27 deletions frontend/src/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Navigate, Route, BrowserRouter, Routes } from "react-router-dom";
import React from "react";
import { Navigate, Route, BrowserRouter, Routes } from "react-router-dom";
import useAuth from "../hooks/useAuth";
import Home from "../pages/Home";
import Signin from "../pages/Signin";
Expand All @@ -11,14 +11,14 @@ import ExclusionTrilhas from "../pages/ExclusionTrilhas";
import Recommendations from "../pages/Recommendations";
import SendStudent from "../pages/SendStudents";
import RegistrationPeriod from "../pages/RegistrationPeriod"
import ChoiceList from "../pages/ChoiceList"
import ListElectives from "../pages/ListElectives"
import ListLearningPath from "../pages/ListLearningPath"
import StudentHome from "../pages/StudentHome"

const RoutesApp = () => {
const { isAuthenticated, isSuperUser } = useAuth();
let typeUser = isSuperUser()
console.log('type:', typeUser == 'true')


isSuperUser()

return (
<BrowserRouter>
Expand All @@ -27,7 +27,7 @@ const RoutesApp = () => {
<Route path="/signup" element={<Signup />} />
<Route path="/" element={<Navigate to="/signin" />} />

{isSuperUser() ? (
{typeUser == 'true' ? (
<>
<Route
path="/home"
Expand Down Expand Up @@ -60,7 +60,7 @@ const RoutesApp = () => {
}
/>
<Route
path="/excluir-trilha"
path="/excluir-trilhas"
element={
!isAuthenticated() ? <Navigate to="/signin" /> : <ExclusionTrilhas />
}
Expand All @@ -77,30 +77,12 @@ const RoutesApp = () => {
!isAuthenticated() ? <Navigate to="/signin" /> : <RegistrationPeriod />
}
/>
<Route
path="/lista"
element={
!isAuthenticated() ? <Navigate to="/signin" /> : <ChoiceList />
}
/>
<Route
path="/eletivas"
element={
!isAuthenticated() ? <Navigate to="/signin" /> : <ListElectives />
}
/>
<Route
path="/trilhas"
element={
!isAuthenticated() ? <Navigate to="/signin" /> : <ListLearningPath />
}
/>
</>
) : (
<Route
path="/home"
path="/home-student"
element={
!isAuthenticated() ? <Navigate to="/signin" /> : <Home />
!isAuthenticated() ? <Navigate to="/signin" /> : <StudentHome />
}
/>
)}
Expand Down

0 comments on commit 806946c

Please sign in to comment.