From f5b8c8dd652e3d5f7689b43ba7a474ee6d759f2f Mon Sep 17 00:00:00 2001 From: Samuel Poirier Date: Sat, 23 Mar 2024 10:40:51 -0400 Subject: [PATCH] Applied linting rules to all tsx files (#53) --- canopeum_frontend/src/App.tsx | 44 ++++--- canopeum_frontend/src/components/Navbar.tsx | 117 ++++++++++-------- canopeum_frontend/src/pages/Home.tsx | 68 +++++----- .../src/pages/UserManagement.tsx | 22 ++-- .../src/services/apiInterface.ts | 4 +- 5 files changed, 134 insertions(+), 121 deletions(-) diff --git a/canopeum_frontend/src/App.tsx b/canopeum_frontend/src/App.tsx index 4d5e2721b..0256407b1 100644 --- a/canopeum_frontend/src/App.tsx +++ b/canopeum_frontend/src/App.tsx @@ -1,31 +1,29 @@ import './App.scss'; +import 'bootstrap/js/index.umd.js'; + import { BrowserRouter, Route, Routes } from 'react-router-dom'; -import Home from './pages/Home'; + +import Navbar from './components/Navbar'; import Analytics from './pages/Analytics'; +import Home from './pages/Home'; +import Login from './pages/Login'; import Map from './pages/Map'; import UserManagement from './pages/UserManagement'; -import Login from './pages/Login'; - -import Navbar from './components/Navbar'; import Utilities from './pages/Utilities'; -import 'bootstrap/js/index.umd.js'; +const App = () => ( + + + + } path="/home" /> + } path="/" /> + } path="/analytics" /> + } path="/map" /> + } path="/user-management" /> + } path="/login" /> + } path="/utilities" /> + + +); -export default function App() { - return ( - <> - - - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - - - - ); -} +export default App; diff --git a/canopeum_frontend/src/components/Navbar.tsx b/canopeum_frontend/src/components/Navbar.tsx index f0af7c110..e5ca079b2 100644 --- a/canopeum_frontend/src/components/Navbar.tsx +++ b/canopeum_frontend/src/components/Navbar.tsx @@ -1,57 +1,66 @@ import { Link, useLocation } from 'react-router-dom'; +const Navbar = () => { + const location = useLocation(); -export default function Navbar() { - - const location = useLocation(); - - return ( - - ); -} + return ( + + ); +}; +export default Navbar; diff --git a/canopeum_frontend/src/pages/Home.tsx b/canopeum_frontend/src/pages/Home.tsx index ef1d651ec..0a4fa897a 100644 --- a/canopeum_frontend/src/pages/Home.tsx +++ b/canopeum_frontend/src/pages/Home.tsx @@ -1,50 +1,56 @@ -import { useEffect, useState } from 'react' +import { useEffect, useState } from 'react'; -import type { BatchAnalytics } from '../services/api.ts' -import api from '../services/apiInterface.ts' -import { ensureError } from '../services/errors.ts' +import type { BatchAnalytics } from '../services/api.ts'; +import api from '../services/apiInterface.ts'; +import { ensureError } from '../services/errors.ts'; const Home = () => { - const [data, setData] = useState([]) - const [isLoading, setIsLoading] = useState(false) - const [error, setError] = useState(undefined) + const [data, setData] = useState([]); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(undefined); const fetchData = async () => { - setIsLoading(true) + setIsLoading(true); try { - const response = await api.batches.all() - setData(response) + const response = await api.batches.all(); + setData(response); } catch (error_: unknown) { - setError(ensureError(error_)) + setError(ensureError(error_)); } finally { - setIsLoading(false) + setIsLoading(false); } - } + }; useEffect((): void => { - void fetchData() - }, []) + void fetchData(); + }, []); return (
-
-
+
+

Home

{isLoading - ?

Loading...

- : error - ?

Error: {error.message}

- : ( -
-

Exemple request from API:

-
    - {(data).map(item =>
  • {item.name}
  • )} -
-
- )} +? ( +

Loading...

+ ) +: error +? ( +

Error: {error.message}

+ ) +: ( +
+

Example request from API:

+
    + {data.map((item) => ( +
  • {item.name}
  • + ))} +
+
+ )}
- ) -} -export default Home + ); +}; +export default Home; diff --git a/canopeum_frontend/src/pages/UserManagement.tsx b/canopeum_frontend/src/pages/UserManagement.tsx index da41e37c4..95772e6d2 100644 --- a/canopeum_frontend/src/pages/UserManagement.tsx +++ b/canopeum_frontend/src/pages/UserManagement.tsx @@ -1,11 +1,11 @@ -export default function UserManagement() { - return ( -
-
-
-

Setting

-
-
-
- ); -} +const UserManagement = () => ( +
+
+
+

Setting

+
+
+
+); + +export default UserManagement; diff --git a/canopeum_frontend/src/services/apiInterface.ts b/canopeum_frontend/src/services/apiInterface.ts index 303cedbab..aa9ac6533 100644 --- a/canopeum_frontend/src/services/apiInterface.ts +++ b/canopeum_frontend/src/services/apiInterface.ts @@ -1,5 +1,6 @@ import { AnnouncementClient, + AuthenticationClient, BatchClient, CommentClient, ContactClient, @@ -8,8 +9,7 @@ import { SiteClient, UserClient, WidgetClient, - AuthenticationClient, -} from "./api"; +} from './api'; const API_URL = String(import.meta.env.VITE_API_URL);