From 171af45318b3c27c232fc7d1aee99976dfb3046e Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Tue, 16 Jun 2020 18:52:58 +0300 Subject: replace interface with simple string for authorization --- src/pages/AuthPage/AuthPage.tsx | 7 +++---- src/pages/AuthPage/SignInForm.tsx | 6 +++--- src/pages/AuthPage/SignUpForm.tsx | 6 +++--- src/types.d.ts | 3 --- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/pages/AuthPage/AuthPage.tsx b/src/pages/AuthPage/AuthPage.tsx index fc7f404..0072686 100644 --- a/src/pages/AuthPage/AuthPage.tsx +++ b/src/pages/AuthPage/AuthPage.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react'; import SignInForm from './SignInForm'; import SignUpForm from './SignUpForm'; -import { Authorization } from '../../types'; interface PropTypes { @@ -9,12 +8,12 @@ interface PropTypes { } const AuthPage: React.FC = ({ logIn }) => { - const [authorization, setAuthorization] = useState({ authorize: 'signIn' }); + const [auth, setAuth] = useState('signIn'); return ( <> - {authorization.authorize === 'signIn' && } - {authorization.authorize === 'signUp' && } + {auth === 'signIn' && } + {auth === 'signUp' && } ); }; diff --git a/src/pages/AuthPage/SignInForm.tsx b/src/pages/AuthPage/SignInForm.tsx index cf68493..ae75541 100644 --- a/src/pages/AuthPage/SignInForm.tsx +++ b/src/pages/AuthPage/SignInForm.tsx @@ -5,7 +5,7 @@ import Button from '@material-ui/core/Button'; interface PropTypes { logIn: (name: string, password: string) => Promise; - setAuthorization: (authorization: { authorize: string }) => void; + setAuth: (auth: string) => void; } const useStyles = makeStyles(theme => ({ @@ -33,7 +33,7 @@ const useStyles = makeStyles(theme => ({ } })); -const SignInForm: React.FC = ({ logIn, setAuthorization }) => { +const SignInForm: React.FC = ({ logIn, setAuth }) => { const [error, setError] = useState(false); const classes = useStyles(); const nameRef = useRef(); @@ -50,7 +50,7 @@ const SignInForm: React.FC = ({ logIn, setAuthorization }) => { }; const handleSignUp = () => { - setAuthorization({ authorize: 'signUp' }); + setAuth('signUp'); }; return ( diff --git a/src/pages/AuthPage/SignUpForm.tsx b/src/pages/AuthPage/SignUpForm.tsx index a4271d5..0013372 100644 --- a/src/pages/AuthPage/SignUpForm.tsx +++ b/src/pages/AuthPage/SignUpForm.tsx @@ -6,7 +6,7 @@ import { post } from '../../requests'; interface PropTypes { logIn: (name: string, password: string) => Promise; - setAuthorization: (authorization: { authorize: string }) => void ; + setAuth: (auth: string) => void ; } const useStyles = makeStyles(theme => ({ @@ -34,7 +34,7 @@ const useStyles = makeStyles(theme => ({ } })); -const SignUpForm: React.FC = ({ logIn, setAuthorization }) => { +const SignUpForm: React.FC = ({ logIn, setAuth }) => { const classes = useStyles(); const inputRef = useRef(); const inputRefPassword = useRef(); @@ -52,7 +52,7 @@ const SignUpForm: React.FC = ({ logIn, setAuthorization }) => { }; const handleSignIn = () => { - setAuthorization({ authorize: 'signIn' }); + setAuth( 'signIn'); }; return ( diff --git a/src/types.d.ts b/src/types.d.ts index fdb9327..a62eec8 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -2,9 +2,6 @@ export interface Page { prefix: string; id: string; } -export interface Authorization { - authorize: string; -} export interface User { name: string; avatarUrl: string; -- cgit v1.2.3