-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Reposition change button, add dialog on change (#2774)
- Loading branch information
1 parent
59aea24
commit 32a46ad
Showing
3 changed files
with
232 additions
and
57 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
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
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,54 @@ | ||
import Button from "@mui/material/Button"; | ||
import Dialog from "@mui/material/Dialog"; | ||
import DialogActions from "@mui/material/DialogActions"; | ||
import DialogContent from "@mui/material/DialogContent"; | ||
import DialogTitle from "@mui/material/DialogTitle"; | ||
import React, { PropsWithChildren } from "react"; | ||
|
||
export interface ConfirmationDialogProps { | ||
open: boolean; | ||
onClose: (isConfirmed: boolean) => void; | ||
title: string; | ||
confirmText?: string; | ||
cancelText?: string; | ||
} | ||
|
||
export const ConfirmationDialog: React.FC< | ||
PropsWithChildren<ConfirmationDialogProps> | ||
> = (props) => { | ||
const { | ||
onClose, | ||
open, | ||
children, | ||
title, | ||
confirmText = "Ok", | ||
cancelText = "Cancel ", | ||
} = props; | ||
|
||
const onCancel = () => onClose(false); | ||
const onConfirm = () => onClose(true); | ||
|
||
return ( | ||
<Dialog | ||
data-testid="confirmation-dialog" | ||
PaperProps={{ | ||
sx: { | ||
width: "100%", | ||
maxWidth: (theme) => theme.breakpoints.values.md, | ||
borderRadius: 0, | ||
background: "#FFF", | ||
margin: (theme) => theme.spacing(2), | ||
}, | ||
}} | ||
maxWidth="xl" | ||
open={open} | ||
> | ||
<DialogTitle>{title}</DialogTitle> | ||
<DialogContent dividers>{children}</DialogContent> | ||
<DialogActions> | ||
<Button onClick={onCancel}>{cancelText}</Button> | ||
<Button onClick={onConfirm}>{confirmText}</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; |