<?php the_admin_header('Dashboard') ?>

<div class="admin-container">
    <section>
        <h2 class="title">Stats per month</h2>

        <div id="dashboard-stats">
            <div class="dashboard-stats__item top-sales">
                <div class="icon">
                    <i class="fa-solid fa-bowl-food"></i>
                </div>
                <div class="info">
                    <div class="label">New recipes</div>
                    <div class="value"><?= $context['recipes_count'] ?></div>
                </div>
            </div>

            <div class="dashboard-stats__item profit">
                <div class="icon">
                    <i class="fa-solid fa-message"></i>
                </div>
                <div class="info">
                    <div class="label">New reviews</div>
                    <div class="value">0</div>
                </div>
            </div>

            <div class="dashboard-stats__item orders">
                <div class="icon">
                    <i class="fa-solid fa-user-slash"></i>
                </div>
                <div class="info">
                    <div class="label">Banned users</div>
                    <div class="value"><?= $context['ban_count'] ?></div>
                </div>
            </div>

            <div class="dashboard-stats__item new-users">
                <div class="icon">
                    <i class="fa-solid fa-user"></i>
                </div>
                <div class="info">
                    <div class="label">New users</div>
                    <div class="value"><?= $context['user_count'] ?></div>
                </div>
            </div>
        </div>
    </section>

    <section>
        <h2 class="title">Quick tools</h2>

        <div id="quicktools">
            <a href="<?php the_permalink('admin:recipe-new') ?>" class="btn btn-secondary hover-anim">
                <i class="fa-solid fa-plus"></i> New recipe
            </a>
            <form action="<?php the_permalink('admin:recipe-list') ?>" method="get">
                <div class="input-admin">
                    <input type="text" name="s" placeholder="Search for recipes">
                    <button class="btn btn-secondary hover-anim" type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
                </div>
            </form>
            
        </div>
    </section>

    <h2 class="title">Latest resipes</h2>

    <table class="admin-table">
        <thead>
            <tr>
                <th>Title</th>
                <th>Price</th>
                <th>Status</th>
                <th>Created At</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($context['latest_recipes'] as $recipe): ?>
            <tr>
                <td><a href="<?php the_permalink('admin:recipe', [$recipe->get_id()]) ?>"><?= $recipe->field_title ?></a></td>
                <td><?= $recipe->get_price() ?></td>
                <td><?= $recipe->get_status() ?></td>
                <td><?= $recipe->field_created_at ?></td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>
</div>

<?php the_admin_footer() ?>