Skip to content

Commit

Permalink
ch[#162067435] implement status messages
Browse files Browse the repository at this point in the history
Move snackbar code to login.js
Delete snackbar.js as it is no longer needed
  • Loading branch information
ebenezerdon committed Nov 21, 2018
1 parent 4889f77 commit 0a4f194
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 28 deletions.
7 changes: 7 additions & 0 deletions UI/assets/js/checkLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (localStorage.accesstoken) {
if (localStorage.role === 'admin') {
window.location.replace('./pages/admindashboard.html');
} else {
window.location.replace('./pages/attendantdashboard.html');
}
}
17 changes: 0 additions & 17 deletions UI/assets/js/indexpage.js

This file was deleted.

14 changes: 13 additions & 1 deletion UI/assets/js/login.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
const addStatusMessageDiv = () => {
document.body.innerHTML += '<div id="status-msg"></div>';
};

const snackbar = (text) => {
const statusMessageDiv = document.getElementById('status-msg');
statusMessageDiv.innerHTML = text;
statusMessageDiv.style.display = 'block';
// eslint-disable-next-line no-return-assign
setTimeout(() => statusMessageDiv.style.display = 'none', 4000);
};

const loginUser = (e) => {
e.preventDefault();
Expand Down Expand Up @@ -33,4 +44,5 @@ const loginUser = (e) => {
});
};

document.getElementById('login').addEventListener('submit', loginUser);
window.onload = addStatusMessageDiv();
document.getElementById('login').addEventListener('submit', loginUser);
9 changes: 0 additions & 9 deletions UI/assets/js/snackbar.js

This file was deleted.

2 changes: 1 addition & 1 deletion UI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="./assets/css/main.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<script type="text/javascript" src="assets/js/indexpage.js"></script>
<script type="text/javascript" src="assets/js/checkLogin.js"></script>
</head>

<body>
Expand Down

0 comments on commit 0a4f194

Please sign in to comment.