diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 062a82e..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - root: true, - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint", "react", "react-hooks"], - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - ], - rules: { - "prefer-const": ["error", { - "destructuring": "all" - }] - }, - settings: { - react: { - version: "detect", - }, - }, -} diff --git a/Documentation/how-to-dev.md b/Documentation/how-to-dev.md index 287a7fe..97a9fa1 100644 --- a/Documentation/how-to-dev.md +++ b/Documentation/how-to-dev.md @@ -1,3 +1,8 @@ +# THIS FILE IS DEPRECATED +See [#107](https://codefirst.iut.uca.fr/git/IQBall/Application-Web/pulls/107) for more details + +----- + This documentation file explains how to start a development server on your machine, and how it works under the hood. diff --git a/package.json b/package.json index 75215b4..7eb6cfb 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "iqball_web", "version": "0.1.0", "private": true, + "type": "module", "dependencies": { - "@loadable/component": "^5.16.3", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -28,7 +28,6 @@ "tsc": "tsc" }, "devDependencies": { - "@types/loadable__component": "^5.13.8", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", "@vitejs/plugin-react": "^4.1.0", diff --git a/src/App.tsx b/src/App.tsx index 13379fe..4312161 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,17 +1,17 @@ import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom" -import loadable from "@loadable/component" import { Header } from "./pages/template/Header.tsx" import "./style/app.css" +import { lazy } from "react" -const HomePage = loadable(() => import("./pages/HomePage.tsx")) -const LoginPage = loadable(() => import("./pages/LoginPage.tsx")) -const RegisterPage = loadable(() => import("./pages/RegisterPage.tsx")) -const NotFoundPage = loadable(() => import("./pages/404.tsx")) -const CreateTeamPage = loadable(() => import("./pages/CreateTeamPage.tsx")) -const TeamPanelPage = loadable(() => import("./pages/TeamPanel.tsx")) -const NewTacticPage = loadable(() => import("./pages/NewTacticPage.tsx")) -const Editor = loadable(() => import("./pages/Editor.tsx")) +const HomePage = lazy(() => import("./pages/HomePage.tsx")) +const LoginPage = lazy(() => import("./pages/LoginPage.tsx")) +const RegisterPage = lazy(() => import("./pages/RegisterPage.tsx")) +const NotFoundPage = lazy(() => import("./pages/404.tsx")) +const CreateTeamPage = lazy(() => import("./pages/CreateTeamPage.tsx")) +const TeamPanelPage = lazy(() => import("./pages/TeamPanel.tsx")) +const NewTacticPage = lazy(() => import("./pages/NewTacticPage.tsx")) +const Editor = lazy(() => import("./pages/Editor.tsx")) export default function App() { return ( diff --git a/src/Fetcher.ts b/src/Fetcher.ts index 52a71b3..f4af2ce 100644 --- a/src/Fetcher.ts +++ b/src/Fetcher.ts @@ -9,7 +9,7 @@ export async function fetchAPI( url: string, payload: unknown, method = "POST", - redirectIfNotAuth: boolean = true, + redirectIfUnauthorized: boolean = true, ): Promise { const session = getSession() const token = session?.auth?.token @@ -29,7 +29,7 @@ export async function fetchAPI( body: JSON.stringify(payload), }) - return await handleResponse(session, response, redirectIfNotAuth) + return await handleResponse(session, response, redirectIfUnauthorized) } export async function fetchAPIGet( diff --git a/src/pages/LoginPage.tsx b/src/pages/LoginPage.tsx index b12c386..d41ae87 100644 --- a/src/pages/LoginPage.tsx +++ b/src/pages/LoginPage.tsx @@ -17,7 +17,7 @@ export default function LoginApp() { const email = emailRef.current!.value const password = passwordRef.current!.value - const response = await fetchAPI("auth/token", { email, password }) + const response = await fetchAPI("auth/token", { email, password }, "POST", false) if (response.ok) { const session = getSession() @@ -27,6 +27,12 @@ export default function LoginApp() { return } + // if unauthorized : + if (response.status === 401) { + setErrors([{ type: "Non autorisé", messages: ["L'adresse email ou le mot de passe sont invalide."] }]) + return + } + try { const failures = await response.json() setErrors(