File size: 972 Bytes
7e5cb25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"use client"
import CaptchaInput from "@/components/CaptchaInput"
import { experimental_useFormState as useFormState } from "react-dom"
import { submitLogin } from "../actions"

export default function SignIn() {
  const [state, formAction] = useFormState(submitLogin, {})

  return (
    <form
      action={formAction}
      style={{ background: "rgba(0,0,0,0.1)", padding: 10 }}
    >
      <input
        required
        type="email"
        id="email"
        name="email"
        placeholder="Email"
      />
      <br />
      <br />
      <CaptchaInput />
      <br />
      <p>
        For anti-spam measure please confirm your email before upvoting or
        submitting prompts.
      </p>

      {state.error && (
        <p
          style={{
            color: "red",
          }}
        >
          {state.error}
        </p>
      )}

      {state.message && <p>{state.message}</p>}

      <input type="submit" value="Confirm email" />
    </form>
  )
}