Skip to content

Commit

Permalink
podkrepi-bg#7 Create ConfirmationDialog common component
Browse files Browse the repository at this point in the history
  • 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.
49 changes: 49 additions & 0 deletions src/components/shared/ConfirmationDialog.tsx
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

0 comments on commit d9f5cd0

Please sign in to comment.