renderDonationForm.tsx
34 lines
| 1 | import { createRoot } from 'react-dom/client'; |
| 2 | import DonationFormBlockApp from '.'; |
| 3 | |
| 4 | /** |
| 5 | * @since 4.7.0 |
| 6 | */ |
| 7 | export default function renderDonationForm(root) { |
| 8 | let dataSrcUrl = root.getAttribute('data-src'); |
| 9 | const locale = root.getAttribute('data-form-locale'); |
| 10 | if (locale) { |
| 11 | const url = new URL(dataSrcUrl); |
| 12 | url.searchParams.set('locale', locale); |
| 13 | dataSrcUrl = url.toString(); |
| 14 | } |
| 15 | |
| 16 | const dataSrc = dataSrcUrl; |
| 17 | const embedId = root.getAttribute('data-givewp-embed-id'); |
| 18 | const formFormat = root.getAttribute('data-form-format'); |
| 19 | const openFormButton = root.getAttribute('data-open-form-button'); |
| 20 | const formUrl = root.getAttribute('data-form-url'); |
| 21 | const formViewUrl = root.getAttribute('data-form-view-url'); |
| 22 | |
| 23 | createRoot(root).render( |
| 24 | <DonationFormBlockApp |
| 25 | openFormButton={openFormButton} |
| 26 | formFormat={formFormat} |
| 27 | dataSrc={dataSrc} |
| 28 | embedId={embedId} |
| 29 | formUrl={formUrl} |
| 30 | formViewUrl={formViewUrl} |
| 31 | /> |
| 32 | ); |
| 33 | } |
| 34 |