diff --git a/web/components/login/login.js b/web/components/login/login.js new file mode 100644 index 0000000000000000000000000000000000000000..d1c4621238805faa7b98990d934676bf51787716 --- /dev/null +++ b/web/components/login/login.js @@ -0,0 +1,13 @@ +export async function mount(where) { + const loginComponent = new Login(); + await loginComponent.mount(where); +} + +class Login { + constructor() { + } + + async mount(mountpoint) { + document.getElementById(mountpoint).innerHTML = /* HTML */ "Empty page" + } +} diff --git a/web/main.js b/web/main.js index 06adfcb2c48a952fc1a87ff09f7e1ad39889b445..dd35937629c1de3c1a30657d55ef1fa3399d5604 100644 --- a/web/main.js +++ b/web/main.js @@ -1,6 +1,7 @@ import * as Auth from "/components/auth/auth.js"; import * as Matcher from "/components/matcher/matcher.js"; import * as Info from "/components/info/info.js"; +import * as Login from "./components/login/login.js"; const mountPoint = document.getElementById("main"); let user = {}; @@ -11,39 +12,47 @@ document.addEventListener("DOMContentLoaded", async () => { }); async function navigate() { - switch (location.pathname) { - case "/auth": - load(mountPoint, async function () { - await Auth.mount("main"); - }); - break; - case "/matcher": - load(mountPoint, async function () { - await Matcher.mount("main"); - }); - break; - case "/mandatecreated": - load(mountPoint, async function () { - await Info.mount("main", "Le mandat a été créé avec succès !"); - }); - break; - case "/callback": - // Redirect to server callback according to cookie - try { - const callbackRoute = document.cookie - .split("; ") - .find((row) => row.startsWith("callbackRoute=")) - .split("=")[1]; - if (callbackRoute != "" && callbackRoute != null) { - location.pathname = callbackRoute; + console + if(user == undefined){ + console.log("test") + load(mountPoint, async function() { + await Login.mount("main"); + }) + }else{ + switch (location.pathname) { + case "/auth": + load(mountPoint, async function () { + await Auth.mount("main"); + }); + break; + case "/matcher": + load(mountPoint, async function () { + await Matcher.mount("main"); + }); + break; + case "/mandatecreated": + load(mountPoint, async function () { + await Info.mount("main", "Le mandat a été créé avec succès !"); + }); + break; + case "/callback": + // Redirect to server callback according to cookie + try { + const callbackRoute = document.cookie + .split("; ") + .find((row) => row.startsWith("callbackRoute=")) + .split("=")[1]; + if (callbackRoute != "" && callbackRoute != null) { + location.pathname = callbackRoute; + } + } catch (e) { + console.error("no callback route was gotten from the cookie"); } - } catch (e) { - console.error("no callback route was gotten from the cookie"); - } - break; - default: - location.pathname = "auth"; - break; + break; + default: + location.pathname = "auth"; + break; + } } }