Files

293 lines
19 KiB
PHP

@extends('layouts.app')
@section('content')
<div class="bg-gray-50 dark:bg-gray-900 min-h-screen">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Header -->
<div class="mb-8">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900 dark:text-white">Comment Moderation</h1>
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Review and moderate user comments</p>
</div>
</div>
</div>
<!-- Success/Error Messages -->
@if(session('success'))
<div class="mb-6 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 text-green-800 dark:text-green-200 px-4 py-3 rounded-lg">
{{ session('success') }}
</div>
@endif
@if(session('error'))
<div class="mb-6 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-800 dark:text-red-200 px-4 py-3 rounded-lg">
{{ session('error') }}
</div>
@endif
<!-- Tabs and Search -->
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 mb-6">
<!-- Status Tabs -->
<div class="border-b border-gray-200 dark:border-gray-700">
<nav class="flex -mb-px">
<a href="{{ route('moderation.comments.index', ['status' => 'pending']) }}"
class="px-6 py-3 text-sm font-medium border-b-2 {{ request('status', 'pending') === 'pending' ? 'border-primary-500 text-primary-600 dark:text-primary-400' : 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300' }}">
Pending
@if($pendingCount > 0)
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200">
{{ $pendingCount }}
</span>
@endif
</a>
<a href="{{ route('moderation.comments.index', ['status' => 'approved']) }}"
class="px-6 py-3 text-sm font-medium border-b-2 {{ request('status') === 'approved' ? 'border-primary-500 text-primary-600 dark:text-primary-400' : 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300' }}">
Approved ({{ $approvedCount }})
</a>
<a href="{{ route('moderation.comments.index', ['status' => 'rejected']) }}"
class="px-6 py-3 text-sm font-medium border-b-2 {{ request('status') === 'rejected' ? 'border-primary-500 text-primary-600 dark:text-primary-400' : 'border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300' }}">
Rejected ({{ $rejectedCount }})
</a>
</nav>
</div>
<!-- Search -->
<div class="p-4">
<form method="GET" action="{{ route('moderation.comments.index') }}" class="flex gap-4">
<input type="hidden" name="status" value="{{ request('status', 'pending') }}">
<div class="flex-1">
<input
type="text"
name="search"
value="{{ request('search') }}"
placeholder="Search comments, users, or products..."
class="w-full rounded-md border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm focus:border-primary-500 focus:ring-primary-500"
>
</div>
<div class="flex gap-2">
<button
type="submit"
class="px-4 py-2 bg-primary-600 hover:bg-primary-700 text-white rounded-md font-medium transition-colors"
>
Search
</button>
@if(request('search'))
<a
href="{{ route('moderation.comments.index', ['status' => request('status', 'pending')]) }}"
class="px-4 py-2 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-md font-medium transition-colors"
>
Clear
</a>
@endif
</div>
</form>
</div>
</div>
<!-- Comments List -->
<div class="space-y-4">
@forelse($comments as $comment)
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
<div class="p-6">
<!-- Comment Header -->
<div class="flex items-start justify-between mb-4">
<div class="flex items-start space-x-4">
<div class="h-10 w-10 rounded-full bg-gradient-to-br from-primary-500 to-accent-500 flex items-center justify-center text-white font-semibold">
{{ strtoupper(substr($comment->user->name, 0, 1)) }}
</div>
<div>
<div class="flex items-center gap-2">
<a href="{{ route('profile.show', $comment->user) }}" class="text-sm font-medium text-gray-900 dark:text-white hover:text-primary-600 dark:hover:text-primary-400">
{{ $comment->user->name }}
</a>
<span class="text-xs text-gray-500 dark:text-gray-400">•</span>
<span class="text-xs text-gray-500 dark:text-gray-400">
{{ $comment->created_at->diffForHumans() }}
</span>
</div>
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
On product: <a href="{{ route('products.show', $comment->product) }}" class="text-primary-600 dark:text-primary-400 hover:underline">{{ $comment->product->name }}</a>
</div>
</div>
</div>
<!-- Status Badge -->
<div>
@if($comment->isPending())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200">
Pending Review
</span>
@elseif($comment->isApproved())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200">
Approved
</span>
@else
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200">
Rejected
</span>
@endif
</div>
</div>
<!-- Comment Body -->
<div class="mb-4">
<p class="text-gray-700 dark:text-gray-300 whitespace-pre-wrap">{{ $comment->body }}</p>
</div>
<!-- Moderation Info -->
@if($comment->moderated_at)
<div class="mb-4 bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-md p-3">
<div class="text-xs text-gray-600 dark:text-gray-400">
<strong>Moderated by:</strong> {{ $comment->moderator->name ?? 'Unknown' }}
<span class="mx-2">•</span>
<strong>Date:</strong> {{ $comment->moderated_at->format('M d, Y h:i A') }}
</div>
@if($comment->moderation_note)
<div class="text-xs text-gray-600 dark:text-gray-400 mt-1">
<strong>Note:</strong> {{ $comment->moderation_note }}
</div>
@endif
</div>
@endif
<!-- Actions -->
<div class="flex items-center gap-2 pt-4 border-t border-gray-200 dark:border-gray-700">
@if($comment->isPending())
<!-- Approve -->
<form action="{{ route('moderation.comments.approve', $comment) }}" method="POST" class="inline">
@csrf
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
Approve
</button>
</form>
<!-- Reject -->
<form action="{{ route('moderation.comments.reject', $comment) }}" method="POST" class="inline">
@csrf
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
Reject
</button>
</form>
@elseif($comment->isApproved())
<!-- Set to Pending -->
<form action="{{ route('moderation.comments.setPending', $comment) }}" method="POST" class="inline">
@csrf
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 bg-yellow-600 hover:bg-yellow-700 text-white text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Set to Pending
</button>
</form>
<!-- Reject -->
<form action="{{ route('moderation.comments.reject', $comment) }}" method="POST" class="inline">
@csrf
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 bg-red-600 hover:bg-red-700 text-white text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
Reject
</button>
</form>
@else
<!-- Set to Pending -->
<form action="{{ route('moderation.comments.setPending', $comment) }}" method="POST" class="inline">
@csrf
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 bg-yellow-600 hover:bg-yellow-700 text-white text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Set to Pending
</button>
</form>
<!-- Approve -->
<form action="{{ route('moderation.comments.approve', $comment) }}" method="POST" class="inline">
@csrf
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
Approve
</button>
</form>
@endif
<!-- Edit -->
<a
href="{{ route('moderation.comments.edit', $comment) }}"
class="inline-flex items-center px-3 py-1.5 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 text-sm rounded-md font-medium transition-colors"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
</svg>
Edit
</a>
<!-- Delete -->
<form
action="{{ route('moderation.comments.destroy', $comment) }}"
method="POST"
onsubmit="return confirm('Are you sure you want to delete this comment?');"
class="inline"
>
@csrf
@method('DELETE')
<button
type="submit"
class="inline-flex items-center px-3 py-1.5 text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300 text-sm font-medium"
>
<svg class="h-4 w-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
</svg>
Delete
</button>
</form>
</div>
</div>
</div>
@empty
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-12 text-center">
<svg class="h-12 w-12 text-gray-400 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path>
</svg>
<p class="text-sm text-gray-500 dark:text-gray-400">No comments found</p>
</div>
@endforelse
</div>
<!-- Pagination -->
@if($comments->hasPages())
<div class="mt-6">
{{ $comments->links() }}
</div>
@endif
</div>
</div>
@endsection