@extends('admin.layouts.container')

@section('content')
<div class="side-title">
    <h3>{{$head ?? '' }}</h3>
</div>

<div class="border-item">
    <form class="form-row add_address_form" method="post" action="{{ $action }}" enctype="multipart/form-data">
        @if($address ?? ''  && $address->id)
            @method('PUT')
        @endif
        @csrf

        <div class="form-group col-lg-6">
            <label>{{ meta('email', $lang) ?? __('addresses.email') }} </label>
            <input type="email" class="form-control" name="email" placeholder="{{ meta('email', $lang) ?? __('addresses.email') }}" value='{{ $address->email ?? "" }}'/>
        </div>

        <div class="form-group col-lg-6">
            <label>{{ meta('phone', $lang) ?? __('addresses.phone') }} </label>
            <input type="tel" class="form-control" name="phone" placeholder="{{ meta('phone', $lang) ?? __('addresses.phone') }}" value='{{ $address->phone ?? "" }}'/>
        </div>

        <div class="form-group col-lg-12">
            <label>{{ meta('map_url', $lang) ?? __('addresses.map_url') }} </label>
            <input type="text" class="form-control" name="map_url" placeholder="{{ meta('map_url', $lang) ?? __('addresses.map_url') }}" value='{{ $address->map_url ?? "" }}'/>
        </div>

        @foreach(languages() as $language)
        <div class="form-group col-lg-6">
            <label>{{ meta('name', $language->local) ?? __('addresses.name') }} {{ count($languages) > 1 ? "({$language->name})" : '' }} </label>
            <input type="text" class="form-control {{ $errors->has('name_'.$language->local) ? 'is-invalid' : '' }}" name="name_{{ $language->local }}" placeholder="{{ meta('name', $language->local) ?? __('addresses.name') }}" value='{{ old("name_{$language->local}", $address[$language->local]->name ?? "") }}'/>
        </div>
        @endforeach

        <div class="text-center mt-5 col-12">
            <button class="butn add_address_button"><span>{{ __('dashboard.save') }}</span></button>
        </div>
    </form>
</div>

@endsection

@section('inner_js')

    <script>
        sendAjax('.add_address_button', '.add_address_form')
    </script>

@endsection



