@extends('layouts.base')

@section('menu')
    @include('etudiants.menu')
@endsection

@section('content')
<section class="profile-details bg-light py-5">
    <div class="container">
        <!-- Header -->
        <div class="header d-flex justify-content-between align-items-center mb-4">
            <h1 class="text-primary">Mon Profil</h1>
            <a href="{{ route('etudiants.offres.index') }}" class="btn btn-outline-primary">
                <i class="bi bi-arrow-left"></i> Retour à l'accueil
            </a>
        </div>

        <!-- User Profile Details -->
        <div class="card shadow-sm">
            <div class="card-body ">
                <div class="d-flex align-items-center mb-4">
                    <img src="{{ asset('auth/images/img2.svg') }}" alt="User Avatar" class="rounded-circle me-3" width="80" height="80">
                    <div>
                        <h3 class="card-title">{{ auth()->user()->name }} {{ auth()->user()->surname }}</h3>
                        <p class="text-muted">{{ auth()->user()->email }}</p>
                    </div>
                </div>

                <hr>
                <h2 class="d-flex justify-content-center align-items-center vh-10">Mettez à jour votre profil</h2>
                <div class="row d-flex justify-content-center align-items-center vh-10">
                
                    <div class="col-md-6">
                    
                    <form action="{{ route('etudiants.updateProfile') }}" method="POST" enctype="multipart/form-data">
                            @csrf
                        
                            <div class="mb-3">
                                <label for="name" class="form-label">Nom</label>
                                <input type="text" class="form-control" id="name" name="name" value="{{ old('name', $user->name) }}" required>
                                @error('name')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>

                            <div class="mb-3">
                                <label for="email" class="form-label">Email</label>
                                <input type="email" class="form-control" id="email" name="email" value="{{ old('email', $user->email) }}" readonly>
                                @error('email')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="matricule" class="form-label">Matricule</label>
                                <input type="matricule" class="form-control" id="matricule" name="matricule" value="{{ old('matricule', $user->matricule) }}" readonly>
                                @error('matricule')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>


                            <div class="mb-3">
                                <label for="password" class="form-label">Mot de passe (laissez vide pour ne pas modifier)</label>
                                <input type="password" class="form-control" id="password" name="password">
                            </div> 
                            <div class="mb-3">
                                <label for="phone" class="form-label">Téléphone</label>
                                <input type="text" class="form-control" id="phone" name="phone" value="{{ old('phone', $user->phone) }}" >
                                @error('name')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div> <div class="mb-3">
                                <label for="birthday" class="form-label">Date de naissance</label>
                                <input type="date" class="form-control" id="birthday" name="birthday" value="{{ old('birthday', $user->birthday) }}" >
                                @error('name')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div> <div class="mb-3">
                                <label for="birthplace" class="form-label">Lieu de naissance</label>
                                <input type="text" class="form-control" id="birthplace" name="birthplace" value="{{ old('birthplace', $user->birthplace) }}" >
                                @error('name')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div> <div class="mb-3">
                                <label for="address" class="form-label">Adresse</label>
                                <input type="text" class="form-control" id="address" name="address" value="{{ old('address', $user->address) }}" >
                                @error('name')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>
                            <div class="mb-3">
                                <label for="cv" class="form-label">Télécharger votre CV</label>
                                <input type="file" class="form-control" id="cv" name="cv" accept=".pdf,.doc,.docx,.jpg,.jpeg,.png" >
                                @error('cv')
                                    <div class="text-danger">{{ $message }}</div>
                                @enderror
                            </div>

                            <button type="submit" class="btn btn-primary">Mettre à jour</button>
                    </form>
    
     
            </div>
        </div>
    </div>
</section>
@endsection
