File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
exercises/user_signup/solutions/codely_next-typescript-middle-out/src Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 11import React , { useState } from "react" ;
2+ import { signUpUser } from "../services/signUpUser" ;
23import { Input } from "./Input" ;
34
45type FormStatus = "success" | "error" | "initial"
56
67export function SignUpForm ( ) {
78 const [ formStatus , setFormStatus ] = useState < FormStatus > ( "initial" )
89
9- function handleSubmit ( ev : React . FormEvent ) {
10+ async function handleSubmit ( ev : React . FormEvent ) {
1011 ev . preventDefault ( )
11- setFormStatus ( "success" )
12+ const data = new FormData ( ev . target as HTMLFormElement ) ;
13+ const entries = Object . fromEntries ( data . entries ( ) ) as { [ key : string ] : string } ;
14+
15+ await signUpUser ( { name : entries . name , email : entries . email } ) ;
16+ setFormStatus ( "success" ) ;
1217 }
1318
1419 if ( formStatus === "success" ) {
Original file line number Diff line number Diff line change 1+ export async function signUpUser ( { name, email} : { name : string , email : string } ) : Promise < void > {
2+ return ;
3+ }
You can’t perform that action at this time.
0 commit comments