Skip to content

Commit

Permalink
Merge pull request #47 from wanderlust-group-project-1/sandali
Browse files Browse the repository at this point in the history
Dashboard controller
  • Loading branch information
Sandali-Upekha authored Oct 31, 2023
2 parents 0030080 + 22bcade commit 0f8c255
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 55 deletions.
26 changes: 26 additions & 0 deletions app/controllers/Dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

class Dashboard
{
use Controller;

public function index(string $a = '', string $b = '', string $c = ''): void
{

$user = $_SESSION['USER'];
// echo $user->role;

if ($user->role == 'guide') {
//echo "Welcome";
$this->view('guide/GuideDashboard');
} else if ($user->role == 'rentalservice') {
$this->view('rental/RentalDashboard');
}

// else {
// $this->view('profile');
// }

// $this->view('profile');
}
}
2 changes: 1 addition & 1 deletion app/controllers/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function index(string $a = '', string $b = '', string $c = ''):void {
$this->view('customer/profile');
} else if ($user->role == 'guide') {
$this->view('guide/profile');
} else if ($user->role == 'admin') {
} else if ($user->role == 'rentalservice') {
$this->view('rental-service/profile');
}

Expand Down
106 changes: 52 additions & 54 deletions app/views/components/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,76 @@
<li class="nav-menu-item"><a href="#">Complaints</a></li>
</ul>

<?php if (isset($_SESSION['USER'] ) && $_SESSION['USER']->role != 'admin' ){ $user = $_SESSION['USER']; ?>
<?php if (isset($_SESSION['USER']) && $_SESSION['USER']->role != 'admin') {
$user = $_SESSION['USER']; ?>

<!-- profile avatar with dropdown -->

<div class="profile-avatar">
<img src="<?php echo ROOT_DIR?>/assets/images/1.png" alt="profile picture">
<div class="dropdown-menu" id="nav-dropdown">
<ul>
<li><a href="<?= ROOT_DIR ?>/profile">Profile</a></li>
<li><a href="<?= ROOT_DIR ?>/settings">Settings</a></li>
<li><a href="<?= ROOT_DIR ?>/logout">Logout</a></li>
</ul>
<div class="profile-avatar">
<img src="<?php echo ROOT_DIR ?>/assets/images/1.png" alt="profile picture">
<div class="dropdown-menu" id="nav-dropdown">
<ul>
<li><a href="<?= ROOT_DIR . ($user->role == 'guide' || $user->role == 'rentalservice' ? '/Dashboard' : '/profile') ?>">Profile</a></li>
<li><a href="<?= ROOT_DIR ?>/settings">Settings</a></li>
<li><a href="<?= ROOT_DIR ?>/logout">Logout</a></li>
</ul>
</div>
</div>
</div>



<?php }else if(isset($_SESSION['USER']) && $_SESSION['USER']->role == 'admin' ){ $admin = $_SESSION['USER']; ?>
<?php } else if (isset($_SESSION['USER']) && $_SESSION['USER']->role == 'admin') {
$admin = $_SESSION['USER']; ?>

<!-- profile avatar with dropdown -->
<div class="profile-avatar">
<img src="<?php echo ROOT_DIR?>/assets/images/1.png" alt="profile picture">
<div class="dropdown-menu" id="nav-dropdown">
<ul>
<li><a href="<?= ROOT_DIR ?>/admin/dashboard">Dashboard</a></li>
<!-- <li><a href="<?= ROOT_DIR ?>/settings">Settings</a></li> -->
<li><a href="<?= ROOT_DIR ?>/logout">Logout</a></li>
</ul>
<img src="<?php echo ROOT_DIR ?>/assets/images/1.png" alt="profile picture">
<div class="dropdown-menu" id="nav-dropdown">
<ul>
<li><a href="<?= ROOT_DIR ?>/admin/dashboard">Dashboard</a></li>
<!-- <li><a href="<?= ROOT_DIR ?>/settings">Settings</a></li> -->
<li><a href="<?= ROOT_DIR ?>/logout">Logout</a></li>
</ul>
</div>
</div>
</div>


<?php }else

{ ?>
<?php } else { ?>



<div class="login-button"><a href="<?= ROOT_DIR ?>/login">Login</a></div>
<div class="login-button"><a href="<?= ROOT_DIR ?>/login">Login</a></div>

<?php } ?>
</nav>

<script>
// Get the profile avatar element and the dropdown menu
var profileAvatar = document.querySelector('.profile-avatar');
var dropdownMenu = document.getElementById('nav-dropdown');

// Toggle the dropdown menu when clicking on the profile avatar
profileAvatar.addEventListener('click', function(event) {
// Prevent the default behavior of the anchor tags
event.preventDefault();

// Toggle the display style of the dropdown menu
if (dropdownMenu.style.display === 'block') {
dropdownMenu.style.display = 'none';
} else {
dropdownMenu.style.display = 'block';
}
});

// Close the dropdown menu if the user clicks outside of it
document.addEventListener('click', function(event) {
if (!profileAvatar.contains(event.target) && !dropdownMenu.contains(event.target)) {
dropdownMenu.style.display = 'none';
}
});

// Prevent event propagation when clicking on dropdown links
dropdownMenu.addEventListener('click', function(event) {
event.stopPropagation();
});


</script>
// Get the profile avatar element and the dropdown menu
var profileAvatar = document.querySelector('.profile-avatar');
var dropdownMenu = document.getElementById('nav-dropdown');

// Toggle the dropdown menu when clicking on the profile avatar
profileAvatar.addEventListener('click', function(event) {
// Prevent the default behavior of the anchor tags
event.preventDefault();

// Toggle the display style of the dropdown menu
if (dropdownMenu.style.display === 'block') {
dropdownMenu.style.display = 'none';
} else {
dropdownMenu.style.display = 'block';
}
});

// Close the dropdown menu if the user clicks outside of it
document.addEventListener('click', function(event) {
if (!profileAvatar.contains(event.target) && !dropdownMenu.contains(event.target)) {
dropdownMenu.style.display = 'none';
}
});

// Prevent event propagation when clicking on dropdown links
dropdownMenu.addEventListener('click', function(event) {
event.stopPropagation();
});
</script>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0f8c255

Please sign in to comment.