HeaderExtension
1 year ago
AddForm.tsx
2 years ago
Banner.tsx
2 years ago
EditForm.tsx
4 months ago
FormBuilderButton.tsx
1 year ago
FormBuilderButtonPortal.tsx
1 year ago
EditForm.tsx
75 lines
| 1 | import {useState} from 'react'; |
| 2 | import {__} from '@wordpress/i18n'; |
| 3 | import FormBuilderButtonPortal from './FormBuilderButtonPortal'; |
| 4 | import Button from '@givewp/components/AdminUI/Button'; |
| 5 | import {CompassIcon} from '@givewp/components/AdminUI/Icons'; |
| 6 | import styles from '../style.module.scss'; |
| 7 | |
| 8 | export default function EditForm() { |
| 9 | |
| 10 | const [state, setState] = useState({ |
| 11 | show: false, |
| 12 | upgrading: false |
| 13 | }); |
| 14 | |
| 15 | const {isMigrated, migratedFormUrl} = window.GiveDonationForms; |
| 16 | |
| 17 | return ( |
| 18 | <> |
| 19 | <FormBuilderButtonPortal |
| 20 | showDialog={state.show} |
| 21 | setShowDialog={setState} |
| 22 | isUpgrading={state.upgrading} |
| 23 | isEditing={true} |
| 24 | /> |
| 25 | |
| 26 | {isMigrated && migratedFormUrl ? ( |
| 27 | <div className={styles.migrationGuideBox}> |
| 28 | <div className={styles.migrationGuideTitle}> |
| 29 | <CompassIcon /> |
| 30 | {__('Upgrade in Progress', 'give')} |
| 31 | </div> |
| 32 | |
| 33 | <div className={styles.migrationGuideContent}> |
| 34 | {__('This form has been upgraded to the Visual Form Builder. Complete the transfer to finalize the upgrade.', 'give')} |
| 35 | </div> |
| 36 | |
| 37 | <Button |
| 38 | onClick={(e) => { |
| 39 | e.preventDefault(); |
| 40 | window.location.href = migratedFormUrl; |
| 41 | }} |
| 42 | style={{width: '100%'}} |
| 43 | > |
| 44 | {__('Continue editing upgraded form', 'give')} |
| 45 | </Button> |
| 46 | </div> |
| 47 | ) : !isMigrated && ( |
| 48 | <div className={styles.migrationGuideBox}> |
| 49 | <div className={styles.migrationGuideTitle}> |
| 50 | <CompassIcon /> |
| 51 | {__('Migration Guide', 'give')} |
| 52 | </div> |
| 53 | |
| 54 | <div className={styles.migrationGuideContent}> |
| 55 | {__('Easily upgrade your form to support the new form builder', 'give')} |
| 56 | </div> |
| 57 | |
| 58 | <Button |
| 59 | onClick={(e) => { |
| 60 | e.preventDefault(); |
| 61 | setState({ |
| 62 | upgrading: true, |
| 63 | show: true |
| 64 | }); |
| 65 | }} |
| 66 | style={{width: '100%'}} |
| 67 | > |
| 68 | {__('Upgrade this form', 'give')} |
| 69 | </Button> |
| 70 | </div> |
| 71 | )} |
| 72 | </> |
| 73 | ) |
| 74 | } |
| 75 |