index.tsx
34 lines
| 1 | import {__} from '@wordpress/i18n'; |
| 2 | import ModalDialog from '@givewp/components/AdminUI/ModalDialog'; |
| 3 | import {store} from '../../tabs/recurring-donations/store'; |
| 4 | import {setError} from '../../tabs/recurring-donations/store/actions'; |
| 5 | |
| 6 | import './style.scss'; |
| 7 | |
| 8 | type ErrorMessageProps = { |
| 9 | error: string; |
| 10 | }; |
| 11 | |
| 12 | export default function ErrorMessage({error}: ErrorMessageProps) { |
| 13 | const {dispatch} = store; |
| 14 | |
| 15 | const toggleModal = () => { |
| 16 | dispatch(setError(null)); |
| 17 | }; |
| 18 | |
| 19 | return ( |
| 20 | <ModalDialog |
| 21 | wrapperClassName={'give-donor-dashboard__error-modal'} |
| 22 | title={__('Error', 'give')} |
| 23 | showHeader={true} |
| 24 | isOpen={!!error} |
| 25 | handleClose={toggleModal} |
| 26 | > |
| 27 | <p className={'give-donor-dashboard__error-message'}>{error}</p> |
| 28 | <button className={'give-donor-dashboard__error-close'} onClick={toggleModal}> |
| 29 | {__('Okay', 'give')} |
| 30 | </button> |
| 31 | </ModalDialog> |
| 32 | ); |
| 33 | } |
| 34 |