aboutsummaryrefslogtreecommitdiff
path: root/src/Form
diff options
context:
space:
mode:
Diffstat (limited to 'src/Form')
-rw-r--r--src/Form/SignInForm.tsx21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/Form/SignInForm.tsx b/src/Form/SignInForm.tsx
index 40352fe..efe85ed 100644
--- a/src/Form/SignInForm.tsx
+++ b/src/Form/SignInForm.tsx
@@ -26,24 +26,17 @@ const SignInForm: React.FC<PropTypes> = ({ setUser }) => {
const classes = useStyles();
const inputRef = useRef<HTMLInputElement>();
- const getUserProfile = name => {
- get(`/users?name=${name}`).then(response => {
- setUser(response.data[0]);
- });
- };
-
const onClick = () => {
- const value = inputRef.current?.value;
- if (value) {
- localStorage.setItem('user', value);
- getUserProfile(value);
+ const username = inputRef.current?.value;
+ if (username) {
+ get(`/users?name=${username}`).then(response => {
+ const user = response.data[0];
+ setUser(user);
+ localStorage.setItem('userId', user._id);
+ });
}
};
- if (localStorage.getItem('user') !== null) {
- getUserProfile(localStorage.getItem('user'));
- }
-
return (
<form className={classes.root} noValidate autoComplete="off">
<h1>Sign In</h1>