<?php
require_once "common/Queries.php";
$q = new Queries();

$mainCategories = $q->getMainCategories();

// Used when user clicks subcategory
$mainCatId = $_GET["main"] ?? $mainCategories[0]["id"];
?>

<div data-simplebar class="px-4 pb-4">
  <div class="service-selector">
    <ul>
      <?php foreach ($mainCategories as $cat): ?>
        <li class="<?= ($mainCatId == $cat["id"]) ? 'active' : '' ?>">
          <a href="services.php?main=<?= $cat['id'] ?>">
            <img src="<?= $cat["icon"] ?>" width="24" height="24" class="icon">
            <?= $cat["name"] ?>
          </a>
        </li>
      <?php endforeach; ?>
    </ul>
  </div>
</div>
