@extends('admin.layouts.container')

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

<div class="border-item">
    <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}">
        @if($newsletter ?? ''  && $newsletter->id ?? '')
            @method('PUT')
        @endif
        @CSRF

        @if ($newsletter ?? '')

        <div class="form-group col-lg-6">
            <label>{{ meta('visitor_email', getCurrentLocale()) ?? __('newsletters.email') }} </label>
            <p class="form-control" style="height: auto">{{$newsletter->email}}</p>
        </div>
        <div class="form-group col-lg-6"></div>
        @endif
        {{-- Start replies container--}}
        @if ($replies ?? false)

            @foreach ($replies as $reply)
                    <div class="col-sm-1">
                        <div class="thumbnail">
                            <img class="img-responsive rounded img-thumbnail user_photo" src="{{asset('assets/admin/images/reply_avatar.png')}}">
                        </div>
                    </div>
                    <div class="card col-sm-11 reply_card mb-2">
                        <div class="card-header d-flex justify-content-between">
                            <strong>{{$reply->user->name}}</strong> <span class="bg-dark text-white rounded px-1"><i class="fa fa-user-clock"></i> {{$reply->created_at}}</span>
                        </div>
                        <div class="card-body">
                            {!! $reply->reply !!}
                        </div>
                    </div>
            @endforeach

        @endif
        {{-- End replies container--}}

            <div class="card col-md-12 mt-3">
                <div class="card-header">
                    <div class="card-title">
                        <h4>{{meta('reply', getCurrentLocale()) ?? 'Replying on message'}}</h4>
                    </div>
                </div>

                <div class="card-body">
                    <div class="form-group col-lg-12">
                        <label>{{ meta('send_to', getCurrentLocale()) ?? __('newsletters.send_to') }} </label>
                        <input type="text" name="visitor_email" class="form-control {{ $errors->has('visitor_email') ? 'is-invalid' : '' }}" placeholder="{{ __('newsletters.email') }}" value="{{ old("email", $newsletter->email ?? "") }}">
                    </div>
                    <div class="form-group col-lg-12">
                        <label>{{ meta('message', getCurrentLocale()) ??  __('newsletters.message') }} </label>
                        <textarea name="reply" class="form-control my-editor" placeholder="{{ __('newsletters.message') }}">{{ old("message") }}</textarea>
                    </div>
                </div>
            </div>

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

    </form>
</div>

@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>-
    <script>
        var route_prefix = "{{ url(config('lfm.prefix')) }}";
        var url = "{{url('/')}}/";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>

@endsection
