one-click-accessibility/modules/settings/assets/js/components/confirm-dialog/index.js
Nirbhay Singh 5fc9cf67f7
[APP-1159] Add mismatch URL flow (#210)
* update: convert imports to named imports

* add: function to check if current screen is settings page

* update: rename elementor logo to app logo

* add: url mismatch flow and components

* update: remove obsolete code

* Update modules/connect/rest/authorize.php

Co-authored-by: Pavlo Kniazevych <139438463+pkniazevych@users.noreply.github.com>

* Update modules/settings/module.php

Co-authored-by: Pavlo Kniazevych <139438463+pkniazevych@users.noreply.github.com>

* fix: modal was not closing

* update: remove url mismatch notice

* update: mismatch modal and rendering logic

* add: toast notifications for errors

* update: convert components into styled components

* update: remove bottom border from the dialog

* update: text copy

* fix: logo alignment

* update: renamed styled component

---------

Co-authored-by: Pavlo Kniazevych <139438463+pkniazevych@users.noreply.github.com>
2025-03-11 12:10:53 +02:00

58 lines
1.5 KiB
JavaScript

import { AlertTriangleFilledIcon } from '@elementor/icons';
import Button from '@elementor/ui/Button';
import Dialog from '@elementor/ui/Dialog';
import DialogActions from '@elementor/ui/DialogActions';
import DialogContent from '@elementor/ui/DialogContent';
import DialogHeader from '@elementor/ui/DialogHeader';
import Typography from '@elementor/ui/Typography';
import { __ } from '@wordpress/i18n';
const ConfirmDialog = ({
title,
onCancel,
onClose,
onApprove,
approveText = __('Submit', 'pojo-accessibility'),
cancelText = __('Cancel', 'pojo-accessibility'),
approveButtonColor = 'error',
approveButtonSize = 'medium',
children,
logo = <AlertTriangleFilledIcon color="error" />,
showCancelButton = true,
showApproveButton = true,
approveButtonDisabled = false,
showCloseButton = false,
dividers = false,
...props
}) => {
return (
<Dialog open onClose={onClose} {...props}>
<DialogHeader logo={logo} onClose={showCloseButton ? onClose : false}>
<Typography variant="subtitle1">{title}</Typography>
</DialogHeader>
<DialogContent dividers={dividers}>{children}</DialogContent>
<DialogActions>
{showCancelButton && (
<Button onClick={onCancel} color="secondary">
{cancelText}
</Button>
)}
{showApproveButton && (
<Button
variant="contained"
disabled={approveButtonDisabled}
color={approveButtonColor}
size={approveButtonSize}
onClick={onApprove}
>
{approveText}
</Button>
)}
</DialogActions>
</Dialog>
);
};
export default ConfirmDialog;