From d0c5a4ecaafdd1836179d1339f1ec3f579fc919c Mon Sep 17 00:00:00 2001 From: Shivansh Bhatnagar Date: Fri, 14 Jun 2024 15:09:42 +0530 Subject: [PATCH] fixed lint --- frontend/src/App.tsx | 6 +-- frontend/src/Navbar.tsx | 29 +++++----- frontend/src/contexts/AuthContext.tsx | 19 ++++--- frontend/src/library/button.tsx | 2 +- frontend/src/pages/Login.tsx | 65 ++++++++++++---------- frontend/src/pages/SignUp.tsx | 77 +++++++++++++++------------ 6 files changed, 107 insertions(+), 91 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 4c00605..1ad3a4b 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,7 +7,7 @@ import Game from './pages/Game'; import About from './pages/About'; import { AuthProvider } from './contexts/AuthContext'; import Login from './pages/Login'; -import SignUp from './pages/SignUp' +import SignUp from './pages/SignUp'; const router = createBrowserRouter([ { @@ -25,8 +25,8 @@ const router = createBrowserRouter([ }, { path: '/about', element: }, { path: '/error', element: }, - { path: '/login', element: }, - { path: '/signup', element: } + { path: '/login', element: }, + { path: '/signup', element: }, ], }, ]); diff --git a/frontend/src/Navbar.tsx b/frontend/src/Navbar.tsx index 902f2ec..46bb356 100644 --- a/frontend/src/Navbar.tsx +++ b/frontend/src/Navbar.tsx @@ -41,22 +41,19 @@ const Navbar: React.FC = ({ {isLoggedIn ? ( - <> - - - ) : ( - <> -
-
- - )} - + <> + ) : ( + <> +
+
+ + )} {isOpen && (
diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index 4b34852..68bc566 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -30,14 +30,17 @@ export function useAuth() { } export function AuthProvider({ children }: { children: ReactElement }) { - const [user, setUser] = useState(null); - - const login = useCallback((name: string, pass: string) => { - setUser({ - name: name, - pass: pass, - }); - }, [setUser]); + const [user, setUser] = useState(null); + + const login = useCallback( + (name: string, pass: string) => { + setUser({ + name: name, + pass: pass, + }); + }, + [setUser] + ); const logout = useCallback(() => { setUser(null); diff --git a/frontend/src/library/button.tsx b/frontend/src/library/button.tsx index af848eb..add3958 100644 --- a/frontend/src/library/button.tsx +++ b/frontend/src/library/button.tsx @@ -15,7 +15,7 @@ type ButtonProps = { fontSize?: string; rounded?: string; buttonSize?: string; - type?: "submit" | "reset" | "button" + type?: 'submit' | 'reset' | 'button'; borderColor?: string; hoverColor?: string; hoverScale?: boolean; diff --git a/frontend/src/pages/Login.tsx b/frontend/src/pages/Login.tsx index 3654fd4..115c2bc 100644 --- a/frontend/src/pages/Login.tsx +++ b/frontend/src/pages/Login.tsx @@ -12,7 +12,7 @@ const Login: React.FC = () => { const [isLoggedIn, setIsLoggedIn] = useState(false); const [username, setUsername] = useState(''); const auth = useAuth(); - + const handleLogin = () => { setUsername('Username_7'); setIsLoggedIn(true); @@ -27,19 +27,20 @@ const Login: React.FC = () => { setName(event.target.value); }; - const handlePasswordChange = (event: React.ChangeEvent) => { + const handlePasswordChange = ( + event: React.ChangeEvent + ) => { setPassword(event.target.value); }; - const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); console.log('Form submitted'); - const user = auth.getUser(); - if(user?.name == name && user.pass == password){ - console.log("Successful Login"); - }else{ - console.log("Failed Login"); + const user = auth.getUser(); + if (user?.name == name && user.pass == password) { + console.log('Successful Login'); + } else { + console.log('Failed Login'); } }; @@ -50,15 +51,15 @@ const Login: React.FC = () => { return ( <> -
+
-
-
+
+
{/*
*/}
-
-
-
+ +
+
-
+
-
+
-
- Don't have an account? Sign up +
+ Don't have an account?{' '} + + {' '} + Sign up +
@@ -118,8 +126,7 @@ const Login: React.FC = () => {
- ); }; -export default Login; \ No newline at end of file +export default Login; diff --git a/frontend/src/pages/SignUp.tsx b/frontend/src/pages/SignUp.tsx index 993931e..21e0d41 100644 --- a/frontend/src/pages/SignUp.tsx +++ b/frontend/src/pages/SignUp.tsx @@ -13,7 +13,7 @@ const SignUp: React.FC = () => { const [isLoggedIn, setIsLoggedIn] = useState(false); const [username, setUsername] = useState(''); const auth = useAuth(); - + const handleLogin = () => { setUsername('Username_7'); setIsLoggedIn(true); @@ -24,7 +24,9 @@ const SignUp: React.FC = () => { setIsLoggedIn(false); }; - const handelConfirmPassChange = (event: React.ChangeEvent) => { + const handelConfirmPassChange = ( + event: React.ChangeEvent + ) => { setConfirmPass(event.target.value); }; @@ -32,19 +34,20 @@ const SignUp: React.FC = () => { setName(event.target.value); }; - const handlePasswordChange = (event: React.ChangeEvent) => { + const handlePasswordChange = ( + event: React.ChangeEvent + ) => { setPassword(event.target.value); }; - const handleSubmit = (event: React.FormEvent) => { event.preventDefault(); console.log('Form submitted'); - if(password === confirmPass){ - auth.login(name, password) - console.log("successfull signup") - }else{ - console.log("failed signup"); + if (password === confirmPass) { + auth.login(name, password); + console.log('successfull signup'); + } else { + console.log('failed signup'); } }; @@ -57,16 +60,16 @@ const SignUp: React.FC = () => { return ( <> -
+
-
-
- {/*
+
+
+ {/*
*/}
-
-
-
+ +
+
-
+
-
+
-
+
-
- Already have an account? Login +
+ Already have an account?{' '} + + {' '} + Login +
@@ -135,8 +145,7 @@ const SignUp: React.FC = () => {
- ); }; -export default SignUp; \ No newline at end of file +export default SignUp;