62 lines
2.4 KiB
JavaScript
62 lines
2.4 KiB
JavaScript
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
|
import Layout from "../pages/Layout";
|
|
import Home from "../pages/Home";
|
|
import AboutUs from "../pages/AboutUs";
|
|
import Privacy from "../pages/Privacy";
|
|
import ContactUs from "../pages/ContactUs";
|
|
import Morceaux from "../pages/Morceaux";
|
|
import MorceauDetail from "../pages/MorceauDetail";
|
|
import Inventaire from "../pages/Inventaire";
|
|
import Login from "../pages/Login";
|
|
import Logout from "../pages/Logout";
|
|
import Register from "../pages/Register";
|
|
import Formulaire from "../pages/Formulaire";
|
|
import MyInvoices from "../pages/MyInvoices";
|
|
import { useState, useEffect } from "react";
|
|
import React from 'react';
|
|
import Invoices from "../pages/Invoices";
|
|
import Cookies from "universal-cookie";
|
|
import ReviewInvoice from "../pages/ReviewInvoice";
|
|
|
|
const App = () => {
|
|
const cookies = new Cookies();
|
|
|
|
useEffect(() => {
|
|
async function FetchUser() {
|
|
const response = await fetch(`https://localhost:7292/api/WhoAmI`, { credentials: 'include' });
|
|
if (response.status === 200) {
|
|
var user = await response.json();
|
|
cookies.set('GMGM', { ...user, LoggedIn: true }, { path: '/', SameSite: 'strict', secure: true, maxAge: 2592000 })
|
|
}
|
|
else cookies.set('GMGM', { LoggedIn: false }, { path: '/', SameSite: 'strict', secure: true, maxAge: 2592000 })
|
|
}
|
|
if (cookies.GMGM === null) {
|
|
FetchUser();
|
|
}
|
|
});
|
|
|
|
return (
|
|
<BrowserRouter>
|
|
<Routes>
|
|
<Route path="/" element={<Layout />}>
|
|
<Route index element={<Home />} />
|
|
<Route path="morceaux" element={<Morceaux />} />
|
|
<Route path="aboutUs" element={<AboutUs />} />
|
|
<Route path="contactUs" element={<ContactUs />} />
|
|
<Route path="privacy" element={<Privacy />} />
|
|
<Route path="morceaux/:id" element={<MorceauDetail />} />
|
|
<Route path="inventaire" element={<Inventaire />} />
|
|
<Route path="login" element={<Login />} />
|
|
<Route path="logout" element={<Logout />} />
|
|
<Route path="register" element={<Register />} />
|
|
<Route path="formulaire" element={<Formulaire />} />
|
|
<Route path="myinvoices" element={<MyInvoices />} />
|
|
<Route path="invoices" element={<Invoices />} />
|
|
<Route path="reviewinvoice" element={<ReviewInvoice />} />
|
|
</Route>
|
|
</Routes>
|
|
</BrowserRouter>
|
|
);
|
|
};
|
|
|
|
export default App; |