| 1 |
import ModalDialog from '@givewp/components/AdminUI/ModalDialog'; |
| 2 |
import ErrorMessages from './ErrorMessages'; |
| 3 |
import styles from './FormModal.module.scss'; |
| 4 |
|
| 5 |
/** |
| 6 |
* Form Modal component that renders a modal with a styled form inside |
| 7 |
* |
| 8 |
* @since 3.6.0 |
| 9 |
*/ |
| 10 |
export default function FormModal({ |
| 11 |
isOpen, |
| 12 |
handleClose, |
| 13 |
title, |
| 14 |
handleSubmit, |
| 15 |
errors, |
| 16 |
className, |
| 17 |
children, |
| 18 |
}: FormModalProps) { |
| 19 |
return ( |
| 20 |
<ModalDialog |
| 21 |
isOpen={isOpen} |
| 22 |
showHeader={true} |
| 23 |
handleClose={handleClose} |
| 24 |
title={title} |
| 25 |
wrapperClassName={styles.formModal} |
| 26 |
> |
| 27 |
<form className={`givewp-event-tickets__form ${className}`} onSubmit={handleSubmit}> |
| 28 |
<ErrorMessages errors={errors} /> |
| 29 |
|
| 30 |
{children} |
| 31 |
</form> |
| 32 |
</ModalDialog> |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
interface FormModalProps { |
| 37 |
isOpen: boolean; |
| 38 |
handleClose: () => void; |
| 39 |
title: string; |
| 40 |
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void; |
| 41 |
errors: Record<string, any>; |
| 42 |
className: string; |
| 43 |
children: JSX.Element | JSX.Element[]; |
| 44 |
} |
| 45 |
|