@extends('layouts.app')
@section('title', 'User Profile')
@section('content')
    <section class="breadcrumb-area pt-5 pb-5" >
        <div class="container">
            <div class="breadcrumb-content text-center">
                <h2>{{__('Dashboard')}}</h2>
                <ul>
                    <li><a href="{{route('home')}}">{{__('Home')}}</a></li>
                    <li> {{__('My profile')}}</li>
                </ul>
            </div>
        </div>
    </section>
    <section class="container pt-4 pb-5 ">
        <div class="row">
            <div class="col-lg-8">
                <form action="{{ route('user.update_profile') }}" method="POST" enctype="multipart/form-data" autocomplete="off">
                    @csrf
                    @method('PATCH')
                    <div class="row">
                        <div class="col-lg-12 text-center mb-4">
                            @if(auth(activeGuard())->user()->user_image)
                                <img src="{{ asset('storage/images/users/' . auth(activeGuard())->user()->user_image) }}"
                                     class="img-thumbnail" width="120"
                                     alt="{{ auth(activeGuard())->user()->full_name }}">
                                <div class="mt-2">
                                    <a href="{{ route('user.remove_image') }}" class="btn btn-outline-danger">{{__("Remove image")}}</a>
                                </div>
                            @else
                                <img src="{{ asset('img/avatar.png') }}"
                                     class="img-thumbnail" width="120"
                                     alt="{{ auth(activeGuard())->user()->full_name }}">
                            @endif
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6 form-group">
                            <label for="first_name" class="text-small text-uppercase">{{__("First Name")}}</label>
                            <input type="text" class="form-control "
                                   name="first_name" id="first_name"
                                   value="{{ old('first_name', auth(activeGuard())->user()->first_name) }}">
                            @error('first_name')<span class="text-danger">{{ $message }}</span>@enderror
                        </div>

                        <div class="col-lg-6 form-group">
                            <label for="last_name" class="text-small text-uppercase">{{__("Last Name")}}</label>
                            <input type="text" class="form-control "
                                   name="last_name" id="last_name"
                                   value="{{ old('last_name', auth(activeGuard())->user()->last_name) }}">
                            @error('last_name')<span class="text-danger">{{ $message }}</span>@enderror
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6 form-group">
                            <label for="email" class="text-small text-uppercase">{{__('Email')}}</label>
                            <input type="email" class="form-control "
                                   name="email" id="email"
                                   value="{{ old('email', auth(activeGuard())->user()->email) }}">
                            @error('email')<span class="text-danger">{{ $message }}</span>@enderror
                        </div>

                        <div class="col-lg-6 form-group">
                            <label for="phone" class="text-small text-uppercase">{{__("Phone Number")}}</label>
                            <input type="text" class="form-control "
                                   name="phone" id="phone"
                                   placeholder="ex. 683xxxxxxxx"
                                   value="{{ old('phone', auth(activeGuard())->user()->phone) }}">
                            @error('phone')<span class="text-danger">{{ $message }}</span>@enderror
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6 form-group">
                            <label for="password" class="text-small text-uppercase">
                               {{__("Password")}}
                                <small class="ml-auto text-secondary">{{__('(optional)')}}</small>
                            </label>
                            <input type="password" class="form-control "
                                   name="password" id="email"
                                   value="{{ old('password') }}">
                            @error('password')<span class="text-danger">{{ $message }}</span>@enderror
                        </div>
                        <div class="col-lg-6 form-group">
                            <label for="password_confirmation" class="text-small text-uppercase">{{__('Re-Password')}}</label>
                            <input type="password" class="form-control "
                                   name="password_confirmation" id="password_confirmation"
                                   value="{{ old('password_confirmation') }}">
                            @error('password-confirm')<span class="text-danger"><strong>{{ $message }}</strong></span>@enderror
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6 form-group">
                            <div class="custom-control custom-switch cursor-pointer">
                                <input type="checkbox"
                                       name="receive_email" id="receive-email"
                                       {{auth(activeGuard())->user()->receive_email ? "checked" : ""}}
                                class="custom-control-input cursor-pointer">
                                <label class="custom-control-label fs-14s" for="receive-email">{{__('Receive Email')}}</label>
                                @error('receive_email')<span class="text-danger">{{ $message }}</span>@enderror

                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-12 form-group">
                            <label for="user_image" class="text-small text-uppercase">{{__("Image")}}</label>
                            <input type="file" id="user_image" name="user_image"><br>
                            @error('user_image')<span class="text-danger">{{ $message }}</span>@enderror
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-12">
                            <button class="button btn-block btn-default text-white" type="submit">
                                {{__('Update')}}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-4">
                @include('partials.frontend.user.sidebar')
            </div>
        </div>
    </section>
@endsection
