<?php

use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Tree;

/**
 * @var bool          $is_admin
 * @var Individual    $individual
 * @var array<object> $stories
 * @var Tree          $tree
 */

?>

<div class="wt-tab-stories py-4">
    <?php foreach ($stories as $story) : ?>
        <div class="story_title descriptionbox text-center rela">
            <?= e($story->title) ?>
        </div>
        <div class="story_body optionbox">
            <?= $story->story_body ?>
        </div>
        <?php if ($is_admin) : ?>
            <div class="story_edit">
                <a href="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminEdit', 'block_id' => $story->block_id, 'tree' => $tree->name(), 'url' => $individual->url()])) ?>">
                    <?= I18N::translate('Edit the story') ?>
                </a>
            </div>
        <?php endif ?>
    <?php endforeach ?>

    <?php if ($is_admin && $stories === []) : ?>
        <div>
            <a href="<?= e(route('module', ['module' => 'stories', 'action' => 'AdminEdit', 'xref' => $individual->xref(), 'tree' => $tree->name(), 'url' => $individual->url()])) ?>">
                <?= I18N::translate('Add a story') ?>
            </a>
        </div>
    <?php endif ?>
</div>
