@extends("layouts.dashboard")

@section("title", "Comments - Dashboard | TechnoBlog")

@section("dashboard_content")

	<div class="my-3 my-md-5">

		<div class="container">

			<div class="page-header">
				<h1 class="page-title">Comments</h1>
			</div>

			<div class="row">

				<div class="col-sm-12">
					<div class="card">

						<div class="card-header">
							<h3 class="card-title">List of comments</h3>
						</div>

						<div class="table-responsive pt-5 pb-5">

							<table id="dttable" class="table" style="width:100%">
								<thead>
									<tr>
										<th class="text-center">Name</th>
										<th class="text-center">Email</th>
										<th class="text-center">Created Date</th>
										<th class="text-center">Status</th>
										<th class="text-center">Actions</th>
									</tr>
								</thead>
								<tbody>
									@foreach ($comments as $comment)
										<tr>
											<td>{{ $comment->name }}</td>
											<td>{{ $comment->email }}</td>
											<td>{{ date('d.m.Y', strtotime($comment->created_at)) }}</td>
											<td>
												@if ($comment->is_active)
													Confirmed
												@else
													Not confirmed yet
												@endif
											</td>
											<td class="text-center">
												<div class="item-action dropdown">
													<a href="javascript:void(0)" data-toggle="dropdown" class="icon" aria-expanded="false"><i class="fe fe-more-vertical"></i></a>
													<div class="dropdown-menu dropdown-menu-right" x-placement="bottom-end" style="position: absolute; transform: translate3d(15px, 20px, 0px); top: 0px; left: 0px; will-change: transform;">
                                                        <a href="{{ route("blog.post", ["category" => strtolower($comment->post->category->name), "slug" => $comment->post->slug]) }}" target="_blank" class="dropdown-item"><i class="dropdown-icon fe fe-file-text"></i> View Post </a>

														@if (!$comment->is_active)
                                                            <a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.comments.confirm", ["id" => $comment->id]) }}" data-method="patch"><i class="dropdown-icon fe fe-check"></i> Confirm </a>
                                                        @endif

                                                        <div class="dropdown-divider"></div>
                                                        <a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.comments.destroy", ["id" => $comment->id]) }}" data-method="delete"><i class="dropdown-icon fe fe-trash-2 text-danger"></i> Delete </a>
                                                    </div>
												</div>
											</td>
										</tr>
									@endforeach
								</tbody>
							</table>

						</div>

					</div>

				</div>

			</div>

		</div>

	</div>

@endsection
