<?= $this->extend('layouts/enterprise') ?>

<?= $this->section('styles') ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css">
<?= $this->endSection() ?>

<?= $this->section('content') ?>

<?= view('partials/workspace_hero', [
    'workspaceCrumbPill'    => 'Transport',
    'workspaceCrumbCurrent' => 'Add Location',
    'workspaceTitle'        => 'Add Location',
    'workspaceDesc'         => 'Register a depot, stop, hub, or customer site with map coordinates.',
]) ?>

<article class="enterprise-settings-card" style="max-width:860px;">
    <div class="enterprise-settings-card__head">
        <i class="fa-solid fa-map-location-dot"></i>
        <h2 class="enterprise-settings-card__title">Location Details</h2>
    </div>

    <?= $this->include('Modules\Transport\Views\partials\form_errors') ?>

    <form action="<?= base_url('transport/locations') ?>" method="post" novalidate>
        <?= csrf_field() ?>
        <?= $this->include('Modules\Transport\Views\locations\_form') ?>
        <div class="enterprise-settings-card__footer">
            <a href="<?= base_url('transport/locations') ?>" class="btn btn-outline-secondary">Cancel</a>
            <button type="submit" class="btn btn-primary">Create Location</button>
        </div>
    </form>
</article>

<?= $this->endSection() ?>

<?= $this->section('scripts') ?>
<?php if (($mapSettings['default_provider'] ?? 'openstreetmap') === 'google' && ! empty($mapSettings['google_api_key'])): ?>
    <script src="https://maps.googleapis.com/maps/api/js?key=<?= esc($mapSettings['google_api_key']) ?>"></script>
<?php else: ?>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
<?php endif; ?>
<script src="<?= base_url('assets/js/transport-map.js') ?>"></script>
<?= $this->endSection() ?>
