webapp/src/components/Discours/Feedback.tsx

32 lines
1000 B
TypeScript
Raw Normal View History

2023-02-17 09:21:02 +00:00
import { useLocalize } from '../../context/localize'
import { hideModal } from '../../stores/ui'
2023-05-29 19:39:53 +00:00
import { Button } from '../_shared/Button'
2022-09-09 11:53:35 +00:00
export const Feedback = () => {
2023-02-17 09:21:02 +00:00
const { t } = useLocalize()
2022-09-09 11:53:35 +00:00
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',
2024-02-07 23:12:10 +00:00
'content-type': 'application/json; charset=utf-8'
2022-09-09 11:53:35 +00:00
},
2024-02-07 23:12:10 +00:00
body: JSON.stringify({ contact: contactElement?.value, message: msgElement?.textContent })
2022-09-09 11:53:35 +00:00
})
hideModal()
}
return (
2023-05-29 19:39:53 +00:00
<form method={method} action={action} onSubmit={submit}>
2022-09-09 11:53:35 +00:00
<input type="text" name="contact" placeholder="email" ref={contactElement} />
<textarea cols="12" name="message" rows="3" placeholder={t('Write to us')} ref={msgElement} />
2023-05-29 19:39:53 +00:00
<Button value={'Отправить'} />
2022-09-09 11:53:35 +00:00
</form>
)
}