@extends('admin.layouts.app')

@section('content')
<div class="container-fluid px-4">
    <x-admin.page-header
        :title="__('admin/email-marketing.edit_title')"
        icon="fas fa-envelope-open-text"
        :buttons="[
            ['label' => __('admin/common.back'), 'route' => route('admin.email-marketing.index'), 'icon' => 'fas fa-arrow-left', 'color' => 'outline-secondary'],
        ]"
    />

    <x-admin.alert />

    <form method="POST" action="{{ route('admin.email-marketing.update', $emailMarketing) }}">
        @csrf
        @method('PUT')
        <x-admin.card>
            <div class="row g-3">
                <div class="col-md-6">
                    <label class="form-label">{{ __('admin/email-marketing.fields_name') }}</label>
                    <input type="text" class="form-control" name="name" value="{{ old('name', $emailMarketing->name) }}" required>
                </div>
                <div class="col-md-6">
                    <label class="form-label">{{ __('admin/email-marketing.fields_provider') }}</label>
                    <select class="form-select" name="provider">
                        <option value="">{{ __('admin/common.select') }}</option>
                        <option value="mailchimp" @if($emailMarketing->provider==='mailchimp') selected @endif>Mailchimp</option>
                        <option value="mailerlite" @if($emailMarketing->provider==='mailerlite') selected @endif>MailerLite</option>
                        <option value="local" @if($emailMarketing->provider==='local') selected @endif>Local</option>
                    </select>
                </div>
                <div class="col-md-12">
                    <label class="form-label">{{ __('admin/email-marketing.fields_description') }}</label>
                    <textarea class="form-control" name="description" rows="3">{{ old('description', $emailMarketing->description) }}</textarea>
                </div>
            </div>
        </x-admin.card>

        <x-admin.card :title="__('admin/email-marketing.defaults_title')" icon="fas fa-cog" class="mt-3">
            <div class="row g-3">
                <div class="col-md-4">
                    <label class="form-label">{{ __('admin/email-marketing.fields_default_from_name') }}</label>
                    <input type="text" class="form-control" name="default_from_name" value="{{ old('default_from_name', $emailMarketing->default_from_name) }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">{{ __('admin/email-marketing.fields_default_from_email') }}</label>
                    <input type="email" class="form-control" name="default_from_email" value="{{ old('default_from_email', $emailMarketing->default_from_email) }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">{{ __('admin/email-marketing.fields_default_reply_to') }}</label>
                    <input type="email" class="form-control" name="default_reply_to" value="{{ old('default_reply_to', $emailMarketing->default_reply_to) }}">
                </div>
            </div>

            <x-slot:footer>
                <x-admin.form-actions
                    :submit-text="__('admin/common.update')"
                    :cancel-url="route('admin.email-marketing.index')"
                />
            </x-slot:footer>
        </x-admin.card>
    </form>
</div>
@endsection
