@extends('app.my-account.admin.users.single')

@section('details')
    <div class="my-4">
        <div class="d-flex align-items-center justify-content-between">
            <h4 class="m-0"><b>Emails Sent</b></h4>  
            <div>
                @include('app.my-account.admin.users.forms.create-email')
            </div>
        </div>
        
        <div class="table-responsive">
            <table class="table table-sm table-hover table-striped table-bordered mb-0">
                <thead>
                    <tr>
                        <th>Sent At</th>
                        <th>To</th>
                        <th>Subject</th>
                        <th>Text</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($emailsSent as $email)
                        <tr>
                            <td>{{ friendly_date($email->created_at) }}</td>
                            <td><?= $email->to ?></td>
                            <td><?= $email->subject ?></td>
                            <td><?= nl2br($email->content) ?></td>
                        </tr>
                    @endforeach
                    @if(!count($emailsSent))
                        <tr>
                            <td colspan="4">No emails sent!</td>
                        </tr>
                    @endif
                </tbody>
            </table>
        </div>
    </div>
@endsection
