<?php

/**
 * @var array<int, string> $errors
 * @var array $form
 */

?>
<div class="app-details-container">
  <section>
    <?php
    $hasTenantOptions = !empty($tenants);
    $breadcrumbs = [
      ['label' => t('Home'), 'path' => 'admin'],
      ['label' => t('Departments'), 'path' => 'admin/departments'],
      ['label' => t('Create department')],
    ];
    require templatePath('partials/app-breadcrumb.phtml');
    $titlebar = [
      'title' => t('Create department'),
      'backHref' => 'admin/departments',
      'backTitle' => t('Cancel'),
      'actions' => [
        [
          'form' => 'department-form',
          'name' => 'action',
          'value' => 'create',
          'class' => 'secondary outline',
          'label' => t('Create'),
          'disabled' => !$hasTenantOptions,
        ],
        [
          'form' => 'department-form',
          'name' => 'action',
          'value' => 'create_close',
          'class' => 'primary',
          'label' => t('Create & close'),
          'disabled' => !$hasTenantOptions,
        ],
      ],
    ];
    require templatePath('partials/app-details-titlebar.phtml');
    ?>
    <?php
    $validationSummaryErrors = $validationSummaryErrors ?? ($errors ?? []);
    require templatePath('partials/app-details-validation-summary.phtml');
    ?>
    <?php if (!empty($warnings)): ?>
      <div class="notice" data-variant="info">
        <ul>
          <?php foreach ($warnings as $warning): ?>
            <li><?php e($warning); ?></li>
          <?php endforeach; ?>
        </ul>
      </div>
    <?php endif; ?>
    <?php
    $values = $form ?? [];
    $detailsOpenAll = true;
    require __DIR__ . '/_form.phtml';
    ?>
  </section>
</div>
