Adrià Vilanova MartÃnez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 1 | // 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 | |
| 5 | import * as React from 'react'; |
| 6 | import {makeStyles} from '@material-ui/styles'; |
| 7 | import Dialog from '@material-ui/core/Dialog'; |
| 8 | import DialogTitle from '@material-ui/core/DialogTitle'; |
| 9 | import DialogContent from '@material-ui/core/DialogContent'; |
| 10 | import DialogContentText from '@material-ui/core/DialogContentText'; |
| 11 | import DialogActions from '@material-ui/core/DialogActions'; |
| 12 | import Button from '@material-ui/core/Button'; |
| 13 | |
| 14 | const userStyles = makeStyles({ |
| 15 | actionsButtons: { |
| 16 | paddingTop: '0', |
| 17 | }, |
| 18 | primaryButton: { |
| 19 | backgroundColor: 'rgb(25, 118, 210)', |
| 20 | color: 'white', |
| 21 | } |
| 22 | }); |
| 23 | |
| 24 | type Props = { |
| 25 | enable: boolean, |
| 26 | setEnable: Function, |
| 27 | confirmBack: Function, |
| 28 | } |
| 29 | |
| 30 | export 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 | } |