176 lines
6.6 KiB
PHP
176 lines
6.6 KiB
PHP
<div class="row">
|
|
<div class="col">
|
|
<fieldset class="mb-3 border p-3">
|
|
<legend>{{ __('General Information') }}</legend>
|
|
<div class="row mb-3">
|
|
|
|
<div class="col-12 col-md-8 form-group">
|
|
<label class="col-form-label" for="shop-name">
|
|
<b>{{ Str::ucfirst(__('Pickup point name')) }}*</b>
|
|
</label>
|
|
<input class="form-control" id="shop-name" name="name" type="text" value="{{ old('name', $shop->name ?? '') }}" required>
|
|
@include('bo.modules.input-error', ['inputName' => 'name'])
|
|
</div>
|
|
|
|
<div class="col-12 col-md-4 form-group pt-4">
|
|
<input class="form-check-input mt-2" id="shop-default" name="default" type="checkbox" value="1" @checked(old('default', $shop->default ?? '0'))>
|
|
<label class="col-form-label form-check-label pt-1" for="shop-default">
|
|
<b>{{ Str::ucfirst(__('Default pickup point')) }}</b>
|
|
</label><br>
|
|
@include('bo.modules.input-error', ['inputName' => 'default'])
|
|
</div>
|
|
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<fieldset class="mb-3 border p-3">
|
|
<legend>{{ __('Contact Information') }}</legend>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-12 form-group position-relative">
|
|
<label class="col-form-label" for="shop-address">
|
|
<b>{{ Str::ucfirst(__('Address')) }}*</b>
|
|
</label>
|
|
<input class="form-control" id="shop-address" name="address" type="text" value="{{ old('address', $shop->address ?? '') }}"
|
|
required autocomplete="off" placeholder="{{ __('Start typing an address..') }}">
|
|
|
|
<ul class="list-group position-absolute w-100 shadow-sm autocomplete-dropdown" id="address-suggestions">
|
|
</ul>
|
|
|
|
@include('bo.modules.input-error', ['inputName' => 'address'])
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-md-4 form-group">
|
|
<label class="col-form-label" for="shop-postcode">
|
|
<b>{{ Str::ucfirst(__('Zip code')) }}*</b>
|
|
</label>
|
|
<input class="form-control" id="shop-postcode" name="postcode" type="text" value="{{ old('postcode', $shop->postcode ?? '') }}"
|
|
autocomplete="off" required>
|
|
@include('bo.modules.input-error', ['inputName' => 'postcode'])
|
|
</div>
|
|
|
|
<div class="col-12 col-md-4 form-group">
|
|
<label class="col-form-label" for="shop-city">
|
|
<b>{{ Str::ucfirst(__('City')) }}*</b>
|
|
</label>
|
|
<input class="form-control" id="shop-city" name="city" type="text" value="{{ old('city', $shop->city ?? '') }}"
|
|
autocomplete="off" required>
|
|
@include('bo.modules.input-error', ['inputName' => 'city'])
|
|
</div>
|
|
|
|
<div class="col-12 col-md-4 form-group">
|
|
<label class="col-form-label" for="shop-phone">
|
|
<b>{{ Str::ucfirst(__('Phone')) }}</b>
|
|
</label>
|
|
<input class="form-control" id="shop-phone" name="phone" type="text" value="{{ old('phone', $shop->phone ?? '') }}"
|
|
autocomplete="off">
|
|
@include('bo.modules.input-error', ['inputName' => 'phone'])
|
|
</div>
|
|
</div>
|
|
|
|
</fieldset>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<fieldset class="mb-3 border p-3">
|
|
<legend>{{ __('GPS & Maps Coordinates') }}</legend>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-12 form-group">
|
|
<label class="col-form-label" for="map-location-picker"><b>{{ Str::ucfirst(__('Location on the map')) }}</b></label>
|
|
@php
|
|
$mapData = [
|
|
'latName' => 'latitude',
|
|
'lngName' => 'longitude',
|
|
'lat' => old('latitude', $shop->latitude ?? null),
|
|
'lng' => old('longitude', $shop->longitude ?? null),
|
|
];
|
|
@endphp
|
|
<div id="map-location-picker" data-json='@json($mapData)'></div>
|
|
@include('bo.modules.input-error', ['inputName' => 'latitude'])
|
|
@include('bo.modules.input-error', ['inputName' => 'longitude'])
|
|
</div>
|
|
</div>
|
|
|
|
</fieldset>
|
|
</div>
|
|
</div>
|
|
|
|
@push('scripts')
|
|
<script nonce="{{ Vite::cspNonce() }}">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const addressInput = document.getElementById('shop-address');
|
|
const postcodeInput = document.getElementById('shop-postcode');
|
|
const cityInput = document.getElementById('shop-city');
|
|
const suggestionsList = document.getElementById('address-suggestions');
|
|
|
|
let debounceTimer;
|
|
|
|
addressInput.addEventListener('input', function() {
|
|
clearTimeout(debounceTimer);
|
|
const query = this.value;
|
|
|
|
if (query.length < 3) {
|
|
suggestionsList.style.display = 'none';
|
|
return;
|
|
}
|
|
|
|
debounceTimer = setTimeout(() => {
|
|
fetch(`https://api-adresse.data.gouv.fr/search/?q=${encodeURIComponent(query)}&limit=5&autocomplete=1`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
suggestionsList.innerHTML = '';
|
|
|
|
if (data.features && data.features.length > 0) {
|
|
data.features.forEach(feature => {
|
|
const li = document.createElement('li');
|
|
li.className = 'list-group-item list-group-item-action';
|
|
li.style.cursor = 'pointer';
|
|
li.textContent = feature.properties.label;
|
|
|
|
li.addEventListener('click', function() {
|
|
addressInput.value = feature.properties.name;
|
|
postcodeInput.value = feature.properties.postcode;
|
|
cityInput.value = feature.properties.city;
|
|
suggestionsList.style.display = 'none';
|
|
|
|
const lng = feature.geometry.coordinates[0];
|
|
const lat = feature.geometry.coordinates[1];
|
|
|
|
const event = new CustomEvent('ban-address-selected', {
|
|
detail: {
|
|
lat: lat,
|
|
lng: lng
|
|
}
|
|
});
|
|
document.dispatchEvent(event);
|
|
});
|
|
|
|
suggestionsList.appendChild(li);
|
|
});
|
|
|
|
suggestionsList.style.display = 'block';
|
|
} else {
|
|
suggestionsList.style.display = 'none';
|
|
}
|
|
})
|
|
.catch(error => console.error('BAN error:', error));
|
|
}, 300);
|
|
});
|
|
|
|
document.addEventListener('click', function(e) {
|
|
if (e.target !== addressInput && !suggestionsList.contains(e.target)) {
|
|
suggestionsList.style.display = 'none';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
@endpush
|