aboutsummaryrefslogtreecommitdiff
path: root/src/pages/AuthPage/SignUpForm.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-30 01:27:39 +0300
committereug-vs <eug-vs@keemail.me>2020-06-30 01:27:39 +0300
commitb31ed66aafbe1d5dbe70d0cdfd70864204510d81 (patch)
treea279ed47157436cd4223698db38cfb2b1ce3ec3d /src/pages/AuthPage/SignUpForm.tsx
parent5ccb1ec0be71ed4efb22b4942d70d9132415f69e (diff)
downloadwhich-ui-b31ed66aafbe1d5dbe70d0cdfd70864204510d81.tar.gz
fix: re-implement navigation logic
Diffstat (limited to 'src/pages/AuthPage/SignUpForm.tsx')
-rw-r--r--src/pages/AuthPage/SignUpForm.tsx8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/pages/AuthPage/SignUpForm.tsx b/src/pages/AuthPage/SignUpForm.tsx
index af7a0f8..1dacd45 100644
--- a/src/pages/AuthPage/SignUpForm.tsx
+++ b/src/pages/AuthPage/SignUpForm.tsx
@@ -4,6 +4,7 @@ import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import { post } from '../../requests';
import { useAuth } from '../../hooks/useAuth';
+import { useNavigate } from '../../hooks/useNavigate';
const useStyles = makeStyles(theme => ({
@@ -30,15 +31,16 @@ const SignUpForm: React.FC = () => {
const emailRef = useRef<HTMLInputElement>();
const passwordRef = useRef<HTMLInputElement>();
const { login } = useAuth();
+ const { navigate } = useNavigate();
const onClick = () => {
const username = usernameRef.current?.value;
const password = passwordRef.current?.value;
const email = emailRef.current?.value;
if (username && password) {
- post('/users', { username, password, email }).then(() => {
- login(username, password);
- });
+ post('/users', { username, password, email })
+ .then(() => login(username, password))
+ .then(() => navigate('profile'));
} else setError(true);
};