Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f596f4a
commit 7b259ee
Showing
4 changed files
with
50 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useState, useMemo } from 'react'; | ||
import { useForm, FielderProvider } from 'fielder'; | ||
import { SignUp } from './SignUp'; | ||
import { GettingStarted } from './GettingStarted'; | ||
import { Login } from './Login'; | ||
|
||
export const Form = () => { | ||
const [continued, setContinued] = useState(false); | ||
const formState = useForm(); | ||
|
||
const formPage = useMemo(() => { | ||
if (!continued) { | ||
return 'init'; | ||
} | ||
|
||
if (formState.fields.email.value === 'user@mail.com') { | ||
return 'login'; | ||
} | ||
|
||
return 'signup'; | ||
}, [formState, continued]); | ||
|
||
return ( | ||
<FielderProvider value={formState}> | ||
{formPage === 'init' && ( | ||
<GettingStarted onNext={() => setContinued(true)} /> | ||
)} | ||
{formPage === 'login' && <Login />} | ||
{formPage === 'signup' && <SignUp />} | ||
</FielderProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
import React, { useState, useMemo } from 'react'; | ||
import { useForm, FielderProvider } from 'fielder'; | ||
import { SignUp } from './SignUp'; | ||
import { GettingStarted } from './GettingStarted'; | ||
import { Login } from './Login'; | ||
|
||
export const Form = () => { | ||
const [continued, setContinued] = useState(false); | ||
const formState = useForm(); | ||
|
||
const formPage = useMemo(() => { | ||
if (!continued) { | ||
return 'init'; | ||
} | ||
|
||
if (formState.fields.email.value === 'user@mail.com') { | ||
return 'login'; | ||
} | ||
|
||
return 'signup'; | ||
}, [formState, continued]); | ||
|
||
return ( | ||
<FielderProvider value={formState}> | ||
{formPage === 'init' && ( | ||
<GettingStarted onNext={() => setContinued(true)} /> | ||
)} | ||
{formPage === 'login' && <Login />} | ||
{formPage === 'signup' && <SignUp />} | ||
</FielderProvider> | ||
); | ||
}; | ||
export * from './Form'; |