<?php
$downloads = mb_get_block_field("component-downloads");

if ($downloads) { ?>
<section <?= inoby_block_attrs($attributes, ["class" => "component-downloads"]) ?>>
  <div class="container">
    <div class="row">
      <div class="col-12">
        <div class="downloads-wrap">
          <?php foreach ($downloads as $download): ?>
          <div class="download-item">
            <?php
            echo isset($download["name"]) ? "<h5>" . $download["name"] . "</h5>" : "";
            foreach ($download["files"] ?? [] as $file):
              $file_url = wp_get_attachment_url($file);
              $file_name = get_the_title($file);
              echo '<a target="_blank" class="download-link" href="' . $file_url . '">' . $file_name . "</a>";
            endforeach;
            ?>
          </div>
          <?php endforeach; ?>
        </div>
      </div>
    </div>
  </div>
</section>
<?php }
