{{ Form::open(['route' => 'Admin.Core.Mail.MailTemplate.storeAjax', 'id' => 'mail_template-form', 'autocomplete' => 'off', 'files' => true]) }}

	<input type="hidden" id="id" name="id" value="{{ $mail_template['id'] ?? null }}">

    <div class="row mb-3">
        <div class="col-3">
            @include('components.form.input', [
                    'name' => 'name',
                    'value' => $mail_template['name'] ?? '',
                    'label' => __('Core.name'),
                    'required' => true,
                ])
        </div>
        <div class="col-3">
            @include('components.form.select', [
                'name' => 'mailable',
                'value' => $mail_template['mailable'] ?? '',
                'list' => $mailables ?? [],
                'label' => __('Core.mailables'),
                'with_empty' => '',
                'required' => true,
            ])
        </div>
        <div class="col-6">
            <div id="mail_template-vars">
                @include('Admin.Core.Mail.MailTemplate.partials.vars', ['vars' => $mail_template['vars'] ?? []])
            </div>
        </div>
    </div>

    <div id="mode_fr" class="">
        <div class="row mb-3">
            <div class="col-6">
                @include('components.form.input', [
                    'name' => 'subject[fr]',
                    'value' => $mail_template['subject_translations']['fr'] ?? '',
                    'label' => __('Core.subject'),
                    'required' => true,
                ])
            </div>
        </div>

        <div class="row mb-3">
            <div class="col-12">
                @include('components.form.editor', [
                    'name' => 'html_template[fr]',
                    'value' => $mail_template['html_template_translations']['fr'] ?? '',
                    'label' => 'HTML',
                    'rows' => 10,
                ])
            </div>
        </div>

        <div class="row mb-3">
            <div class="col-12">
                @include('components.form.textarea', [
                    'name' => 'text_template[fr]',
                    'value' => $mail_template['text_template_translations']['fr'] ?? '',
                    'label' => 'Text',
                ])
            </div>
        </div>
    </div>

{{ Form::close() }}


<script>

	$(function() {
		initSelect2();
        initEditor();

        $('.lang').click(function() {
            var lang = $(this).data('lang');
            $('#mode_en').toggleClass('d-none');
            $('#mode_fr').toggleClass('d-none');
            $('#lang_en').toggleClass('d-none');
            $('#lang_fr').toggleClass('d-none');
        });
	});
</script>
