Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modulo3/projeto-cookenu/projeto-cookenu-completo/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { BrowserRouter } from "react-router-dom";
const App =() => {

const token = localStorage.getItem ("token")
const [rightButtonText, setRigthButtonText] = useState (token ? "Logout": "Login")
const [rightButtonText, setRightButtonText] = useState (token ? "Logout": "Login")

return (

<ThemeProvider theme={theme}>

<BrowserRouter>
<Header rightButtonText ={rightButtonText} setRigthButtonText ={setRigthButtonText} />
<Router setRigthButtonText ={setRigthButtonText} />
<Header rightButtonText ={rightButtonText} setRightButtonText ={setRightButtonText} />
<Router setRightButtonText ={setRightButtonText} />
</BrowserRouter>

</ThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { useHistory } from "react-router-dom"
import CircularProgress from '@material-ui/core/CircularProgress'


const LoginForm = ({setRigthButtonText}) =>{
const LoginForm = ({setRightButtonText}) =>{

const [form, onChange, clear] = useForm ({email:"", password:""})
const history = useHistory()
const [isLoading, setIsLoading] = useState(false)

const onSubmitForm = (event) =>{
event.preventDefault()
login(form,clear, history, setRigthButtonText,setIsLoading)
login(form,clear, history, setRightButtonText,setIsLoading)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ import useUnProtectedPage from "../hooks/useUnProtectedPage"



const LoginPage = ({setRigthButtonText}) =>{
const LoginPage = ({setRightButtonText}) =>{
useUnProtectedPage()
const history = useHistory ()

return (

<ScreenContainer>
<div>
<LogoImage src={logo} />
<LoginForm setRigthButtonText ={setRigthButtonText}/>
<ScreenContainer>
<LoginForm setRightButtonText ={setRightButtonText}/>
<SignUpButtonContainer>
<Button
onClick={() => goToSignUp(history)}
Expand All @@ -33,11 +32,8 @@ const LoginPage = ({setRigthButtonText}) =>{
Não possui conta? Cadastre-se!
</Button>
</SignUpButtonContainer>


</ScreenContainer>


</div>

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ export const ScreenContainer = styled.div`
display: flex;
flex-direction: column;


align-items: center;
width: 100vw;
margin-top: 5vh;
margi-bottom: 10vh;
margin-top: 50vh;
margin-bottom: 10vh;

@media (max-width:420px){
position:absolute;
bottom:30px;
}

@media (max-width:380px){
position:absolute;
bottom:10px;

}

`

Expand Down Expand Up @@ -39,13 +49,36 @@ export const SignUpButtonContainer = styled.div`
`

export const LogoImage = styled.img`
width: 70vw;
position:absolute;
width: 250px;
max-width: 300px;
margin-right: 800px;
margin-left: 120vh;
bottom:280px;
/* margin-right: 800px; */
margin-left: 73vh;
margin-bottom: 3vh;
border-radius: 20px;

/* @media (max-width:420px){
margin-left: 108vh;

} */
@media (max-width:420px){
position:absolute;
width:250px;
margin-left:70px;
bottom:360px;

}
@media (max-width:380px){
position:absolute;
width:200px;
bottom:320px;
margin-left:75px;


}




`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import useForm from '../hooks/useForm'
import {signUp} from "../services/user"
import CircularProgress from '@material-ui/core/CircularProgress'

const SignUpForm = ({setRigthButtonText}) =>{
const SignUpForm = ({setRightButtonText}) =>{
const history = useHistory ()

const [form, onChange, clear] = useForm ({name:"", email:"", password:""})
const [isLoading, setIsLoading] = useState(false)

const onSubmitForm = (event) => {
event.preventDefault()
signUp(form, clear, history, setRigthButtonText, setIsLoading)
signUp(form, clear, history, setRightButtonText, setIsLoading)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { LogoImage } from "./styled"
import useUnProtectedPage from "../hooks/useUnProtectedPage"


const SignUpPage = ({setRigthButtonText}) =>{
const SignUpPage = ({setRightButtonText}) =>{
useUnProtectedPage()

return (
<ScreenContainer>
<LogoImage src={logo}/>
<SignUpForm setRigthButtonText ={setRigthButtonText} />
<SignUpForm setRightButtonText ={setRightButtonText} />
</ScreenContainer>

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@ export const LogoImage = styled.img`
max-width: 350px;
margin-bottom: 3vh;
border-radius: 20px;

@media (max-width: 420px){
width:60vw;
margin-right:25px;
}

@media (max-width: 380px){
width:60vw;
margin-right:25px;
}
`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Header = ({rightButtonText, setRightButtonText}) => {

<AppBar position="static">
<StyledToolbar>
<Button onClick={() => goToRecipesList (history)} color="inherit">MASTER RECEITAS</Button>
<Button onClick={() => goToRecipesList (history)} color="inherit">COOKENU RECEITAS</Button>
<Button onClick={rightButtonAction} color="inherit">{rightButtonText}</Button>
</StyledToolbar>
</AppBar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import SignUpPage from "../SignUpPage/SignUpPage"
import ErroPage from "../ErroPage/ErroPage"


const Router = ({setRigthButtonText}) =>{
const Router = ({setRightButtonText}) =>{

return (

<Switch>

<Route exact path ="/login">
<LoginPage setRigthButtonText ={setRigthButtonText} />
<LoginPage setRightButtonText ={setRightButtonText} />
</Route>

<Route exact path ="/cadastro">
<SignUpPage setRigthButtonText ={setRigthButtonText}/>
<SignUpPage setRightButtonText ={setRightButtonText}/>
</Route>

//Esse aqui é a minha Home do site... é o feed das receitas....
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import axios from "axios"
import {goToRecipesList} from "../routes/coordinator"


export const login = (body, clear, history, setRigthButtonText,setIsLoading) => {
export const login = (body, clear, history, setRightButtonText,setIsLoading) => {
setIsLoading(true)
axios.post ("https://cookenu-api.herokuapp.com/user/login",body)
.then((res)=> {
localStorage.setItem ("token", res.data.token)
clear()
setIsLoading(false)
goToRecipesList (history)
setRigthButtonText ("Logout")
setRightButtonText ("Logout")
})

.catch((err) => {
Expand All @@ -20,15 +20,15 @@ import {goToRecipesList} from "../routes/coordinator"

}

export const signUp = (body, clear, history, setRigthButtonText,setIsLoading) => {
export const signUp = (body, clear, history, setRightButtonText,setIsLoading) => {
setIsLoading(true)
axios.post("https://cookenu-api.herokuapp.com/user/signup", body)
.then((res) => {
localStorage.setItem("token", res.data.token)
clear()
setIsLoading(true)
goToRecipesList (history)
setRigthButtonText ("Logout")
setRightButtonText ("Logout")

})
.catch((err) => {
Expand Down
Empty file.