PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Views / Components / AdminDetailsPage / ConfirmationDialog.tsx

ConfirmationDialog.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Views/Components/AdminDetailsPage/ConfirmationDialog.tsx

82 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import cx from 'classnames';
2 import {__} from '@wordpress/i18n'
3 import ModalDialog from '@givewp/components/AdminUI/ModalDialog';
4 import {ErrorIcon, WarningIcon} from './Icons';
5 import styles from './AdminDetailsPage.module.scss'
6 import { Spinner } from '@wordpress/components';
7 import ArcSpinner from '@givewp/src/Admin/components/Spinner/ArcSpinner';
8
9 export type ConfirmationDialogProps = {
10 isOpen: boolean;
11 handleClose: () => void;
12 handleConfirm: () => void;
13 title: string;
14 icon?: React.ReactElement;
15 variant?: 'error' | 'regular' | 'syncing';
16 className?: string;
17 actionLabel: string;
18 showCancelButton?: boolean;
19 children: React.ReactNode;
20 isConfirming?: boolean;
21 spinner?: 'regular' | 'arc' | 'none';
22 footer?: React.ReactNode;
23 }
24
25 /**
26 * @since 4.8.0 Add showCancelButton prop
27 * @since 4.4.0
28 */
29 export default function ConfirmationDialog({
30 isOpen,
31 title,
32 icon,
33 variant = 'error',
34 handleClose,
35 handleConfirm,
36 className,
37 actionLabel,
38 showCancelButton = true,
39 children,
40 isConfirming = false,
41 spinner ='none',
42 footer,
43 }: ConfirmationDialogProps) {
44 return (
45 <ModalDialog
46 icon={icon || (variant === 'error' && <ErrorIcon />)}
47 isOpen={isOpen}
48 showHeader={true}
49 handleClose={handleClose}
50 title={title}
51 wrapperClassName={className}
52 >
53 <>
54 <div className={styles.confirmationDialogContent}>
55 {children}
56 </div>
57 <div className={styles.confirmationDialogButtons}>
58 {showCancelButton && (
59 <button
60 className={styles.cancelButton}
61 onClick={handleClose}
62 >
63 {__('Cancel', 'give')}
64 </button>
65 )}
66 <button
67 className={cx(styles.confirmButton, styles[`confirmButton--${variant}`])}
68 onClick={handleConfirm}
69 disabled={isConfirming}
70 >
71 {actionLabel}
72 {isConfirming ? (spinner === 'arc' ? <ArcSpinner /> : <Spinner />) : null}
73 </button>
74 </div>
75 <div className={styles.confirmationDialogFooter}>
76 {footer}
77 </div>
78 </>
79 </ModalDialog>
80 );
81 }
82