@extends('layouts.dashboard')
@section('title', 'ویرایش پروفایل')

@section('content')
    <h3 class="fw-bold mb-4">پروفایل کاربری</h3>
    <div class="row">
        <div class="col-lg-4 mb-4">
            <div class="card text-center p-4">
                <div class="position-relative d-inline-block mb-3">
                    <img src="https://picsum.photos/seed/user1/150/150" class="rounded-circle border border-4 border-light shadow-sm" alt="Avatar" id="profilePreview">
                    <label for="uploadImage" class="position-absolute bottom-0 start-100 translate-middle bg-primary text-white rounded-circle p-2" style="cursor: pointer; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center;">
                        <i class="bi bi-camera-fill small"></i>
                    </label>
                    <input type="file" id="uploadImage" class="d-none" accept="image/*" onchange="previewImage(event)">
                </div>
                <h5 class="fw-bold">
                    {{ userinfo()->firstname }} {{ userinfo()->lastname }}
                </h5>
                <p class="text-muted">{{ userinfo()->phone }}</p>
                <hr>
                <div class="d-grid">
                    <a href="{{ route('changepass') }}" class="btn btn-outline-danger btn-sm rounded-3">
                        <i class="bi bi-lock-fill me-1"></i> تغییر رمز عبور
                    </a>
                </div>
            </div>
        </div>
        <div class="col-lg-8">
            <div class="card p-4">
                <h5 class="fw-bold mb-3">ویرایش اطلاعات</h5>
                <form action="{{ route('doUpdateProfile') }}" method="POST">
                    @csrf
                    <div class="row g-3">
                        <div class="col-md-6">
                            <label class="form-label text-muted small">نام</label>
                            <input type="text" class="form-control" name="firstname" value="{{ userinfo()->firstname }}">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label text-muted small">نام خانوادگی</label>
                            <input type="text" class="form-control" name="lastname" value="{{ userinfo()->lastname }}">
                        </div>
                        <div class="col-md-12">
                            <label class="form-label text-muted small">شماره</label>
                            <input type="tel" name="phone" class="form-control" value="{{ userinfo()->phone }}">
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-6">
                            <label class="form-label text-muted small">استان</label>
                            <input type="text" name="state" value="{{ userinfo()->state }}" class="form-control">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label text-muted small">شهر</label>
                            <input type="text" name="city" value="{{ userinfo()->city }}" class="form-control">
                        </div>
                    </div>


                    <div class="col-12 mt-4">
                        <button type="submit" class="btn btn-primary-custom">ذخیره تغییرات</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

@endsection
