<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\I18N;
use Illuminate\Support\Collection;

/**
 * @var bool                 $can_upload_media
 * @var Collection<int,Fact> $clipboard_facts
 * @var Collection<int,Fact> $facts
 * @var Family               $record
 */

?>

<?= view('family-page-pending', ['record' => $record]) ?>

<div class="d-flex mb-4">
    <h2 class="wt-page-title mx-auto">
        <?= $record->fullName() ?>
    </h2>
    <?php if ($record->canEdit()) : ?>
        <?= view('family-page-menu', ['can_upload_media' => $can_upload_media, 'clipboard_facts' => $clipboard_facts, 'record' => $record]) ?>
    <?php endif ?>
</div>

<div class="wt-page-content">
    <div class="wt-family-members d-flex">
        <?= view('family-page-children', ['family' => $record]) ?>
        <?= view('family-page-parents', ['family' => $record]) ?>
    </div>

    <h3 class="mt-4"><?= I18N::translate('Facts and events') ?></h3>
    <table class="table wt-facts-table">
        <?php if ($facts->isEmpty()) : ?>
            <tr>
                <td colspan="2">
                    <?= I18N::translate('No facts exist for this family.') ?>
                </td>
            </tr>
        <?php else : ?>
            <?php foreach ($facts as $fact) : ?>
                <?= view('fact', ['fact' => $fact, 'record' => $record]) ?>
            <?php endforeach ?>
        <?php endif ?>

        <?php if ($record->canEdit()) : ?>
            <?= view('fact-add-new', ['record' => $record]) ?>
        <?php endif ?>
    </table>
</div>

<?= view('modals/ajax') ?>
