* Submit Form
(event)
| 98 | */ |
| 99 | |
| 100 | submitForm(event) { |
| 101 | |
| 102 | event.preventDefault() |
| 103 | |
| 104 | const self = this |
| 105 | const name = this.refFormName.current.value |
| 106 | const email = this.refFormEmail.current.value |
| 107 | |
| 108 | if (!name || name === '' || !email || email === '') { |
| 109 | alert('Form fields must be filled in') |
| 110 | return |
| 111 | } |
| 112 | |
| 113 | const callApi = () => { |
| 114 | return fetch(this.state.admin.url, { |
| 115 | method: 'POST', |
| 116 | mode: 'cors', |
| 117 | headers: { |
| 118 | 'Content-Type': 'application/json', |
| 119 | }, |
| 120 | body: JSON.stringify({ name, email }), |
| 121 | }) |
| 122 | } |
| 123 | |
| 124 | return callApi() |
| 125 | .then(() => { |
| 126 | self.setState({ visible: { ...this.state.visible, ...{ success: true }}}) |
| 127 | }) |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Update API |