Skip to content
Snippets Groups Projects
Commit b083604c authored by vgm18's avatar vgm18
Browse files

Fixing bugs reported by Professor Todt

parent 33076f2b
No related branches found
No related tags found
3 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!45Bug fixing vinicius
...@@ -101,9 +101,6 @@ export default function MenuBar(props) { ...@@ -101,9 +101,6 @@ export default function MenuBar(props) {
const { state } = useContext(Store) const { state } = useContext(Store)
const buildMyAreaTabs = () => { const buildMyAreaTabs = () => {
let canUserAdmin = false;
let index = 0;
const userRoles = [...state.currentUser.roles]
const minhaArea = [ const minhaArea = [
{ name: "Perfil e Atividades", href: "/perfil", value: '0' }, { name: "Perfil e Atividades", href: "/perfil", value: '0' },
{ name: "Recursos Publicados", href: "/perfil", value: '1' }, { name: "Recursos Publicados", href: "/perfil", value: '1' },
...@@ -113,6 +110,11 @@ export default function MenuBar(props) { ...@@ -113,6 +110,11 @@ export default function MenuBar(props) {
{ name: "Configurações", href: "/editarperfil", value: '5'}, { name: "Configurações", href: "/editarperfil", value: '5'},
] ]
if (state.currentUser.roles) {
let canUserAdmin = false;
let index = 0;
const userRoles = [...state.currentUser.roles]
while (!canUserAdmin && index < userRoles.length) { while (!canUserAdmin && index < userRoles.length) {
if(userRoles[index].id === 3 || userRoles[index].id === 7) if(userRoles[index].id === 3 || userRoles[index].id === 7)
canUserAdmin = true canUserAdmin = true
...@@ -125,6 +127,7 @@ export default function MenuBar(props) { ...@@ -125,6 +127,7 @@ export default function MenuBar(props) {
href: "/admin/home", href: "/admin/home",
value: '6', value: '6',
}) })
}
return minhaArea; return minhaArea;
} }
......
...@@ -38,9 +38,6 @@ export default function MobileDrawerMenu(props) { ...@@ -38,9 +38,6 @@ export default function MobileDrawerMenu(props) {
const { state, dispatch } = useContext(Store) const { state, dispatch } = useContext(Store)
const buildMyAreaTabs = () => { const buildMyAreaTabs = () => {
let canUserAdmin = false;
let index = 0;
const userRoles = [...state.currentUser.roles]
const minhaArea = [ const minhaArea = [
{ name: "Perfil e Atividades", href: "/perfil", value: '0' }, { name: "Perfil e Atividades", href: "/perfil", value: '0' },
{ name: "Recursos Publicados", href: "/perfil", value: '1' }, { name: "Recursos Publicados", href: "/perfil", value: '1' },
...@@ -50,6 +47,11 @@ export default function MobileDrawerMenu(props) { ...@@ -50,6 +47,11 @@ export default function MobileDrawerMenu(props) {
{ name: "Configurações", href: "/editarperfil", value: '5' }, { name: "Configurações", href: "/editarperfil", value: '5' },
] ]
if (state.currentUser.roles) {
let canUserAdmin = false;
let index = 0;
const userRoles = [...state.currentUser.roles]
while (!canUserAdmin && index < userRoles.length) { while (!canUserAdmin && index < userRoles.length) {
if (userRoles[index].id === 3 || userRoles[index].id === 7) if (userRoles[index].id === 3 || userRoles[index].id === 7)
canUserAdmin = true canUserAdmin = true
...@@ -62,6 +64,7 @@ export default function MobileDrawerMenu(props) { ...@@ -62,6 +64,7 @@ export default function MobileDrawerMenu(props) {
href: "/admin/home", href: "/admin/home",
value: '6', value: '6',
}) })
}
return minhaArea; return minhaArea;
} }
......
...@@ -58,9 +58,16 @@ export default function SignUpContainer (props) { ...@@ -58,9 +58,16 @@ export default function SignUpContainer (props) {
} }
) )
const handleChange = (e, type) => { const [formConfirmation, setConfirmation] = useState(
{
key : false,
value : ""
}
)
const handleChange = (e, type, confirmation) => {
const userInput = e.target.value const userInput = e.target.value
const flag = ValidateUserInput(type, userInput) const flag = ValidateUserInput(type, userInput, confirmation)
if (type === 'username') { if (type === 'username') {
setNome({...formNome, setNome({...formNome,
...@@ -83,6 +90,13 @@ export default function SignUpContainer (props) { ...@@ -83,6 +90,13 @@ export default function SignUpContainer (props) {
}) })
console.log(formSenha) console.log(formSenha)
} }
else if(type === 'confirmation') {
setConfirmation({...formConfirmation,
key : flag,
value : userInput
})
console.log(formConfirmation)
}
} }
const limpaCamposForm = () => { const limpaCamposForm = () => {
...@@ -100,6 +114,11 @@ export default function SignUpContainer (props) { ...@@ -100,6 +114,11 @@ export default function SignUpContainer (props) {
key : false, key : false,
value : '' value : ''
}) })
setConfirmation({...formConfirmation,
key : false,
value : ''
})
} }
const switchModal = (e) => { const switchModal = (e) => {
...@@ -110,9 +129,9 @@ export default function SignUpContainer (props) { ...@@ -110,9 +129,9 @@ export default function SignUpContainer (props) {
const onSubmit = (e) => { const onSubmit = (e) => {
e.preventDefault(); e.preventDefault();
const newLogin = {name : formNome.value, email : formEmail.value, password : formSenha.value} const newLogin = {name : formNome.value, email : formEmail.value, password : formSenha.value, senha : formConfirmation.value}
if (!(formNome.key || formEmail.key || formSenha.key)) { if (!(formNome.key || formEmail.key || formSenha.key || formConfirmation.key)) {
props.handleLoginInfo(newLogin) props.handleLoginInfo(newLogin)
limpaCamposForm() limpaCamposForm()
} }
...@@ -178,6 +197,17 @@ export default function SignUpContainer (props) { ...@@ -178,6 +197,17 @@ export default function SignUpContainer (props) {
help = {formSenha.key ? (formSenha.value.length === 0 ? "Faltou digitar sua senha." : "A senha precisa ter no mínimo 8 caracteres.") : ""} help = {formSenha.key ? (formSenha.value.length === 0 ? "Faltou digitar sua senha." : "A senha precisa ter no mínimo 8 caracteres.") : ""}
/> />
<br/> <br/>
<FormInput
inputType={"password"}
name={"confirmation"}
value={formConfirmation.value}
placeholder={"Confirme a Senha"}
handleChange={e => handleChange(e, 'confirmation', formSenha.value)}
required={true}
error={formConfirmation.key}
help = {formConfirmation.key ? (formConfirmation.value.length === 0 ? "Faltou digitar sua senha." : (formConfirmation.value !== formSenha.value ? "As senhas precisam ser iguais" : "A senha precisa ter no mínimo 8 caracteres.")) : ""}
/>
<br/>
<ConfirmContainerStyled> <ConfirmContainerStyled>
<StyledSignUpButton type="submit" variant="contained"> <StyledSignUpButton type="submit" variant="contained">
<span <span
...@@ -192,7 +222,7 @@ export default function SignUpContainer (props) { ...@@ -192,7 +222,7 @@ export default function SignUpContainer (props) {
<TermosDeUsoStyled> <TermosDeUsoStyled>
<p>Ao se cadastrar, você está aceitando os Termos de Uso e de Política <p>Ao se cadastrar, você está aceitando os Termos de Uso e de Política
de Privacidade. <a href="./">Ler Termos</a>.</p> de Privacidade. <a href="/termos">Ler Termos</a>.</p>
</TermosDeUsoStyled> </TermosDeUsoStyled>
<DialogFooterStyled> <DialogFooterStyled>
......
...@@ -23,6 +23,7 @@ import styled from 'styled-components' ...@@ -23,6 +23,7 @@ import styled from 'styled-components'
import SignUpContainer from './SignUpContainerFunction.js' import SignUpContainer from './SignUpContainerFunction.js'
import {Store} from '../Store.js' import {Store} from '../Store.js'
import {authentication} from './HelperFunctions/getAxiosConfig' import {authentication} from './HelperFunctions/getAxiosConfig'
//import {postRequest} from './HelperFunctions/getAxiosConfig'
export default function SignUpModal (props) { export default function SignUpModal (props) {
const { state, dispatch } = useContext(Store) const { state, dispatch } = useContext(Store)
...@@ -41,11 +42,12 @@ export default function SignUpModal (props) { ...@@ -41,11 +42,12 @@ export default function SignUpModal (props) {
name : newLogin.name, name : newLogin.name,
email: newLogin.email, email: newLogin.email,
password : newLogin.password, password : newLogin.password,
password_confirmation : newLogin.senha, password_confirmation : newLogin.senha //,
terms_of_service:true, // terms_of_service : true,
avatar: "" // avatar: ""
} }
authentication(url, payload, handleSuccess, (error) => {console.log(error)}) authentication(url, payload, handleSuccess, (error) => {console.log(error)})
//postRequest(url, payload, handleSuccess, (error) => {console.log(error)})
} }
return ( return (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment