Skip to content
Snippets Groups Projects
Commit ed8bf87a authored by Nigel  Sahl's avatar Nigel Sahl
Browse files

fix: filter and search homepage admin

parent f74547dd
Branches
Tags
No related merge requests found
......@@ -12,8 +12,6 @@ AuthMiddleware::getInstance()->secureRoute(true);
$searching = [
// 'name' => $_GET["name"] ?? null,
// 'description' => $_GET["description"] ?? null
];
$itemInPage = 6;
......@@ -23,19 +21,6 @@ $selectedCity = $_GET["city"] ?? null;
$selectedPriceRange = $_GET["price-range"] ?? null;
$selectedSorting = $_GET["sorting"] ?? null;
$gymsFiltered = GymService::getInstance()->getFiltered(
[
'page' => $currentPage,
'cityId' => $selectedCity,
'sorting' => $selectedSorting,
'priceRange' => $selectedPriceRange,
'sortingOption' => $sortingOption,
'priceRangeOption' => $priceRangeOption,
'gymCountInPage' => $itemInPage,
'searching' => $searching
]
);
?>
<!DOCTYPE html>
......@@ -51,6 +36,17 @@ $gymsFiltered = GymService::getInstance()->getFiltered(
<body>
<div class="app">
<script>
const gym_name = <?php echo json_encode($_GET["gym_name"] ?? null) ?>;
const page = <?php echo json_encode($currentPage) ?>;
const selectedCity = <?php echo json_encode($selectedCity) ?>;
const selectedSorting = <?php echo json_encode($selectedSorting) ?>;
const selectedPriceRange = <?php echo json_encode($selectedPriceRange) ?>;
const sortingOption = <?php echo json_encode($sortingOption) ?>;
const priceRangeOption = <?php echo json_encode($priceRangeOption) ?>;
const itemInPage = <?php echo json_encode($itemInPage) ?>;
const searching = <?php echo json_encode($searching) ?>;
</script>
<?php
echo NavbarAdmin();
?>
......@@ -77,38 +73,34 @@ $gymsFiltered = GymService::getInstance()->getFiltered(
<?php
echo FilterForm($selectedCity, $selectedPriceRange, $selectedSorting);
?>
<div class="form-search">
<input id="input-search" class="input-search" type="text" name="name" onChange={handleChange}
placeholder="Search a gym" />
<button class="button-search" id="button-search">
<form class="form-search">
<input id="input-search" class="input-search" type="text" name="gym_name" placeholder="Search Gym">
<button type="button" class="button-search" id="button-search" onclick="buttonSearch(event)">
<img src="/public/icon/vector_search.svg" alt="Search Icon">
</button>
</div>
</form>
<a class="button-add-gym" id="add-gym" href="/admin/add">
<img src="/public/icon/add-gym.svg" alt="Add Gym Icon">
</a>
</div>
<div class="gym-card-container">
<?php
if (sizeof($gymsFiltered['gyms']) == 0) {
?>
<?= "No Gym Found" ?>
<?php
}
foreach ($gymsFiltered['gyms'] as $gym) {
echo GymCardAdmin($gym);
}
?>
<div class="gym-card-container" id="gym-card-container">
<div class="space"></div>
Loading...
</div>
<div class="pagination-container" id="pagination-container">
<div class="pagination-container">
<?php echo generatePagination($gymsFiltered['itemCount'], $itemInPage, $currentPage, $maxPages); ?>
</div>
</div>
<script src="/public/javascript/admin.js"></script>
<script src="/public/javascript/gym/format_card.js"></script>
<script src="/public/javascript/gym/gym_card_admin.js"></script>
<script src="/public/javascript/pagination.js"></script>
<script src="/public/javascript/gym/filter.js"></script>
<script src="/public/javascript/gym/search.js"></script>
<script src="/public/javascript/popup_with_id.js"></script>
</body>
......
function GymCard(gym) {
let truncated_name = truncateText(gym.name, 16);
let formatted_price = formatPrice(gym.monthly_price);
let gym_card = `
<div class="gym-card" id="gym-card-${gym.gym_id}">
<a class="content-gym-card" id="content-gym-card" href="/admin/gym?gym_id=${gym.gym_id}">
<img class="gym-card-picture" src="/public/image/gym/${gym.picture_id}.png" alt="Gym Image-${gym.picture_id}">
<div class="gym-card-text-admin">
<div class="gym-card-name">
${truncated_name}
</div>
<div class="gym-card-text-bottom">
<div class="gym-card-text-bottom-left">
${gym.average_rating}
<img src="/public/icon/star.svg" alt="Star Icon">
</div>
<div class="gym-card-text-bottom-right">
${formatted_price}
</div>
</div>
</div>
<div class="button-gym-card">
<a class="button-edit-delete-gym" id="edit-gym" href="/admin/edit?gym_id=${gym.gym_id}">
<img src="/public/icon/edit.svg" alt="Edit Gym Icon">
</a>
<button class="button-edit-delete-gym" id="delete-gym-${gym.gym_id}" onclick="event.stopPropagation();showPopupDel(${gym.gym_id});">
<img src="/public/icon/trash.svg" alt="Trash Gym Icon">
</button>
</div>
</a>
</div>
<div class="popup" id="pop-up-delete-${gym.gym_id}" onclick="hidePopupDel(${gym.gym_id});">
<div class="popup-content" onclick="event.stopPropagation();">
<div class="popup-title" id="pop-up-title-edit-delete">
Do you want to delete ${gym.name}
</div>
<div class="space2"></div>
<button class="search-filter" onclick="deleteGymCall(${gym.gym_id});" id="yes-btn-del">Yes</button>
<div class="space3"></div>
<button class="cancel-filter" id="cancel-btn-del" onclick="hidePopupDel(${gym.gym_id});">Cancel</button>
</div>
</div>
`;
return gym_card;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment