<?= $this->layout('_layout', ['title' => $title]); ?>

<main class="main">
    <?= $this->insert('includes/aside_info') ?>

    <div class="content">
        <div class="h2-title h2-title-content flex-s-c">
            <span>My Ads</span>
        </div>


        <ul class="_links">
            <li><a class="button" href="<?= __redirect("market/vault") ?>">To go back</a></li>
        </ul>


        <?php if (plugin()->market) : ?>
            <div class="information warning">
                <strong>Attention:</strong> check that <strong>there is space in your chest and log out of your game account</strong>
                <br> to remove your items from the market, otherwise they will be visible for purchase.
            </div>
            <?php if ($items) :  ?>
                <div class="information">
                    <div>
                        <table>
                            <tbody class="bg-neutral-600">
                                <tr>
                                    <td width="6%" align="center"><b>#</b></td>
                                    <td><b>Item</b></td>
                                    <td><b>Price</b></td>
                                    <td></td>
                                </tr>
                                <?php foreach ($items as $item) : ?>
                                    <tr class="image-view">
                                        <td><img src="<?= __resources("items/{$item['details']['image']}"); ?>" alt="" width="80" height="80" style="object-fit:contain"></td>
                                        <td><?= $item['details']['name'] ?></td>
                                        <td><?= $item['price'] ?> <?= $item['coin_name'] ?></td>
                                        <td> <a class="button" href="<?= __redirect('auth/market/remove/item/' . $item['id']) ?>">To remove</a></td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>

                </div>
            <?php else : ?>
                <br>
                <div class="warning">There are no items announced at this time</div>
            <?php endif; ?>
        <?php else : ?>
            <br>
            <div class="warning">Function disabled by administration</div>
        <?php endif; ?>
    </div>
</main>