-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.js
29 lines (24 loc) · 1.23 KB
/
admin.js
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
// admin.js
document.addEventListener('DOMContentLoaded', function () {
// Check if the user is logged in and if they are an admin
const isLoggedIn = localStorage.getItem('isLoggedIn'); // Example check for login status
const isAdmin = localStorage.getItem('isAdmin'); // Example check for admin status
// Get the admin action buttons
const addCourseButton = document.getElementById('addCourseButton');
const deleteCourseButton = document.getElementById('deleteCourseButton');
// If the user is logged in and is an admin, show the buttons
if (isLoggedIn && isAdmin === 'true') {
addCourseButton.style.display = 'inline-block';
deleteCourseButton.style.display = 'inline-block';
} else {
addCourseButton.style.display = 'none';
deleteCourseButton.style.display = 'none';
}
// Example logic to handle button clicks (you can modify as per your needs)
addCourseButton.addEventListener('click', function () {
alert("Adding a course..."); // Replace with actual add course functionality
});
deleteCourseButton.addEventListener('click', function () {
alert("Deleting a course..."); // Replace with actual delete course functionality
});
});