Skip to content
Snippets Groups Projects
Commit 1801d700 authored by Lucas Eduardo Schoenfelder's avatar Lucas Eduardo Schoenfelder
Browse files

added snackbar to provide feedback

parent ea696ba0
No related branches found
No related tags found
6 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!39Update admin system,!32Homologa,!31Fix console error,!30Centraliza axios
...@@ -16,7 +16,7 @@ GNU Affero General Public License for more details. ...@@ -16,7 +16,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>.*/ along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import React, {useContext} from 'react'; import React, {useContext, useState} from 'react';
import { Button } from '@material-ui/core'; import { Button } from '@material-ui/core';
import Modal from '@material-ui/core/Modal'; import Modal from '@material-ui/core/Modal';
import Backdrop from '@material-ui/core/Backdrop'; import Backdrop from '@material-ui/core/Backdrop';
...@@ -28,6 +28,7 @@ import ReportUserForm from './ReportUserForm.js' ...@@ -28,6 +28,7 @@ import ReportUserForm from './ReportUserForm.js'
import ReportRecursoForm from './ReportRecursoForm.js' import ReportRecursoForm from './ReportRecursoForm.js'
import ReportColecaoForm from './ReportColecaoForm.js' import ReportColecaoForm from './ReportColecaoForm.js'
import {postRequest} from './HelperFunctions/getAxiosConfig' import {postRequest} from './HelperFunctions/getAxiosConfig'
import SnackbarComponent from './SnackbarComponent.js'
function CloseModalButton (props) { function CloseModalButton (props) {
return ( return (
...@@ -39,6 +40,7 @@ function CloseModalButton (props) { ...@@ -39,6 +40,7 @@ function CloseModalButton (props) {
export default function ReportModal (props) { export default function ReportModal (props) {
const {state} = useContext(Store) const {state} = useContext(Store)
const [snackbarOpen, handleSnackbar] = useState(false)
const handleSubmit = (complaint_reason_id, description) => { const handleSubmit = (complaint_reason_id, description) => {
const url = `/complaints/` const url = `/complaints/`
...@@ -52,7 +54,11 @@ export default function ReportModal (props) { ...@@ -52,7 +54,11 @@ export default function ReportModal (props) {
} }
} }
postRequest(url, payload, (data) => {console.log(data)}, (error) => {console.log(error)}) postRequest(url, payload, (data) => {
console.log(data)
props.handleClose();
handleSnackbar(true);
}, (error) => {console.log(error)})
} }
...@@ -73,49 +79,40 @@ export default function ReportModal (props) { ...@@ -73,49 +79,40 @@ export default function ReportModal (props) {
} }
} }
/* const renderForm = (formType) => {
switch (formType) {
case 'colecao':
return (
<ReportCollectionForm
handleClose={props.handleClose}
handleSubmit={handleSubmit}
/>
);
break;
}
} */
return ( return (
<StyledModal <React.Fragment>
aria-labelledby="transition-modal-title" <SnackbarComponent snackbarOpen={snackbarOpen} severity={"success"} handleClose={() => {handleSnackbar(false)}} text={"Sua reclamação foi recebida."}
aria-describedby="transition-modal-description" />
open={props.open} <StyledModal
aria-labelledby="transition-modal-title"
centered="true" aria-describedby="transition-modal-description"
onClose={props.handleClose} open={props.open}
closeAfterTransition
BackdropComponent={Backdrop} centered="true"
BackdropProps={{ onClose={props.handleClose}
timeout: 500, closeAfterTransition
}} BackdropComponent={Backdrop}
> BackdropProps={{
<Fade in={props.open}> timeout: 500,
<ReportContainer> }}
<Header> >
<span style={{width:"32px"}}/> <Fade in={props.open}>
<h2>O que está acontecendo?</h2> <ReportContainer>
<CloseModalButton handleClose={props.handleClose}/> <Header>
</Header> <span style={{width:"32px"}}/>
<h2>O que está acontecendo?</h2>
<Content> <CloseModalButton handleClose={props.handleClose}/>
{ </Header>
renderForm(props.form)
} <Content>
</Content> {
</ReportContainer> renderForm(props.form)
</Fade> }
</StyledModal> </Content>
</ReportContainer>
</Fade>
</StyledModal>
</React.Fragment>
) )
} }
......
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