<!-- $pdo=Supplier::class -->
<div class="row">
	<div class="col-12">
		<h3>Supplier Details <x-leenooks::button.success class="float-right"/></h3>
		<hr>

		<form method="POST">
			@csrf

			<div class="row">
				<div class="col-4">
					<div class="row">
						<!-- Supplier Active -->
						<div class="col-12 col-sm-3">
							<x-leenooks::form.toggle name="active" label="Active" :value="$spo->active"/>
						</div>

						<!-- Supplier Name -->
						<div class="col-12 col-sm-9">
							<x-leenooks::form.text name="name" icon="fa-tag" label="Supplier Name" :value="$spo->name ?? ''"/>
						</div>
					</div>

					<div class="row">
						<!-- Address Lines -->
						<div class="col-12">
							<div class="form-group">
								<label for="address1">Address Lines</label>
								<input type="text" style="border-bottom-left-radius:0;border-bottom-right-radius:0;" class="form-control @error('address1') is-invalid @enderror" id="address1" name="address1" value="{{ old('address1',$spo->address1) }}">
								<input type="text" style="border-top-left-radius:0;border-top-right-radius:0;border-top:0;" class="form-control" id="address2" name="address2" value="{{ old('address2',$spo->address2) }}">
								<span class="invalid-feedback" role="alert">
									@error('address1')
										{{ $message }}
									@else
										Atleast 1 address line required.
									@enderror
								</span>
							</div>
						</div>
					</div>

					<div class="row">
						<!-- City -->
						<div class="col-12">
							<x-leenooks::form.text name="city" label="City" :value="$spo->city ?? ''"/>
						</div>
					</div>

					<div class="row">
						<!-- State -->
						<div class="col-12 col-sm-9">
							<x-leenooks::form.text name="state" label="State" :value="$spo->state ?? ''"/>
						</div>

						<!-- Postal Code -->
						<div class="col-12 col-sm-3">
							<x-leenooks::form.text name="postcode" label="Post Code" :value="$spo->postcode ?? ''"/>
						</div>
					</div>
				</div>

				<div class="offset-1 col-4">
					<div class="row">
						<!-- Accounts Email -->
						<div class="col-12">
							<x-leenooks::form.email name="supplier_details[accounts]" label="Accounts Email" old="supplier_details.accounts" :value="$spo?->detail->accounts ?? ''"/>
						</div>
					</div>

					<div class="row">
						<!-- Support Email -->
						<div class="col-12">
							<x-leenooks::form.email name="supplier_details[support]" label="Support Email" old="supplier_details.support" :value="$spo?->detail->support ?? ''"/>
						</div>
					</div>

					<div class="row">
						<!-- Payment Details -->
						<div class="col-12">
							<x-leenooks::form.email name="supplier_details[payments]" label="Payment Details" old="supplier_details.payments" :value="$spo?->detail->payments ?? ''"/>
						</div>
					</div>

					@if($spo->api_class())
						<hr>
						<p class="h6">
							<i class="fa-fw fas fa-sitemap"></i> <strong>{{ $spo->api_class() }}</strong>
						</p>

						<div class="row">
							<!-- API Details -->
							<div class="col-12">
								<x-leenooks::form.text name="api_key" label="API Key" :value="($spo->detail ? Arr::get($spo->detail->connections,'api_key') : '')"/>
							</div>
						</div>

						<div class="row">
							<!-- API Details -->
							<div class="col-12">
								<x-leenooks::form.text name="api_secret" label="API Secret" :value="($spo->detail ? Arr::get($spo->detail->connections,'api_secret') : '')"/>
							</div>
						</div>
					@endif
				</div>
			</div>

			<div class="row">
				<!-- Notes -->
				<div class="col-12">
					<x-leenooks::form.textarea name="supplier_details[notes]" label="Notes" :value="($spo->detail ? $spo->detail->notes : '')"/>
				</div>
			</div>

			<div class="row">
				<!-- Buttons -->
				<div class="col">
					<x-leenooks::button.cancel/>
					<x-leenooks::button.submit class="float-right">@if($spo?->exists)Update @else Add @endif</x-leenooks::button.submit>
				</div>
			</div>
		</form>
	</div>
</div>