Newer
Older
import * as Auth from "/components/auth/auth.js";
import * as Matcher from "/components/matcher/matcher.js";
import * as Login from "./components/login/login.js";
const mountPoint = document.getElementById("main");
document.addEventListener("DOMContentLoaded", async () => {
navigate();
});
async function navigate() {
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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");
break;
default:
location.pathname = "auth";
break;
}
}
}
async function load(element, domAlteration) {
// Start the alteration
const alteration = domAlteration();
await alteration; // Await for alteration end
}