From ad91510c6d0a600cb19678e6f3dd64f66656e01a Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Tue, 16 Jun 2020 17:24:29 +0300 Subject: fix: clear eslint errors --- src/pages/AuthPage/AuthPage.tsx | 24 ++++++-------------- src/pages/AuthPage/SignInForm.tsx | 18 +++++++-------- src/pages/AuthPage/SignUpForm.tsx | 48 ++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/pages/AuthPage/AuthPage.tsx b/src/pages/AuthPage/AuthPage.tsx index c490078..fc7f404 100644 --- a/src/pages/AuthPage/AuthPage.tsx +++ b/src/pages/AuthPage/AuthPage.tsx @@ -1,29 +1,19 @@ -import React, {useState} from 'react'; -import {Authorization} from '../../types'; +import React, { useState } from 'react'; import SignInForm from './SignInForm'; -import {makeStyles} from "@material-ui/core"; -import SignUpForm from "./SignUpForm"; +import SignUpForm from './SignUpForm'; +import { Authorization } from '../../types'; + interface PropTypes { logIn: (name: string, password: string) => Promise; } -const useStyles = makeStyles(theme => ({ - authorize: { - display: 'flex', - width: 200, - justifyContent: 'space-around', - margin: '0 auto' - } -})); - -const AuthPage: React.FC = ({logIn}) => { - const classes = useStyles(); - const [authorization, setAuthorization] = useState({authorize: 'signIn'}); +const AuthPage: React.FC = ({ logIn }) => { + const [authorization, setAuthorization] = useState({ authorize: 'signIn' }); return ( <> - {authorization.authorize === 'signIn' && } + {authorization.authorize === 'signIn' && } {authorization.authorize === 'signUp' && } ); diff --git a/src/pages/AuthPage/SignInForm.tsx b/src/pages/AuthPage/SignInForm.tsx index f4f763c..cf68493 100644 --- a/src/pages/AuthPage/SignInForm.tsx +++ b/src/pages/AuthPage/SignInForm.tsx @@ -1,11 +1,11 @@ -import React, {useState, useRef} from 'react'; -import {makeStyles} from '@material-ui/core/styles'; +import React, { useState, useRef } from 'react'; +import { makeStyles } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; import Button from '@material-ui/core/Button'; interface PropTypes { logIn: (name: string, password: string) => Promise; - setAuthorization: (authorization: { authorize: string }) => void ; + setAuthorization: (authorization: { authorize: string }) => void; } const useStyles = makeStyles(theme => ({ @@ -21,11 +21,11 @@ const useStyles = makeStyles(theme => ({ }, formTransfer: { display: 'flex', - justifyContent: 'center' + justifyContent: 'center' }, transferButton: { marginLeft: 10, - color: 'green' + color: 'green' }, formHeader: { textAlign: 'center', @@ -33,7 +33,7 @@ const useStyles = makeStyles(theme => ({ } })); -const SignInForm: React.FC = ({logIn, setAuthorization}) => { +const SignInForm: React.FC = ({ logIn, setAuthorization }) => { const [error, setError] = useState(false); const classes = useStyles(); const nameRef = useRef(); @@ -50,12 +50,12 @@ const SignInForm: React.FC = ({logIn, setAuthorization}) => { }; const handleSignUp = () => { - setAuthorization({authorize: 'signUp'}); + setAuthorization({ authorize: 'signUp' }); }; return ( <> -
Sign In
+
Sign In
= ({logIn, setAuthorization}) => {
-
Don't have an account?
+
Don`t have an account?
Sign Up
diff --git a/src/pages/AuthPage/SignUpForm.tsx b/src/pages/AuthPage/SignUpForm.tsx index 29f17b1..a4271d5 100644 --- a/src/pages/AuthPage/SignUpForm.tsx +++ b/src/pages/AuthPage/SignUpForm.tsx @@ -1,9 +1,8 @@ -import React, {useRef} from 'react'; -import {makeStyles} from '@material-ui/core/styles'; +import React, { useRef } from 'react'; +import { makeStyles } from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; import Button from '@material-ui/core/Button'; -import {Authorization} from '../../types'; -import {get, post} from '../../requests'; +import { post } from '../../requests'; interface PropTypes { logIn: (name: string, password: string) => Promise; @@ -35,7 +34,7 @@ const useStyles = makeStyles(theme => ({ } })); -const SignUpForm: React.FC = ({logIn,setAuthorization}) => { +const SignUpForm: React.FC = ({ logIn, setAuthorization }) => { const classes = useStyles(); const inputRef = useRef(); const inputRefPassword = useRef(); @@ -44,40 +43,37 @@ const SignUpForm: React.FC = ({logIn,setAuthorization}) => { const onClick = () => { const name = inputRef.current?.value; const password = inputRefPassword.current?.value; - const newUser = { - name: name, - password: password, - avatarUrl: '', - }; + const newUser = { name: name, password: password, avatarUrl: '' }; if (name && password) { - post(`/users`,newUser).then(response => { + post('/users', newUser).then(() => { logIn(name, password); }); } }; const handleSignIn = () => { - setAuthorization({authorize: 'signIn'}); + setAuthorization({ authorize: 'signIn' }); }; return ( <>
Sign Up
- - - - - -
-
Already have an account?
-
Sign In
-
- + + + + + +
+
Already have an account?
+
Sign In
+
+ ); }; -- cgit v1.2.3