forked from podkrepi-bg/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
podkrepi-bg#7 Create ConfirmationDialog common component
- Loading branch information
Nikola Andreev
authored and
Nikola Andreev
committed
Jan 24, 2021
1 parent
503f65b
commit d9f5cd0
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react' | ||
import Button from '@material-ui/core/Button' | ||
import Dialog from '@material-ui/core/Dialog' | ||
import DialogActions from '@material-ui/core/DialogActions' | ||
import DialogContent from '@material-ui/core/DialogContent' | ||
import DialogContentText from '@material-ui/core/DialogContentText' | ||
import DialogTitle from '@material-ui/core/DialogTitle' | ||
|
||
export type ConfirmationDialogRef = HTMLDialogElement | ||
export interface ConfirmationDialogProps { | ||
isOpen: boolean | ||
handleConfirm: () => void | ||
handleCancel: () => void | ||
title: string | ||
content: string | ||
confirmButtonLabel: string | ||
cancelButtonLabel: string | ||
} | ||
|
||
const ConfirmationDialog = ({ | ||
isOpen, | ||
handleConfirm, | ||
handleCancel, | ||
title, | ||
content, | ||
confirmButtonLabel, | ||
cancelButtonLabel, | ||
}: ConfirmationDialogProps) => ( | ||
<Dialog | ||
open={isOpen} | ||
onClose={handleCancel} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description"> | ||
<DialogTitle id="alert-dialog-title">{title}</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description">{content}</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleConfirm} color="primary"> | ||
{confirmButtonLabel} | ||
</Button> | ||
<Button onClick={handleCancel} color="secondary"> | ||
{cancelButtonLabel} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
|
||
export default ConfirmationDialog |