import { createSignal } from "solid-js" import { Show } from "solid-js/web" import { useLocalize } from "~/context/localize" export const ConnectView = () => { const { t } = useLocalize() const [state, setState] = createSignal<'initial' | 'loading' | 'success' | 'error'>('initial') let formRef: HTMLFormElement | null const handleFormSubmit = async (e: SubmitEvent) => { e.preventDefault() setState('loading') const postData = formRef? Array.from(formRef.elements).reduce( (acc, element) => { const formField = element as unknown as { name: string; value: string } if (formField.name) { acc[formField.name] = formField.value } return acc }, {} as Record, ) : {} const requestOptions = { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(postData), } const result = await fetch('/api/feedback', requestOptions) if (!result.ok) { console.error('[handleFormSubmit]', result) setState('error') return } setState('success') window.scrollTo({ top: 0, }) } return (

{t('Suggest an idea')}

{t('Want to suggest, discuss or advise something? Share a topic or an idea? Please send us a message!')} {t('Specify your e-mail and we will reply.')}

(formRef = el)}>