{extends file="views/layout.tpl"}

{block name="content"}
<main class="container mt-5 py-5">

    <!-- Message après l'envoi d'email -->
    {if isset($smarty.get.mail) && $smarty.get.mail === 'ok'}
        <div class="alert alert-success">Email envoyé avec succès.</div>
    {elseif isset($smarty.get.mail) && $smarty.get.mail === 'fail'}
        <div class="alert alert-danger">Erreur lors de l'envoi de l'email.</div>
    {/if}

    <div class="row g-4">

        <!-- Contenu principal du projet -->
        <div class="col-lg-8">

            <h1 class="fw-bold">{$objProject->getTitle()}</h1>

            <p class="text-muted">
                {$arrProject.category_name ?? 'Général'}
            </p>

            <div class="mb-4 shadow-sm">
                <img src=".{$objProject->getThumbnail()}"
                     class="img-fluid rounded w-100">
            </div>

            <div class="bg-light p-4 rounded mb-4">
                <h4 class="border-bottom pb-2">Description</h4>
                <p class="lead">{$objProject->getDescription()}</p>

                <div class="mt-4">
                    {$objProject->getContent()}
                </div>
            </div>

            <!-- Formulaire qui envoie la demande au contrôleur (sendEmail) -->
            <div class="card shadow-sm p-4 mb-5">
                <form method="post" action="index.php?ctrl=project&action=sendEmail">

                    <input type="hidden" name="project_id"
                           value="{$objProject->getId()}">

                    <input type="email" name="to_email"
                           class="form-control mb-3"
                           placeholder="Adresse email" required>

                    <button type="submit" class="btn btn-primary w-100">
                        Envoyer par email
                    </button>

                </form>
            </div>

        </div>

        <!-- Sidebar : informations du créateur -->
        <div class="col-lg-4">
            <div class="card text-center shadow-sm p-4">

                <img src=".{$objProject->getUser_image()}"
                     class="rounded-circle mb-3 mx-auto"
                     style="width:100px;height:100px;object-fit:cover;">

                <h5>{$objProject->getCreatorName()}</h5>

                <p class="text-muted small">
                    Publié le {$objProject->getCreation_date()}
                </p>

                <button class="btn btn-primary">Contacter le talent</button>

            </div>
        </div>

    </div>
</main>
{/block}