/*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 Modal from '@material-ui/core/Modal'; import Backdrop from '@material-ui/core/Backdrop'; import Fade from '@material-ui/core/Fade'; import styled from 'styled-components' import { ButtonCancelar, ButtonEnviar } from './EditarColecaoForm'; import CloseModalButton from './CloseModalButton' import SnackbarComponent from './SnackbarComponent' import {deleteRequest} from './HelperFunctions/getAxiosConfig' export default function ModalExcluirColecao (props) { const [snackbarOpen, toggleSnackbar] = useState(false) function handleDeleteSuccess (data) { toggleSnackbar(true) props.removeColl(props.id) props.handleClose() } const handleDelete = () => { const url = `/collections/${props.id}` deleteRequest(url, handleDeleteSuccess, (error) => {console.log(error)}) } return ( <StyledModal aria-labelledby="transition-modal-title" aria-describedby="transition-modal-description" open={props.open} centered="true" onClose={props.handleClose} closeAfterTransition BackdropComponent={Backdrop} BackdropProps={{ timeout: 500, }} > <Fade in={props.open}> <> <SnackbarComponent snackbarOpen={snackbarOpen} severity={"info"} handleClose={() => {toggleSnackbar(false)}} text={"Coleção excluída com sucesso"}/> <Container contrast={props.contrast}> <Header> <h2>Tem certeza que deseja excluir esta Coleção?</h2> <CloseModalButton handleClose={props.handleClose} id={props.id}/> </Header> <Content> <p>A exclusão de uma coleção é permanente. Não é possível desfazer.</p> <ButtonsDiv> <ButtonCancelar contrast={props.contrast} onClick={props.handleClose}>CANCELAR</ButtonCancelar> <ButtonEnviar contrast={props.contrast} onClick={handleDelete}>EXCLUIR</ButtonEnviar> </ButtonsDiv> </Content> </Container> </> </Fade> </StyledModal> ) } const ButtonsDiv = styled.div` display : flex; align-items : center; align-content : center; justify-content : space-evenly; padding-top : 20px; ` const Content = styled.div` padding : 10px 30px 20px; overflow : visible; display : flex; flex-direction : column; p { margin : 0 0 10px; } ` const Header = styled.div` display : flex; flex-direction : row; align-items : center; text-align : center; margin : 20px 30px; h2 { font-size : 26px; font-weight : lighter; } ` const StyledModal = styled(Modal)` .djXaxP{ margin : 0 !important; } display : flex; align-items: center; justify-content : center; text-align : center; padding : 10px !important; max-width : none; max-height : none; ` const Container = styled.div` box-sizing : border-box; background-color: ${props => props.contrast === "" ? "white" : "black"} !important; color: ${props => props.contrast === "" ? "#666" : "white"} !important; border: 1px solid ${props => props.contrast === "" ? "#666" : "white"} !important; max-width : none; align : center; display : flex; flex-direction : column; min-width : 240px; max-height : none; position : relative; padding : 10px; border-radius : 4px; @media screen and (max-width : 899px) { width : 100%; max-height : 600px; } `