<!-- ($o??$user)=User::class -->

@use(App\Models\Country)

@extends('adminlte::layouts.app')

@section('htmlheader_title')
	{{ ($o??$user)->role }} Settings
@endsection
@section('page_title')
	{{ ($o??$user)->name_full }}
@endsection

@section('contentheader_title')
	{{ ($o??$user)->name_full }}
@endsection
@section('contentheader_description')
	{{ ($o??$user)->role }}
@endsection

@section('main-content')
	<div class="row">
		<div class="col">
			<div class="card">
				<div class="card-header">
					<div class="card-title">Update Settings</div>
					<x-leenooks::button.success class="float-right"/>
				</div>

				<form method="POST" action="{{ url(request()->path(),[($o??$user)->id]) }}">
					@csrf

					<div class="card-body">
						<div class="row">
							<div class="col-12 col-sm-6">
								<div class="row">
									<div class="col">
										<x-leenooks::form.email id="email" name="email" icon="fa-at" label="Email" :value="($o??$user)->email ?? ''"/>
									</div>
								</div>

								<div class="row">
									<div class="col">
										<x-leenooks::form.password id="password" name="password" icon="fa-lock" label="Password"/>
									</div>
								</div>

								<div class="row">
									<div class="col">
										<x-leenooks::form.password id="password_confirm" name="password_confirmation" icon="fa-lock" label="Password Confirm" helper="Verify Password"/>
									</div>
								</div>

								<div class="row">
									<div class="col pb-3">
										<button type="reset" id="passkey" name="passkey" @class(['btn','btn-success'=>$x=($o??$user)->passkey,'btn-outline-secondary'=>! $x])><i class="fas fa-fw fa-key"></i> Passkey</button>
									</div>
								</div>
							</div>

							<div class="col-12 col-sm-6">
								<div class="row">
									<div class="col-12 col-md-6">
										<x-leenooks::form.text name="firstname" icon="fa-headset" label="First Name" :value="($o??$user)->firstname ?? ''"/>
									</div>

									<div class="col-12 col-md-6">
										<x-leenooks::form.text name="lastname" icon="fa-signature" label="Last Name" :value="($o??$user)->lastname ?? ''"/>
									</div>
								</div>

								<div class="row">
									<div class="col">
										<x-leenooks::form.text name="address1" icon="fa-map" label="Address" :value="($o??$user)->address1 ?? ''"/>
									</div>
								</div>

								<div class="row">
									<div class="col">
										<x-leenooks::form.text name="address2" :value="($o??$user)->address2 ?? ''"/>
									</div>
								</div>

								<div class="row">
									<div class="col-12 col-md-4">
										<x-leenooks::form.text name="city" label="City" :value="($o??$user)->city ?? ''"/>
									</div>
									<div class="col-12 col-md-4">
										<x-leenooks::form.text name="state" label="State" :value="($o??$user)->state ?? ''"/>
									</div>
									<div class="col-12 col-md-4">
										<x-leenooks::form.text name="postcode" label="Post Code" :value="($o??$user)->postcode ?? ''"/>
									</div>
								</div>

								<div class="row">
									<div class="col-12 col-md-6">
										<x-leenooks::form.select id="country" name="country_id" icon="fa-globe" label="Country" :value="($o??$user)->country_id ?? ''" :options="Country::select(['id','name'])->active()->get()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])"/>
									</div>
								</div>
							</div>
						</div>

						<div class="row pt-3">
							<div class="col">
								<x-leenooks::button.cancel/>
								<x-leenooks::button.submit class="float-right">Save</x-leenooks::button.submit>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
@endsection

@section('page-scripts')
	<!-- Passkeys -->
	<script type='text/javascript' src='{{ asset('/passkey/passkey.js') }}'></script>

	<script type="text/javascript">
		$(document).ready(function() {
			$('#passkey').on('click',function(item) {
				return passkey_create($(this),'{{ csrf_token() }}','fa-key','{{ ($o??$user)->passkey ? 'btn-success' : 'btn-outline-secondary' }}','btn-success','{{ ($o??$user)->passkey ? 'btn-secondary' : 'btn-outline-secondary' }}');
			});
		});
	</script>
@append