blob: 0d07b833f64f2139653925c42a5994d723d995cd [file] [log] [blame]
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +02001// Copyright 2022 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import * as React from 'react';
6import {makeStyles} from '@material-ui/styles';
7import Dialog from '@material-ui/core/Dialog';
8import DialogTitle from '@material-ui/core/DialogTitle';
9import DialogContent from '@material-ui/core/DialogContent';
10import DialogContentText from '@material-ui/core/DialogContentText';
11import DialogActions from '@material-ui/core/DialogActions';
12import Button from '@material-ui/core/Button';
13
14const userStyles = makeStyles({
15 actionsButtons: {
16 paddingTop: '0',
17 },
18 primaryButton: {
19 backgroundColor: 'rgb(25, 118, 210)',
20 color: 'white',
21 }
22});
23
24type Props = {
25 enable: boolean,
26 setEnable: Function,
27 confirmBack: Function,
28}
29
30export function ConfirmBackModal(props: Props): React.ReactElement {
31 const {enable, setEnable, confirmBack} = props;
32 const classes = userStyles();
33
34 return (
35 <Dialog open={enable}>
36 <DialogTitle>Warning!</DialogTitle>
37 <DialogContent>
38 <DialogContentText>
39 Changes you made on this page won't be saved.
40 </DialogContentText>
41 </DialogContent>
42 <DialogActions className={classes.actionsButtons}>
43 <Button onClick={() => setEnable(false)}>Cancel</Button>
44 <Button onClick={() => {
45 confirmBack();
46 setEnable(false);
47 }} className={classes.primaryButton}>Ok</Button>
48 </DialogActions>
49 </Dialog>
50 )
51}