connect form update

This commit is contained in:
bniwredyc 2023-05-12 16:36:05 +02:00
parent 66696dab7b
commit 9f3fe229d5

View File

@ -27,14 +27,15 @@ export const ConnectPage = () => {
body: JSON.stringify(postData) body: JSON.stringify(postData)
} }
try { const result = await fetch('/api/feedback', requestOptions)
await fetch('/api/feedback', requestOptions)
setState('success') if (!result.ok) {
} catch (error) { console.error('[handleFormSubmit]', result)
console.error('[handleFormSubmit]', error)
setState('error') setState('error')
return
} }
setState('success')
window.scrollTo({ window.scrollTo({
top: 0 top: 0
}) })
@ -45,7 +46,7 @@ export const ConnectPage = () => {
<article class="wide-container container--static-page"> <article class="wide-container container--static-page">
<div class="row"> <div class="row">
<div class="col-sm-20 col-md-16 col-lg-14 col-xl-12 offset-md-5"> <div class="col-sm-20 col-md-16 col-lg-14 col-xl-12 offset-md-5">
<Show when={state() === 'loading' || state() === 'initial'}> <Show when={state() === 'loading' || state() === 'initial' || state() === 'error'}>
<h1> <h1>
<span class="wrapped">Предложить идею</span> <span class="wrapped">Предложить идею</span>
</h1> </h1>
@ -86,8 +87,11 @@ export const ConnectPage = () => {
</button> </button>
</form> </form>
</Show> </Show>
<Show when={state() === 'error'}>Произошла ошибка</Show> <Show when={state() === 'error'}>
<Show when={state() === 'success'}>Спасибо</Show> <br />
Ошибка. Что-то пошло не так. Пожалуйста, попробуйте написать ещё раз
</Show>
<Show when={state() === 'success'}>Спасибо за письмо!</Show>
</div> </div>
</div> </div>
</article> </article>