Skip to content
Snippets Groups Projects
Commit 448c97ef authored by lfr20's avatar lfr20
Browse files

File with the inputs of the sections that need to capture something typed by the user

parent a4589e19
No related branches found
No related tags found
4 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!40merge admin into develop,!37Merge sistema_admin into Update_Admin_System
/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana
This file is part of Plataforma Integrada MEC.
Plataforma Integrada MEC is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plataforma Integrada MEC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import React, { useState } from 'react';
import TextField from '@material-ui/core/TextField';
import MenuItem from '@material-ui/core/MenuItem';
import FormGroup from '@material-ui/core/FormGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Checkbox from '@material-ui/core/Checkbox';
const EmailInputs = () => {
const [option, setOption] = useState('Todos os usuários'); //labels of the text field 'to'
const [index, setIndex] = useState(0); //Used to display something above the text field 'to' depending on what the user clicks
// Capture th text insert by the user in the fields
const [emails, setEmails] = useState('');
const [subject, setSubject] = useState('');
const [message, setMessage] = useState('');
//Controls the state of error in the textfields
const [errorInEmails, setErrorInEmail] = useState({
error: false,
arroba: false,
message: '',
});
const [errorInSubject, setErrorInSubject] = useState({
error: false,
message: '',
});
const [errorInMessage, setErrorInMessage] = useState({
error: false,
message: '',
});
const options = [
{
value: 'All',
label: 'Todos os usuários',
},
{
value: 'Roles',
label: 'Roles/Permissões específicas',
},
{
value: 'Emails',
label: '1 ou mais emails',
},
];
const [roles, setRoles] = useState([
{
label: 'Editor',
isChecked: false,
value: 3
},
{
label: 'Admin',
isChecked: false,
value: 7
},
{
label: 'Curador',
isChecked: false,
value: 5
},
{
label: 'Professor',
isChecked: false,
value: 5
},
{
label: 'Submetedor',
isChecked: false,
value: 5
},
{
label: 'Aluno',
isChecked: false,
value: 5
},
{
label: 'Moderador',
isChecked: false,
value: 5
},
{
label: 'Parceiro',
isChecked: false,
value: 5
},
{
label: 'Supervisor',
isChecked: false,
value: 5
},
{
label: 'Publicador',
isChecked: false,
value: 5
},
]);
const handleChange = (e) => {
setOption(e.target.value);
};
const handleChangeCheckBox = (i) => {
const currState = [...roles];
currState[i].isChecked = !currState[i].isChecked;
setRoles(currState);
}
const EmailsHandler = (e) => {
setEmails(e.target.value)
if (emails.length <= 1) {
const obj = { ...errorInEmails }
obj.error = true
obj.message = '* O email é pequeno'
setErrorInEmail(obj)
} else {
const obj = { ...errorInEmails }
obj.error = false
obj.message = ''
setErrorInEmail(obj)
const tam = emails.length;
if (emails[tam - 1] !== '@') {
const obj = { ...errorInEmails }
if(!obj.arroba){
obj.error = true
obj.message = '* Está faltando o caracter @ para ser identificado como um email válido'
setErrorInEmail(obj)
}
} else {
const obj = { ...errorInEmails }
obj.arroba = true
obj.error = false
obj.message = ''
setErrorInEmail(obj)
}
}
console.log(emails)
}
const SubjectHandler = (e) => {
setSubject(e.target.value)
console.log(subject)
}
const MessageHandler = (e) => {
setMessage(e.target.value)
console.log(message)
}
return (
<form>
<div style={{ width: '50%', display: 'flex', flexDirection: 'column' }}>
<TextField
id="outlined-input"
label="De *"
defaultValue='integrada.contato@mec.gov.br'
variant="outlined"
disabled={true}
/>
<div style={{ height: '1em' }} />
<TextField
select
label="Para *"
defaultValue={option}
value={option}
onChange={handleChange}
helperText="Por favor, selecione uma das opções"
>
{options.map((option, index) => (
<MenuItem onClick={() => setIndex(index)} key={option.value} value={option.value}>
{option.label}
</MenuItem>
))}
</TextField>
<div style={{ height: '1em' }} />
{
index === 0 ? null :
index === 1 ?
<FormGroup>
{roles.map((role, index) => (
<FormControlLabel
key={role.value}
control={<Checkbox checked={role.isChecked} onChange={() => handleChangeCheckBox(index)} name={role.label} />}
label={role.label}
/>
))}
</FormGroup>
:
<TextField
id="outlined-input"
label="Emails"
multiline
rows={2}
error={errorInEmails.error}
helperText={errorInEmails.message}
onChange={EmailsHandler}
placeholder='Digite o edereço dos emails que você deseja enviar a mensagem'
variant="outlined"
style={{ marginBottom: '1em' }}
/>
}
<TextField
id="outlined-input"
label="Assunto"
placeholder='Digite o assunto do email'
onChange={SubjectHandler}
variant="outlined"
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-multiline-static"
label="Mensagem"
onChange={MessageHandler}
multiline
rows={5}
placeholder='Digite sua mensagem...'
variant="outlined"
/>
</div>
</form>
);
}
export default EmailInputs;
\ No newline at end of file
/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana
This file is part of Plataforma Integrada MEC.
Plataforma Integrada MEC is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plataforma Integrada MEC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import React, { useState } from 'react';
import TextField from '@material-ui/core/TextField';
const InstitutionsInputs = ( props ) => {
const [name , setName] = useState(props.editInfo.name)
const [adress , setAdress] = useState(props.editInfo.adress)
const [city , setCity] = useState(props.editInfo.city)
const [country , setCountry] = useState(props.editInfo.country)
return (
<form style={{ width: '25%', display: 'flex', flexDirection: 'column' }}>
<TextField
id="outlined-input"
label="ID *não pode mudar"
defaultValue={props.editInfo.id} //valor recebido por prop
variant="outlined"
disabled={true}
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="Nome"
value={name}
onChange={e => setName(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="Endereço"
value={adress}
onChange={e => setAdress(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="Cidade"
value={city}
onChange={e => setCity(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="País"
value={country}
onChange={e => setCountry(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
</form>
)
}
export default InstitutionsInputs;
\ No newline at end of file
/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana
This file is part of Plataforma Integrada MEC.
Plataforma Integrada MEC is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plataforma Integrada MEC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import React, { useState } from 'react';
import TextField from '@material-ui/core/TextField';
const NoteVarInputs = ( props ) => {
const [name , setName] = useState(props.editInfo.name)
const [code , setCode] = useState(props.editInfo.code)
const [weight , setWeight] = useState(props.editInfo.weight)
return (
<form style={{width : '25%' , display: 'flex' , flexDirection : 'column'}}>
<TextField
id="outlined-input"
label="ID *não pode mudar"
defaultValue={props.editInfo.id} //valor recebido por prop
variant="outlined"
disabled={true}
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="Nome"
value={name}
onChange={e => setName(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="Código"
value={code}
onChange={e => setCode(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
<TextField
id="outlined-input"
label="Peso"
value={weight}
onChange={e => setWeight(e.target.value)}
variant="outlined"
/>
<div style={{ height: '1em' }} />
</form>
)
}
export default NoteVarInputs;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment