Fix turnstile
This commit is contained in:
@@ -14,10 +14,7 @@ import { useState } from 'react'
|
||||
export const TestEmailButton = () => {
|
||||
const [to, setTo] = useState('')
|
||||
const [status, setStatus] = useState<
|
||||
| { kind: 'error'; msg: string }
|
||||
| { kind: 'idle' }
|
||||
| { kind: 'ok'; msg: string }
|
||||
| { kind: 'sending' }
|
||||
{ kind: 'idle' } | { kind: 'sending' } | { kind: 'ok'; msg: string } | { kind: 'error'; msg: string }
|
||||
>({ kind: 'idle' })
|
||||
|
||||
const send = async () => {
|
||||
@@ -28,10 +25,10 @@ export const TestEmailButton = () => {
|
||||
setStatus({ kind: 'sending' })
|
||||
try {
|
||||
const res = await fetch('/api/ipal/test-email', {
|
||||
body: JSON.stringify({ to: to.trim() }),
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({ to: to.trim() }),
|
||||
})
|
||||
const data = await res.json()
|
||||
if (data.ok) {
|
||||
@@ -47,23 +44,23 @@ export const TestEmailButton = () => {
|
||||
return (
|
||||
<div className="field-type" style={{ marginTop: '1rem' }}>
|
||||
<label className="field-label">Send a test email</label>
|
||||
<p style={{ fontSize: '.85rem', marginTop: 0, opacity: 0.7 }}>
|
||||
<p style={{ opacity: 0.7, fontSize: '.85rem', marginTop: 0 }}>
|
||||
Sends through the transport selected above. Save your changes first.
|
||||
</p>
|
||||
<div style={{ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '.5rem' }}>
|
||||
<div style={{ display: 'flex', gap: '.5rem', alignItems: 'center', flexWrap: 'wrap' }}>
|
||||
<input
|
||||
onChange={(e) => setTo(e.target.value)}
|
||||
placeholder="[email protected]"
|
||||
style={{ flex: 1, minWidth: '220px' }}
|
||||
type="email"
|
||||
placeholder="[email protected]"
|
||||
value={to}
|
||||
onChange={(e) => setTo(e.target.value)}
|
||||
style={{ flex: 1, minWidth: '220px' }}
|
||||
/>
|
||||
<button
|
||||
className="btn btn--style-secondary"
|
||||
disabled={status.kind === 'sending'}
|
||||
onClick={send}
|
||||
style={{ whiteSpace: 'nowrap' }}
|
||||
type="button"
|
||||
onClick={send}
|
||||
disabled={status.kind === 'sending'}
|
||||
className="btn btn--style-secondary"
|
||||
style={{ whiteSpace: 'nowrap' }}
|
||||
>
|
||||
{status.kind === 'sending' ? 'Sending…' : 'Send test'}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user