@extends('layouts.app')
@push('title')
    {{ $pageTitle }}
@endpush
@section('content')

    <div class="page-content-wrapper bda-pb-100 bda-pt-30 bda-px-18 ">
        <div class="bda-mb-30">
            <!-- breadcrumb  -->
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb bda-breadcrumb">
                    <li class="breadcrumb-item"><a href="{{route('user.dashboard')}}" class="title-light">{{$previousBreadcrumb}}</a></li>
                    <li class="breadcrumb-item active" aria-current="page">{{$breadcrumb}}</li>
                </ol>
            </nav>
        </div>
        <!-- data table area start -->
        <div class="bda-table-data overflow-x-auto">
            <div class="bda-card-area-box">
                <div class="bda-card-box">
                    <ul class="nav nav-pills gap-3 flex-wrap bda-mb-30" id="pills-tab" role="tablist">
                        <li class="nav-item" role="presentation">
                            <button class="nav-link social-tab-btu bda-tab-bot-button active" id="pills-social-tab-1"
                                    data-bs-toggle="pill"
                                    data-bs-target="#pills-social-1" type="button" role="tab"
                                    aria-controls="pills-social-1"
                                    aria-selected="true">{{ __('Basic Information') }}</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button class="nav-link social-tab-btu bda-tab-bot-button" id="pills-social-tab-2"
                                    data-bs-toggle="pill"
                                    data-bs-target="#pills-social-2" type="button" role="tab"
                                    aria-controls="pills-social-2"
                                    aria-selected="false">{{ __('Password Update') }}</button>
                        </li>
                    </ul>
                    <div class="tab-content" id="pills-tabContent">
                        <div class="tab-pane fade social-tab-content show active" id="pills-social-1" role="tabpanel"
                             aria-labelledby="pills-social-tab-1">
                            <div class="bd-social-data-table border-0">
                                <form class="ajax" action="{{ route('user.profile.update') }}" method="POST"
                                      enctype="multipart/form-data" data-callback="formResponse">
                                    @csrf
                                    <input type="hidden" name="updateId" value="{{ encrypt($user?->id) }}">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="bda-from-box">
                                                <p class="bda-text-label gap-2 align-items-center flex-wrap d-flex">{{__('Profile Picture')}}<i title="{{__('Recommended size is 156 x 156 px')}}" class="ri-information-line"></i> </p>
                                                <label for="picture">
                                                    <img class="avatar-preview"
                                                         src="{{getImageUrl($user?->picture ?? 'assets/images/uplod-logo.png')}}"
                                                         alt="{{__('Picture')}}">
                                                    <input type="file" name="picture"
                                                           class="d-none file-input @error('picture') is-invalid @enderror"
                                                           id="picture" accept="image/*"/>
                                                </label>

                                                @error('picture')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('Name')}}</label>
                                                <input type="text"
                                                       class="bda-from-control @error('name') is-invalid @enderror"
                                                       name="name" placeholder="{{__('Name')}}"
                                                       value="{{ $user?->name ?? old('name') }}">
                                                @error('name')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('Email')}}</label>
                                                <input type="email"
                                                       class="bda-from-control email-frontend-validation @error('email') is-invalid @enderror"
                                                       name="email" placeholder="{{__('Email')}}"
                                                       value="{{ $user?->email ?? old('email') }}">
                                                @error('email')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('Phone')}}</label>
                                                <input type="text"
                                                       class="bda-from-control phone-frontend-validation @error('phone') is-invalid @enderror"
                                                       name="phone" placeholder="{{ __('Phone') }}"
                                                       value="{{ $user?->phone ?? old('phone') }}">
                                                @error('phone')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('Date of Birth')}}</label>
                                                <input type="text"
                                                       class="bda-from-control dob @error('dob') is-invalid @enderror"
                                                       name="dob" placeholder="{{__('Date of Birth')}}"
                                                       value="{{ $user?->dob ?? old('dob') }}" id="dob">
                                                @error('dob')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('City')}}</label>
                                                <input type="text"
                                                       class="bda-from-control @error('city') is-invalid @enderror"
                                                       name="city" placeholder="{{__('City')}}"
                                                       value="{{ $user?->city ?? old('city') }}">
                                                @error('city')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-form-box">
                                                <label class="bda-text-label">{{__('State')}}</label>
                                                <input type="text"
                                                       class="bda-from-control @error('state') is-invalid @enderror"
                                                       name="state" placeholder="{{__('State')}}"
                                                       value="{{ $user?->state ?? old('state') }}">
                                                @error('state')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('Address')}}</label>
                                                <input type="text"
                                                       class="bda-from-control @error('address') is-invalid @enderror"
                                                       name="address" placeholder="{{__('Address')}}"
                                                       value="{{ $user?->address ?? old('address') }}">
                                                @error('address')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <div class="bda-tickets-list">
                                                    <label class="bda-text-label">{{__('Gender')}}</label>
                                                    <div
                                                        class="bda-mb-30 d-flex bda-gab-30 align-items-center flex-wrap">
                                                        <label>
                                                            <input type="radio" class="bda-tickets" id="male"
                                                                   name="gender"
                                                                   value="{{ MALE }}" {{ old('gender', $user?->gender) == MALE ? 'checked' :'' }}>
                                                            <span>{{__("Male")}}</span>
                                                        </label>
                                                        <label>
                                                            <input type="radio" class="bda-tickets" id="male"
                                                                   name="gender"
                                                                   value="{{ FEMALE }}" {{ old('gender', $user?->gender) == FEMALE ? 'checked' :'' }}>
                                                            <span>{{__("Female")}}</span>
                                                        </label>
                                                        <label>
                                                            <input type="radio" class="bda-tickets" id="others"
                                                                   name="gender"
                                                                   value="{{ OTHERS }}" {{ old('gender', $user?->gender) == OTHERS ? 'checked' :'' }}>
                                                            <span>{{__("Others")}}</span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div>
                                        <button class="bda-btu-theme" type="submit">{{__("Update")}}</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="tab-pane social-tab-content  fade" id="pills-social-2" role="tabpanel"
                             aria-labelledby="pills-social-tab-2">
                            <div class="bd-social-data-table border-0">
                                <form class="ajax" action="{{ route('user.profile.password.update') }}"
                                      method="POST" enctype="multipart/form-data"
                                      data-callback="passwordUpdateResponse">
                                    @csrf
                                    <input type="hidden" name="updateId" value="{{ encrypt($user?->id) }}">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('Current Password')}}</label>
                                                <input type="password"
                                                       class="bda-from-control @error('password') is-invalid @enderror"
                                                       name="current_password" placeholder="{{__('Current Password')}}"
                                                       value="{{ old('password') }}">
                                                @error('password')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="bda-from-box">
                                                <label class="bda-text-label">{{__('New Password')}}</label>
                                                <input type="password"
                                                       class="bda-from-control @error('password') is-invalid @enderror"
                                                       name="new_password" placeholder="{{__('New Password')}}"
                                                       value="{{ old('state') }}">
                                                @error('password')
                                                <span class="invalid-feedback mb-3 mt-0 pt-0" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                                @enderror
                                            </div>
                                        </div>
                                        <div>
                                            <button class="bda-btu-theme" type="submit">{{__("Update")}}</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- data table area end -->
    </div>

@endsection
@push('script')
    <script src="{{asset('assets/js/custom/user/profile.js')}}"></script>
@endpush
