| 1 | import { commentText } from 'shared/schema' |
| 2 | |
| 3 | export default function SubmitComment(props: { |
| 4 | onSubmit: (text: string) => Promise<void> |
| 5 | }) { |
| 6 | return ( |
| 7 | <main> |
| 8 | <form |
| 9 | onSubmit={async (e) => { |
| 10 | e.preventDefault() |
| 11 | const formData = new FormData(e.target as HTMLFormElement) |
| 12 | const text = commentText.parse(formData.get('comment')) |
| 13 | // highTODO idempotency token |
| 14 | await props.onSubmit(text) |
| 15 | }} |
| 16 | > |
| 17 | <textarea |
| 18 | class='border' |
| 19 | name='comment' |
| 20 | autocomplete='off' |
| 21 | rows='4' |
| 22 | cols='50' |
| 23 | /> |
| 24 | <button class='block' type='submit'> |
| 25 | Submit |
| 26 | </button> |
| 27 | </form> |
| 28 | </main> |
| 29 | ) |
| 30 | } |