<?php
use App\Services\SetupDefaults;
$dash = $draft['dashboard'] ?? [];
?>
<div class="sup-page">
  <?php \App\Core\View::partial('setup_nav', compact('section', 'dirty', 'canUndo', 'publishedAt')); ?>
  <form class="set-section ajax-form" action="<?= e(url('setup/save')) ?>" method="post">
    <?= csrf_field() ?>
    <input type="hidden" name="section" value="dashboard">
    <div class="set-section-head">
      <div>
        <div class="set-section-title"><i class="bi bi-grid-1x2"></i> Home cards</div>
        <p class="set-section-sub">Pick which cards each role sees on Home after publish.</p>
      </div>
      <button class="btn btn-primary" type="submit">Save draft</button>
    </div>
    <div class="sup-form-grid">
      <?php foreach (SetupDefaults::DASH_CARDS as $role => $cards):
          $on = $dash[$role] ?? array_keys($cards);
      ?>
        <article class="sup-form-card">
          <h2><?= e(ucfirst($role)) ?></h2>
          <?php foreach ($cards as $key => $label): ?>
            <label class="sup-check">
              <input type="checkbox" name="dashboard[<?= e($role) ?>][]" value="<?= e($key) ?>" <?= in_array($key, $on, true) ? 'checked' : '' ?>>
              <?= e($label) ?>
            </label>
          <?php endforeach; ?>
        </article>
      <?php endforeach; ?>
    </div>
  </form>
</div>
