diff options
author | Joseph Ditton <jditton.atomic@gmail.com> | 2021-11-23 14:04:12 -0700 |
---|---|---|
committer | Joseph Ditton <jditton.atomic@gmail.com> | 2021-11-23 14:04:12 -0700 |
commit | 8d0b32f8dfe45291426e58f6bf20cffac8dab6e7 (patch) | |
tree | ec4c1e08e8698d7118641612b67bce940019b3dc /client/components/sign_up | |
parent | 4ae4e874689a71e33cdd7a5799fc0c85c4861367 (diff) | |
download | locchat-8d0b32f8dfe45291426e58f6bf20cffac8dab6e7.tar.gz locchat-8d0b32f8dfe45291426e58f6bf20cffac8dab6e7.zip |
adds api, guard, tailwind
Diffstat (limited to 'client/components/sign_up')
-rw-r--r-- | client/components/sign_up/_sign_up.jsx | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/client/components/sign_up/_sign_up.jsx b/client/components/sign_up/_sign_up.jsx index 13ac6c7..c5d0dcd 100644 --- a/client/components/sign_up/_sign_up.jsx +++ b/client/components/sign_up/_sign_up.jsx @@ -1,9 +1,12 @@ import { useContext, useState } from 'react'; import { useNavigate } from 'react-router'; -import { SettingsContext } from '../../utils/settings_context'; +import { AuthContext } from '../../utils/auth_context'; +import { Paper } from '../common/paper'; +import { Input } from '../common/input'; +import { Button } from '../common/button'; export const SignUp = () => { - const [, dispatch] = useContext(SettingsContext); + const [, setAuthToken] = useContext(AuthContext); const navigate = useNavigate(); const [name, setName] = useState(''); const [email, setEmail] = useState(''); @@ -46,45 +49,36 @@ export const SignUp = () => { }); if (res.status === 201) { const result = await res.json(); - dispatch({ type: 'update', payload: { jwt: result.token } }); + setAuthToken(result.token); navigate('/'); } }; return ( - <div> - <div>Name</div> - <input - type="text" - value={name} - onChange={(e) => setName(e.target.value)} - /> - <div>Email</div> - <input - type="email" - value={email} - onChange={(e) => setEmail(e.target.value)} - /> - <div>Confirm Email</div> - <input - type="email" - value={emailConfirmation} - onChange={(e) => setEmailConfirmation(e.target.value)} - /> - <div>Password</div> - <input - type="password" - value={password} - onChange={(e) => setPassword(e.target.value)} - /> - <div>Confirm Password</div> - <input - type="password" - value={passwordConfiramation} - onChange={(e) => setPasswordConfirmation(e.target.value)} - /> - <div> - <button type="button" onClick={signUp}>Sign up</button> + <div className="flex flex-row justify-center m-4"> + <div className="w-96"> + <Paper> + <div>Name</div> + <Input type="text" value={name} onChange={(e) => setName(e.target.value)} /> + <div>Email</div> + <Input type="email" value={email} onChange={(e) => setEmail(e.target.value)} /> + <div>Confirm Email</div> + <Input type="email" value={emailConfirmation} onChange={(e) => setEmailConfirmation(e.target.value)} /> + <div>Password</div> + <Input type="password" value={password} onChange={(e) => setPassword(e.target.value)} /> + <div>Confirm Password</div> + <Input + type="password" + value={passwordConfiramation} + onChange={(e) => setPasswordConfirmation(e.target.value)} + /> + <div className="flex flex-row justify-end mt-2"> + <Button type="button" onClick={signUp}> + Sign up + </Button> + </div> + <div className="flex">{errorMessage}</div> + </Paper> </div> </div> ); |