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

{block name="content"}
<!-- Page : Inscription -->


<main class="container py-5">

        <!-- Centrage horizontal du formulaire -->
    <div class="row justify-content-center position-relative">
        <div class="col-12 col-md-10 col-lg-6">

                            <!-- Carte contenant le formulaire d'inscription -->
            <div class="card shadow-sm border-0 rounded-4 p-4 p-lg-5">

                            <!-- Titre principal de la page -->
                <h1 class="h3 fw-bold mb-1">Edit du profile</h1>

                {if (isset($arrError) && count($arrError) > 0) }
	            	<div class="alert alert-danger">
	            	{foreach $arrError as $strError}
	            		<p>{$strError}</p>
	            	{/foreach}
	            	</div>
	            {/if}
                        <!-- Formulaire d'inscription -->
                <!-- Les données seront traitées côté serveur en PHP via la méthode POST -->
                <form method="POST" enctype="multipart/form-data">

                    <div class="row g-3">
                        <div class="col-md-6">
                            <label class="form-label" for="user_firstname">
                                                    Prénom 
                            </label>
                            <input
                                                    class="form-control"
                                                    type="text"
                                                    id="user_firstname"
                                                    name="user_firstname"
                                                    value="{$objUser->getFirstname()}"
                                                     >
                        </div>

                        <div class="col-md-6">
                            <label class="form-label" for="user_name">
                                                    Nom 
                            </label>
                            <input
                                                    class="form-control"
                                                    type="text"
                                                    id="user_name"
                                                    name="user_name"
                                                    value="{$objUser->getName()}"
                                                    
                            >
                        </div>

                        <div class="col-12">
                            <label class="form-label" for="user_pseudo">
                                                    Pseudo
                            </label>
                            <div class="input-group">
                            <span class="input-group-text">@</span>
                            <input
                                                        class="form-control"
                                                        type="text"
                                                        id="user_pseudo"
                                                        name="user_pseudo"
                                                         value="{$objUser->getPseudo()}"
                                                        
                            >
                        </div>
                    </div>
                    <div class="col-12">
                        <label class="form-label" for="image">
                            Photo de profil
                        </label>
                        {if $objUser->getImage()}
                            <div class="mb-2">
                                <img src="{$smarty.env.IMG_USER_PATH}{$objUser->getImage()}" alt="image actuel" class="rounded-circle" width="80" height="80">
                            </div>
                        {/if}
                        <input
                            class="form-control"
                            type="file"
                            id="image"
                            name="image"
                            accept="image/jpeg, image/png, image/webp"
                        >
                        <div class="form-text">Formats acceptés : JPG, PNG, WEBP. Laisser vide pour ne pas changer.</div>
                    </div>
                    <div class="col-12">
                        <label class="form-label" for="user_mail">
                                                Adresse e-mail 
                        </label>
                        <input
                                                class="form-control"
                                                type="email"
                                                id="user_mail"
                                                name="user_mail"
                                                value="{$objUser->getMail()}"
                                                
                        >
                    </div>

                                    
                    <div class="col-12">
                        <label class="form-label" for="user_phone">
                                                Téléphone
                        </label>
                        <input
                                                class="form-control"
                                                type="text"
                                                id="user_phone"
                                                name="user_phone"
                                                value="{$objUser->getPhone()}"
                        >
                    </div>

                                    
                    <div class="col-12">
                        <label class="form-label" for="user_work">
                                                Profession
                        </label>
                        <input
                                                class="form-control"
                                                type="text"
                                                id="user_work"
                                                name="user_work"
                                                value="{$objUser->getWork()}"
                        >
                    </div>

                                   
                    <div class="col-12">
                        <label class="form-label" for="user_location">
                                                Localisation
                        </label>
                        <input
                                                class="form-control"
                                                type="text"
                                                id="user_location"
                                                name="user_location"
                                                 value="{$objUser->getLocation()}"
                        >
                    </div>

                                    
                    <div class="col-12">
                        <label class="form-label" for="user_description">
                                                Phrase d'accroche
                        </label>
                        <textarea
                                                class="form-control"
                                                id="user_description"
                                                name="user_description"
                                                rows="3"
                        >
                        {$objUser->getDescription()}
                        </textarea>
                    </div>
                    <div class="col-12 d-grid mt-2">
                        <button type="submit" class="btn btn-primary btn-lg rounded-3">
                                                Edit profile
                        </button>
                    </div>

                        
                </form>

            </div>
                

        </div>

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