From 448c97eff46bb4f0caf998f44dd13f59c310793a Mon Sep 17 00:00:00 2001 From: Luis Felipe Risch <lfr20@inf.ufpr.br> Date: Tue, 13 Oct 2020 08:27:04 -0300 Subject: [PATCH] File with the inputs of the sections that need to capture something typed by the user --- .../Components/Inputs/EmailInputs.js | 248 ++++++++++++++++++ .../Components/Inputs/IntitutionsInputs.js | 79 ++++++ .../Components/Inputs/NoteVarInputs.js | 69 +++++ 3 files changed, 396 insertions(+) create mode 100644 src/Admin/Components/Components/Inputs/EmailInputs.js create mode 100644 src/Admin/Components/Components/Inputs/IntitutionsInputs.js create mode 100644 src/Admin/Components/Components/Inputs/NoteVarInputs.js diff --git a/src/Admin/Components/Components/Inputs/EmailInputs.js b/src/Admin/Components/Components/Inputs/EmailInputs.js new file mode 100644 index 00000000..10759c20 --- /dev/null +++ b/src/Admin/Components/Components/Inputs/EmailInputs.js @@ -0,0 +1,248 @@ +/*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 diff --git a/src/Admin/Components/Components/Inputs/IntitutionsInputs.js b/src/Admin/Components/Components/Inputs/IntitutionsInputs.js new file mode 100644 index 00000000..7d187d11 --- /dev/null +++ b/src/Admin/Components/Components/Inputs/IntitutionsInputs.js @@ -0,0 +1,79 @@ +/*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 diff --git a/src/Admin/Components/Components/Inputs/NoteVarInputs.js b/src/Admin/Components/Components/Inputs/NoteVarInputs.js new file mode 100644 index 00000000..d3024823 --- /dev/null +++ b/src/Admin/Components/Components/Inputs/NoteVarInputs.js @@ -0,0 +1,69 @@ +/*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 -- GitLab