@if (count($order->comments) > 0)
    @php
        $commentTypes = [
            'cancelled' => ['bg-danger', 'feather icon-archive', 'Отменен'],
            'replacement' => ['bg-warning', 'feather icon-refresh-ccw', 'Замена'],
            'closed' => ['bg-success', 'feather icon-archive', 'Закрыто'],
            'default' => ['bg-primary', 'fa fa-comment', 'comment'],
        ];
    @endphp

    <button type="button" class="btn btn-success mb-1" data-toggle="collapse" href="#collapseExample" role="button"
        aria-expanded="false" aria-controls="collapseExample">
        <i class="fa fa-plus-circle"></i> @lang('admin.orders.add_a_comment')
    </button>

    <div class="collapse" id="collapseExample">
        <div class="card ">
            <div class="card-content">
                <form action="{{ route('dashboard.orders.comments_status') }}" method="post">
                    <div class="card-body">
                        <div class="row">
                            @csrf
                            <input type="hidden" name="order_id" value="{{ $order->id }}">
                            <input type="hidden" name="type" value="default">
                            <label>@lang('admin.orders.comment')</label>
                            <textarea name="comment" id="" class="form-control" cols="3" rows="3"></textarea>

                            <button class="btn btn-primary mt-2">
                                <i class="fa fa-save"></i> @lang('admin.save')
                            </button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>

    <h2>@lang('admin.orders.comments')</h2>
    <ul class="activity-timeline timeline-left list-unstyled mt-2">
        @foreach ($order->comments as $comment)
            @php
                $type = $commentTypes[$comment->type] ?? $commentTypes['default'];
            @endphp
            <li>
                <div class="timeline-icon {{ $type[0] }}">
                    <i class="{{ $type[1] }} font-medium-2 align-middle"></i>
                </div>
                <div class="timeline-info">
                    <p class="font-weight-bold mb-0">@lang('admin.orders.' . $type[2])</p>
                    <span class="font-small-3">{{ $comment->comment }}</span>
                </div>
                <small class="text-muted">
                    {{ date('H:i, d.m.Y', strtotime($comment->created_at)) }} |
                    @lang('admin.orders.user') <b>{{ $comment->user->username }}</b>
                </small>
            </li>
        @endforeach
    </ul>
@endif
