-
Notifications
You must be signed in to change notification settings - Fork 2
/
navbar.html
80 lines (68 loc) · 2.85 KB
/
navbar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Self Drive Car Rentals | Rent a Car | Car Hire @ Zoomcar</title>
<link href="https://www.zoomcar.com/fav/favicon.png" rel="shortcut icon" type="image/png">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<link rel="stylesheet" href="./styles/navbar.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" >
</head>
<body>
<nav class="navbar" id="mainNav">
</nav>
</body>
</html>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script src="https://kit.fontawesome.com/445205b9df.js" crossorigin="anonymous"></script>
<script type="module">
import { afterLogin, beforeLogin } from "./components/header.js";
let user = JSON.parse(localStorage.getItem("current-user")) || null;
let navbar = document.getElementById("mainNav");
if (user != null) {
navbar.innerHTML = afterLogin();
document.getElementById("name").innerText = user.name;
document.getElementById("uName").innerText = user.name;
document.getElementById("email").innerText = user.email;
document.getElementById("mob").innerText = user.number;
document.getElementById("city").innerText = user.city;
} else {
navbar.innerHTML = beforeLogin();
}
let logout = document.getElementById("logout");
if (logout) {
logout.addEventListener("click", logoutMe);
}
function logoutMe() {
swal({
title: "Are you sure?",
icon: "warning",
buttons: true,
dangerMode: true,
}).then((willDelete) => {
if (willDelete) {
localStorage.setItem("current-user", JSON.stringify(null));
window.location.href = "navbar.html";
swal("You are successfully logout!", {
icon: "success",
});
}
});
}
if (user != null) {
let goToProfile = document.getElementById("uName");
let goToProfile1 = document.getElementById("logData");
goToProfile.addEventListener("click", profile);
goToProfile1.addEventListener("click", profile1);
function profile() {
window.location.href = "profile.html";
}
function profile1() {
window.location.href = "profile.html";
}
}
</script>