webapp/src/components/Discours/Feedback.tsx

29 lines
891 B
TypeScript
Raw Normal View History

2022-09-09 11:53:35 +00:00
import { hideModal } from '../../stores/ui'
import { t } from '../../utils/intl'
export const Feedback = () => {
const action = '/user/feedback'
const method = 'post'
let msgElement: HTMLTextAreaElement | undefined
let contactElement: HTMLInputElement | undefined
const submit = async () => {
await fetch(action, {
method,
headers: {
accept: 'application/json',
'content-type': 'application/json; charset=utf-8'
},
body: JSON.stringify({ contact: contactElement?.value, message: msgElement?.innerText })
})
hideModal()
}
return (
<form method={method} action={action}>
<input type="text" name="contact" placeholder="email" ref={contactElement} />
<textarea cols="12" name="message" rows="3" placeholder={t('Write to us')} ref={msgElement} />
<input type="submit" onClick={submit} />
</form>
)
}