lots of design improvements

This commit is contained in:
Doar Mihai
2026-02-14 16:11:09 +02:00
parent 56b593d9ca
commit 67de095a03
25 changed files with 1942 additions and 1477 deletions
+148 -123
View File
@@ -1,130 +1,155 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="card">
<div class="card-header">
<h3 class="mb-0">Submit a Product</h3>
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Submit a Product</h1>
<p class="mt-2 text-sm text-gray-600">Share your EU-based tech product with the community</p>
</div>
<div class="bg-white shadow-sm rounded-lg">
<div class="px-4 py-5 sm:p-6">
<form method="POST" action="{{ route('products.store') }}" enctype="multipart/form-data" class="space-y-6">
@csrf
<!-- Title -->
<div>
<label for="title" class="block text-sm font-medium text-gray-700">
Product Title <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<input type="text"
id="title"
name="title"
value="{{ old('title') }}"
required
maxlength="255"
placeholder="e.g., My Awesome Product"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('title') border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500 @enderror">
@error('title')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">A catchy, descriptive title for your product.</p>
</div>
</div>
<div class="card-body">
<form method="POST" action="{{ route('products.store') }}" enctype="multipart/form-data">
@csrf
<!-- Title -->
<div class="mb-3">
<label for="title" class="form-label">Product Title <span class="text-danger">*</span></label>
<input type="text"
class="form-control @error('title') is-invalid @enderror"
id="title"
name="title"
value="{{ old('title') }}"
required
maxlength="255"
placeholder="e.g., My Awesome Product">
@error('title')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<small class="form-text text-muted">A catchy, descriptive title for your product.</small>
</div>
<!-- Description -->
<div class="mb-3">
<label for="description" class="form-label">Description <span class="text-danger">*</span></label>
<textarea class="form-control @error('description') is-invalid @enderror"
id="description"
name="description"
rows="5"
required
placeholder="Tell us about your product...">{{ old('description') }}</textarea>
@error('description')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<small class="form-text text-muted">Provide a detailed description of your product (what it does, key features, etc.).</small>
</div>
<!-- Website URL -->
<div class="mb-3">
<label for="website_url" class="form-label">Website URL <span class="text-danger">*</span></label>
<input type="url"
class="form-control @error('website_url') is-invalid @enderror"
id="website_url"
name="website_url"
value="{{ old('website_url') }}"
required
placeholder="https://example.com">
@error('website_url')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<small class="form-text text-muted">The full URL to your product's website or landing page.</small>
</div>
<!-- Category -->
<div class="mb-3">
<label for="category_id" class="form-label">Category <span class="text-danger">*</span></label>
<select class="form-select @error('category_id') is-invalid @enderror"
id="category_id"
name="category_id"
required>
<option value="">Select a category...</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id') == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<small class="form-text text-muted">Choose the category that best fits your product.</small>
</div>
<!-- Thumbnail -->
<div class="mb-3">
<label for="thumbnail" class="form-label">Product Thumbnail</label>
<input type="file"
class="form-control @error('thumbnail') is-invalid @enderror"
id="thumbnail"
name="thumbnail"
accept="image/*">
@error('thumbnail')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<small class="form-text text-muted">Upload a product screenshot or logo (JPEG, PNG, or GIF, max 2MB).</small>
</div>
<!-- Image Preview -->
<div class="mb-3" id="imagePreview" style="display: none;">
<label class="form-label">Preview:</label>
<div>
<img id="preview" src="#" alt="Thumbnail preview" style="max-width: 300px; max-height: 300px;" class="img-thumbnail">
</div>
</div>
<!-- Submit Button -->
<div class="d-flex justify-content-between">
<a href="{{ route('products.index') }}" class="btn btn-secondary">Cancel</a>
<button type="submit" class="btn btn-primary">Submit Product</button>
</div>
<div class="alert alert-info mt-3" role="alert">
<strong>Note:</strong> Your product will be reviewed by our moderators before it appears on the site.
</div>
</form>
<!-- Description -->
<div>
<label for="description" class="block text-sm font-medium text-gray-700">
Description <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<textarea id="description"
name="description"
rows="5"
required
placeholder="Tell us about your product..."
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('description') border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500 @enderror">{{ old('description') }}</textarea>
@error('description')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">Provide a detailed description of your product (what it does, key features, etc.).</p>
</div>
</div>
</div>
<!-- Website URL -->
<div>
<label for="website_url" class="block text-sm font-medium text-gray-700">
Website URL <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<input type="url"
id="website_url"
name="website_url"
value="{{ old('website_url') }}"
required
placeholder="https://example.com"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('website_url') border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500 @enderror">
@error('website_url')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">The full URL to your product's website or landing page.</p>
</div>
</div>
<!-- Category -->
<div>
<label for="category_id" class="block text-sm font-medium text-gray-700">
Category <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<select id="category_id"
name="category_id"
required
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('category_id') border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500 @enderror">
<option value="">Select a category...</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id') == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">Choose the category that best fits your product.</p>
</div>
</div>
<!-- Thumbnail -->
<div>
<label for="thumbnail" class="block text-sm font-medium text-gray-700">
Product Thumbnail
</label>
<div class="mt-1">
<input type="file"
id="thumbnail"
name="thumbnail"
accept="image/*"
class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100 @error('thumbnail') border-red-300 @enderror">
@error('thumbnail')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">Upload a product screenshot or logo (JPEG, PNG, or GIF, max 2MB).</p>
</div>
</div>
<!-- Image Preview -->
<div id="imagePreview" class="hidden">
<label class="block text-sm font-medium text-gray-700 mb-2">Preview:</label>
<div class="mt-1">
<img id="preview" src="#" alt="Thumbnail preview" class="max-w-xs rounded-lg border border-gray-300 shadow-sm">
</div>
</div>
<!-- Info Alert -->
<div class="rounded-md bg-blue-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-blue-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3 flex-1">
<p class="text-sm text-blue-700">
<strong>Note:</strong> Your product will be reviewed by our moderators before it appears on the site.
</p>
</div>
</div>
</div>
<!-- Submit Buttons -->
<div class="flex items-center justify-between pt-5 border-t border-gray-200">
<a href="{{ route('products.index') }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
Cancel
</a>
<button type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
Submit Product
</button>
</div>
</form>
</div>
</div>
</div>
@@ -137,11 +162,11 @@
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('preview').src = e.target.result;
document.getElementById('imagePreview').style.display = 'block';
document.getElementById('imagePreview').classList.remove('hidden');
}
reader.readAsDataURL(file);
} else {
document.getElementById('imagePreview').style.display = 'none';
document.getElementById('imagePreview').classList.add('hidden');
}
});
</script>
+164 -126
View File
@@ -1,133 +1,171 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="card">
<div class="card-header">
<h3 class="mb-0">Edit Product</h3>
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Edit Product</h1>
<p class="mt-2 text-sm text-gray-600">Update your product information and details</p>
</div>
<div class="bg-white shadow-sm rounded-lg">
<div class="px-4 py-5 sm:p-6">
<form method="POST" action="{{ route('products.update', $product) }}" enctype="multipart/form-data" class="space-y-6">
@csrf
@method('PUT')
<!-- Title -->
<div>
<label for="title" class="block text-sm font-medium text-gray-700">
Product Title <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<input type="text"
id="title"
name="title"
value="{{ old('title', $product->title) }}"
required
maxlength="255"
placeholder="e.g., My Awesome Product"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('title') border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500 @enderror">
@error('title')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">A catchy, descriptive title for your product.</p>
</div>
</div>
<div class="card-body">
<form method="POST" action="{{ route('products.update', $product) }}" enctype="multipart/form-data">
@csrf
@method('PUT')
<!-- Title -->
<div class="mb-3">
<label for="title" class="form-label">Product Title <span class="text-danger">*</span></label>
<input type="text"
class="form-control @error('title') is-invalid @enderror"
id="title"
name="title"
value="{{ old('title', $product->title) }}"
required
maxlength="255">
@error('title')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<!-- Description -->
<div class="mb-3">
<label for="description" class="form-label">Description <span class="text-danger">*</span></label>
<textarea class="form-control @error('description') is-invalid @enderror"
id="description"
name="description"
rows="5"
required>{{ old('description', $product->description) }}</textarea>
@error('description')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<!-- Website URL -->
<div class="mb-3">
<label for="website_url" class="form-label">Website URL <span class="text-danger">*</span></label>
<input type="url"
class="form-control @error('website_url') is-invalid @enderror"
id="website_url"
name="website_url"
value="{{ old('website_url', $product->website_url) }}"
required>
@error('website_url')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<!-- Category -->
<div class="mb-3">
<label for="category_id" class="form-label">Category <span class="text-danger">*</span></label>
<select class="form-select @error('category_id') is-invalid @enderror"
id="category_id"
name="category_id"
required>
<option value="">Select a category...</option>
@foreach($categories as $category)
<option value="{{ $category->id }}"
{{ old('category_id', $product->category_id) == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<!-- Current Thumbnail -->
@if($product->thumbnail_url)
<div class="mb-3">
<label class="form-label">Current Thumbnail:</label>
<div>
<img src="{{ $product->thumbnail_url }}" alt="{{ $product->title }}" style="max-width: 300px; max-height: 300px;" class="img-thumbnail">
</div>
</div>
@endif
<!-- New Thumbnail -->
<div class="mb-3">
<label for="thumbnail" class="form-label">
{{ $product->thumbnail_url ? 'Replace Thumbnail' : 'Product Thumbnail' }}
</label>
<input type="file"
class="form-control @error('thumbnail') is-invalid @enderror"
id="thumbnail"
name="thumbnail"
accept="image/*">
@error('thumbnail')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
<small class="form-text text-muted">JPEG, PNG, or GIF, max 2MB.</small>
</div>
<!-- Image Preview -->
<div class="mb-3" id="imagePreview" style="display: none;">
<label class="form-label">New Preview:</label>
<div>
<img id="preview" src="#" alt="Thumbnail preview" style="max-width: 300px; max-height: 300px;" class="img-thumbnail">
</div>
</div>
<!-- Submit Button -->
<div class="d-flex justify-content-between">
<a href="{{ route('products.show', $product) }}" class="btn btn-secondary">Cancel</a>
<button type="submit" class="btn btn-primary">Update Product</button>
</div>
</form>
<!-- Description -->
<div>
<label for="description" class="block text-sm font-medium text-gray-700">
Description <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<textarea id="description"
name="description"
rows="5"
required
placeholder="Tell us about your product..."
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('description') border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500 @enderror">{{ old('description', $product->description) }}</textarea>
@error('description')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">Provide a detailed description of your product (what it does, key features, etc.).</p>
</div>
</div>
</div>
<!-- Website URL -->
<div>
<label for="website_url" class="block text-sm font-medium text-gray-700">
Website URL <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<input type="url"
id="website_url"
name="website_url"
value="{{ old('website_url', $product->website_url) }}"
required
placeholder="https://example.com"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('website_url') border-red-300 text-red-900 placeholder-red-300 focus:ring-red-500 focus:border-red-500 @enderror">
@error('website_url')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">The full URL to your product's website or landing page.</p>
</div>
</div>
<!-- Category -->
<div>
<label for="category_id" class="block text-sm font-medium text-gray-700">
Category <span class="text-red-600">*</span>
</label>
<div class="mt-1">
<select id="category_id"
name="category_id"
required
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm @error('category_id') border-red-300 text-red-900 focus:ring-red-500 focus:border-red-500 @enderror">
<option value="">Select a category...</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ old('category_id', $product->category_id) == $category->id ? 'selected' : '' }}>
{{ $category->name }}
</option>
@endforeach
</select>
@error('category_id')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">Choose the category that best fits your product.</p>
</div>
</div>
<!-- Current Thumbnail -->
@if($product->thumbnail_url)
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Current Thumbnail:</label>
<div class="mt-1">
<img src="{{ $product->thumbnail_url }}"
alt="{{ $product->title }}"
class="max-w-xs rounded-lg border border-gray-300 shadow-sm">
</div>
</div>
@endif
<!-- New Thumbnail -->
<div>
<label for="thumbnail" class="block text-sm font-medium text-gray-700">
{{ $product->thumbnail_url ? 'Replace Thumbnail' : 'Product Thumbnail' }}
</label>
<div class="mt-1">
<input type="file"
id="thumbnail"
name="thumbnail"
accept="image/*"
class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100 @error('thumbnail') border-red-300 @enderror">
@error('thumbnail')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
<p class="mt-2 text-sm text-gray-500">Upload a product screenshot or logo (JPEG, PNG, or GIF, max 2MB).</p>
</div>
</div>
<!-- Image Preview -->
<div id="imagePreview" class="hidden">
<label class="block text-sm font-medium text-gray-700 mb-2">New Preview:</label>
<div class="mt-1">
<img id="preview" src="#" alt="Thumbnail preview" class="max-w-xs rounded-lg border border-gray-300 shadow-sm">
</div>
</div>
<!-- Info Alert -->
<div class="rounded-md bg-blue-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-blue-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3 flex-1">
<p class="text-sm text-blue-700">
<strong>Note:</strong> Changes to your product may need to be reviewed by moderators before appearing on the site.
</p>
</div>
</div>
</div>
<!-- Submit Buttons -->
<div class="flex items-center justify-between pt-5 border-t border-gray-200">
<a href="{{ route('products.show', $product) }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
Cancel
</a>
<button type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<svg class="mr-2 h-5 w-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>
Update Product
</button>
</div>
</form>
</div>
</div>
</div>
@@ -140,11 +178,11 @@
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('preview').src = e.target.result;
document.getElementById('imagePreview').style.display = 'block';
document.getElementById('imagePreview').classList.remove('hidden');
}
reader.readAsDataURL(file);
} else {
document.getElementById('imagePreview').style.display = 'none';
document.getElementById('imagePreview').classList.add('hidden');
}
});
</script>
+45 -24
View File
@@ -42,15 +42,20 @@
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Filters & Sorting -->
<div class="mb-8">
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-4">
<div class="bg-white rounded-xl shadow-sm border border-gray-200 p-6">
<form method="GET" action="{{ route('products.index') }}" class="space-y-4 lg:space-y-0" x-data="{ showFilters: false }">
<!-- Filter Toggle (Mobile) -->
<div class="lg:hidden">
<div class="lg:hidden mb-4">
<button @click="showFilters = !showFilters"
type="button"
class="w-full btn-secondary flex items-center justify-between">
<span>Filters & Sort</span>
<svg class="h-5 w-5" :class="{ 'rotate-180': showFilters }" fill="none" stroke="currentColor" viewBox="0 0 24 24">
class="w-full inline-flex items-center justify-between px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<span class="flex items-center">
<svg class="mr-2 h-5 w-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"></path>
</svg>
Filters & Sort
</span>
<svg class="h-5 w-5 transition-transform" :class="{ 'rotate-180': showFilters }" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
</button>
@@ -58,20 +63,24 @@
<!-- Filters Grid -->
<div :class="{ 'hidden': !showFilters }"
class="lg:block grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4">
class="lg:flex lg:items-end lg:gap-4 grid grid-cols-1 sm:grid-cols-2 gap-4 lg:gap-4">
<!-- Search (hidden on desktop as it's in hero) -->
<div class="lg:hidden">
<div class="lg:hidden sm:col-span-2">
<label for="mobile-search" class="block text-sm font-medium text-gray-700 mb-2">Search</label>
<input type="text"
id="mobile-search"
name="search"
value="{{ request('search') }}"
placeholder="Search..."
class="input">
placeholder="Search products..."
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
</div>
<!-- Category Filter -->
<div>
<label for="category" class="block text-sm font-medium text-gray-700 mb-1">Category</label>
<select name="category" id="category" class="input">
<div class="lg:flex-1">
<label for="category" class="block text-sm font-medium text-gray-700 mb-2">Category</label>
<select name="category"
id="category"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
<option value="">All Categories</option>
@foreach($categories as $category)
<option value="{{ $category->id }}" {{ request('category') == $category->id ? 'selected' : '' }}>
@@ -82,9 +91,11 @@
</div>
<!-- Date Range Filter -->
<div>
<label for="date_range" class="block text-sm font-medium text-gray-700 mb-1">Time Period</label>
<select name="date_range" id="date_range" class="input">
<div class="lg:flex-1">
<label for="date_range" class="block text-sm font-medium text-gray-700 mb-2">Time Period</label>
<select name="date_range"
id="date_range"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
<option value="">All Time</option>
<option value="today" {{ request('date_range') === 'today' ? 'selected' : '' }}>Today</option>
<option value="week" {{ request('date_range') === 'week' ? 'selected' : '' }}>This Week</option>
@@ -94,9 +105,11 @@
</div>
<!-- Sort By -->
<div>
<label for="sort" class="block text-sm font-medium text-gray-700 mb-1">Sort By</label>
<select name="sort" id="sort" class="input">
<div class="lg:flex-1">
<label for="sort" class="block text-sm font-medium text-gray-700 mb-2">Sort By</label>
<select name="sort"
id="sort"
class="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500 sm:text-sm">
<option value="newest" {{ request('sort') === 'newest' || !request('sort') ? 'selected' : '' }}>Newest</option>
<option value="popular" {{ request('sort') === 'popular' ? 'selected' : '' }}>Most Popular</option>
<option value="oldest" {{ request('sort') === 'oldest' ? 'selected' : '' }}>Oldest</option>
@@ -104,11 +117,19 @@
</div>
<!-- Action Buttons -->
<div class="flex items-end space-x-2">
<button type="submit" class="btn-primary flex-1 lg:flex-none">
<div class="flex gap-2 sm:col-span-2 lg:col-span-auto lg:flex-shrink-0">
<button type="submit"
class="flex-1 lg:flex-none inline-flex items-center justify-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<svg class="mr-2 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
</svg>
Apply
</button>
<a href="{{ route('products.index') }}" class="btn-outline flex-1 lg:flex-none">
<a href="{{ route('products.index') }}"
class="flex-1 lg:flex-none inline-flex items-center justify-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<svg class="mr-2 h-4 w-4" 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>
Clear
</a>
</div>
@@ -179,11 +200,11 @@
@endif
</p>
@auth
<a href="{{ route('products.create') }}" class="btn-primary inline-flex items-center space-x-2">
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<a href="{{ route('products.create') }}" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<svg class="mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
<span>Submit a Product</span>
Submit a Product
</a>
@endauth
</div>
+199 -157
View File
@@ -1,168 +1,210 @@
@extends('layouts.app')
@section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1 class="mb-4">Product Management</h1>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<!-- Header -->
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Product Management</h1>
<p class="mt-2 text-sm text-gray-600">Review and manage submitted products</p>
</div>
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<!-- Status Filter -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 mb-6">
<div class="px-6 py-4">
<h2 class="text-lg font-medium text-gray-900 mb-4">Filter by Status</h2>
<div class="flex flex-wrap gap-3">
<a href="{{ route('products.manage') }}"
class="inline-flex items-center px-4 py-2 rounded-md text-sm font-medium {{ !request('status') || request('status') == 'pending' ? 'bg-yellow-100 text-yellow-800 ring-2 ring-yellow-600' : 'bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50' }}">
<svg class="mr-2 h-5 w-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>
Pending
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ !request('status') || request('status') == 'pending' ? 'bg-yellow-200 text-yellow-800' : 'bg-gray-200 text-gray-700' }}">
{{ $statusCounts['pending'] }}
</span>
</a>
<!-- Status Filter -->
<div class="card mb-4">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<h5 class="mb-3">Filter by Status</h5>
<a href="{{ route('products.manage') }}"
class="btn btn-sm {{ !request('status') || request('status') == 'pending' ? 'btn-warning' : 'btn-outline-warning' }}">
Pending ({{ $statusCounts['pending'] }})
</a>
<a href="{{ route('products.manage', ['status' => 'approved']) }}"
class="btn btn-sm {{ request('status') == 'approved' ? 'btn-success' : 'btn-outline-success' }}">
Approved ({{ $statusCounts['approved'] }})
</a>
<a href="{{ route('products.manage', ['status' => 'rejected']) }}"
class="btn btn-sm {{ request('status') == 'rejected' ? 'btn-danger' : 'btn-outline-danger' }}">
Rejected ({{ $statusCounts['rejected'] }})
</a>
</div>
</div>
</div>
</div>
<a href="{{ route('products.manage', ['status' => 'approved']) }}"
class="inline-flex items-center px-4 py-2 rounded-md text-sm font-medium {{ request('status') == 'approved' ? 'bg-green-100 text-green-800 ring-2 ring-green-600' : 'bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50' }}">
<svg class="mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Approved
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ request('status') == 'approved' ? 'bg-green-200 text-green-800' : 'bg-gray-200 text-gray-700' }}">
{{ $statusCounts['approved'] }}
</span>
</a>
<!-- Products Table -->
<div class="card">
<div class="card-body">
@if($products->count() > 0)
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Thumbnail</th>
<th>Title</th>
<th>Category</th>
<th>Submitted By</th>
<th>Status</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach($products as $product)
<tr>
<td>
@if($product->thumbnail_url)
<img src="{{ $product->thumbnail_url }}"
alt="{{ $product->title }}"
style="width: 60px; height: 60px; object-fit: cover;"
class="rounded">
@else
<div class="bg-light d-flex align-items-center justify-content-center rounded"
style="width: 60px; height: 60px;">
<span class="text-muted small">No img</span>
</div>
@endif
</td>
<td>
<a href="{{ route('products.show', $product) }}" class="fw-bold text-decoration-none">
{{ $product->title }}
</a>
<br>
<small class="text-muted">{{ Str::limit($product->description, 60) }}</small>
</td>
<td>
<span class="badge bg-secondary">{{ $product->category->name }}</span>
</td>
<td>
<a href="{{ route('profile.show', $product->user) }}">
{{ $product->user->name }}
</a>
</td>
<td>
@if($product->isPending())
<span class="badge bg-warning text-dark">Pending</span>
@elseif($product->isApproved())
<span class="badge bg-success">Approved</span>
@elseif($product->isRejected())
<span class="badge bg-danger">Rejected</span>
@endif
</td>
<td>
<small>{{ $product->created_at->format('M j, Y') }}</small>
<br>
<small class="text-muted">{{ $product->created_at->diffForHumans() }}</small>
</td>
<td>
<div class="btn-group btn-group-sm" role="group">
@if($product->isPending() || $product->isRejected())
<form action="{{ route('products.approve', $product) }}" method="POST" class="d-inline">
@csrf
<button type="submit" class="btn btn-success btn-sm" title="Approve">
✓
</button>
</form>
@endif
@if($product->isPending() || $product->isApproved())
<form action="{{ route('products.reject', $product) }}" method="POST" class="d-inline">
@csrf
<button type="submit"
class="btn btn-danger btn-sm"
title="Reject"
onclick="return confirm('Are you sure you want to reject this product?');">
✗
</button>
</form>
@endif
<a href="{{ route('products.show', $product) }}" class="btn btn-info btn-sm" title="View">
👁
</a>
@can('edit-product', $product)
<a href="{{ route('products.edit', $product) }}" class="btn btn-primary btn-sm" title="Edit">
✎
</a>
@endcan
@can('delete-product', $product)
<form action="{{ route('products.destroy', $product) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit"
class="btn btn-danger btn-sm"
title="Delete"
onclick="return confirm('Are you sure you want to delete this product permanently?');">
🗑
</button>
</form>
@endcan
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="d-flex justify-content-center mt-4">
{{ $products->appends(['status' => request('status')])->links() }}
</div>
@else
<div class="alert alert-info">
No products found with status: {{ request('status', 'pending') }}
</div>
@endif
</div>
<a href="{{ route('products.manage', ['status' => 'rejected']) }}"
class="inline-flex items-center px-4 py-2 rounded-md text-sm font-medium {{ request('status') == 'rejected' ? 'bg-red-100 text-red-800 ring-2 ring-red-600' : 'bg-white text-gray-700 ring-1 ring-gray-300 hover:bg-gray-50' }}">
<svg class="mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
Rejected
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium {{ request('status') == 'rejected' ? 'bg-red-200 text-red-800' : 'bg-gray-200 text-gray-700' }}">
{{ $statusCounts['rejected'] }}
</span>
</a>
</div>
</div>
</div>
<!-- Products List -->
@if($products->count() > 0)
<div class="space-y-4">
@foreach($products as $product)
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden hover:shadow-md transition-shadow">
<div class="p-6">
<div class="flex items-start gap-4">
<!-- Thumbnail -->
<div class="flex-shrink-0">
@if($product->thumbnail_url)
<img src="{{ $product->thumbnail_url }}"
alt="{{ $product->title }}"
class="w-20 h-20 rounded-lg object-cover border border-gray-200">
@else
<div class="w-20 h-20 rounded-lg bg-gradient-to-br from-gray-100 to-gray-200 flex items-center justify-center border border-gray-200">
<svg class="h-8 w-8 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
</div>
@endif
</div>
<!-- Content -->
<div class="flex-1 min-w-0">
<div class="flex items-start justify-between">
<div class="flex-1">
<h3 class="text-lg font-semibold text-gray-900">
<a href="{{ route('products.show', $product) }}" class="hover:text-primary-600">
{{ $product->title }}
</a>
</h3>
<p class="mt-1 text-sm text-gray-600 line-clamp-2">{{ $product->description }}</p>
<div class="mt-3 flex flex-wrap items-center gap-4 text-sm">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md bg-primary-100 text-primary-800 font-medium">
{{ $product->category->name }}
</span>
<span class="inline-flex items-center text-gray-500">
<svg class="mr-1.5 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path>
</svg>
<a href="{{ route('profile.show', $product->user) }}" class="hover:text-primary-600">
{{ $product->user->name }}
</a>
</span>
<span class="inline-flex items-center text-gray-500">
<svg class="mr-1.5 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"></path>
</svg>
{{ $product->created_at->format('M j, Y') }}
</span>
<span class="text-gray-400">•</span>
<span class="text-gray-500">{{ $product->created_at->diffForHumans() }}</span>
</div>
</div>
<!-- Status Badge -->
<div class="ml-4 flex-shrink-0">
@if($product->isPending())
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-yellow-100 text-yellow-800">
Pending
</span>
@elseif($product->isApproved())
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-green-100 text-green-800">
Approved
</span>
@elseif($product->isRejected())
<span class="inline-flex items-center px-3 py-1 rounded-md text-sm font-medium bg-red-100 text-red-800">
Rejected
</span>
@endif
</div>
</div>
<!-- Actions -->
<div class="mt-4 flex items-center gap-2">
@if($product->isPending() || $product->isRejected())
<form action="{{ route('products.approve', $product) }}" method="POST">
@csrf
<button type="submit" class="inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
<svg class="mr-1.5 h-4 w-4" 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
@if($product->isPending() || $product->isApproved())
<form action="{{ route('products.reject', $product) }}" method="POST" onsubmit="return confirm('Are you sure you want to reject this product?');">
@csrf
<button type="submit" class="inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
<svg class="mr-1.5 h-4 w-4" 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>
@endif
<a href="{{ route('products.show', $product) }}" class="inline-flex items-center px-3 py-1.5 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<svg class="mr-1.5 h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
</svg>
View
</a>
@can('edit-product', $product)
<a href="{{ route('products.edit', $product) }}" class="inline-flex items-center px-3 py-1.5 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<svg class="mr-1.5 h-4 w-4" 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>
@endcan
@can('delete-product', $product)
<form action="{{ route('products.destroy', $product) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this product permanently?');">
@csrf
@method('DELETE')
<button type="submit" class="inline-flex items-center px-3 py-1.5 border border-red-300 text-sm font-medium rounded-md text-red-700 bg-white hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
<svg class="mr-1.5 h-4 w-4" 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>
@endcan
</div>
</div>
</div>
</div>
</div>
@endforeach
</div>
<!-- Pagination -->
@if($products->hasPages())
<div class="mt-6">
{{ $products->appends(['status' => request('status')])->links() }}
</div>
@endif
@else
<div class="text-center py-12 bg-gray-50 rounded-lg border border-gray-200">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"></path>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No products found</h3>
<p class="mt-1 text-sm text-gray-500">
No products with status: <strong>{{ request('status', 'pending') }}</strong>
</p>
</div>
@endif
</div>
@endsection
+293 -202
View File
@@ -1,215 +1,300 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Success Message -->
@if(session('success'))
<div class="mb-6 rounded-md bg-green-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
</svg>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-green-800">{{ session('success') }}</p>
</div>
</div>
</div>
@endif
<div class="bg-white rounded-lg shadow-sm border border-gray-200">
<!-- Product Header -->
<div class="px-6 py-8 border-b border-gray-200">
<div class="flex flex-col md:flex-row md:items-start md:justify-between gap-4">
<div class="flex-1">
<div class="flex items-center gap-3 mb-3">
<h1 class="text-3xl font-bold text-gray-900">{{ $product->title }}</h1>
<!-- Status Badges -->
@if($product->isPending())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-yellow-100 text-yellow-800">
Pending Review
</span>
@elseif($product->isApproved())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-green-100 text-green-800">
Approved
</span>
@elseif($product->isRejected())
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md text-xs font-medium bg-red-100 text-red-800">
Rejected
</span>
@endif
</div>
<div class="flex items-center gap-3 text-sm text-gray-600">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-md bg-primary-100 text-primary-800 font-medium">
{{ $product->category->name }}
</span>
<span>•</span>
<a href="{{ route('profile.show', $product->user) }}" class="hover:text-primary-600">
by {{ $product->user->name }}
</a>
<span>•</span>
<span>{{ $product->created_at->format('M j, Y') }}</span>
</div>
</div>
<!-- Action Buttons -->
<div class="flex items-center gap-2">
@auth
<!-- Upvote Button -->
<button
class="upvote-btn flex items-center gap-2 px-4 py-2 rounded-md border transition-colors {{ $product->isUpvotedBy(auth()->user()) ? 'border-primary-500 bg-primary-50 text-primary-700' : 'border-gray-300 bg-white text-gray-700 hover:border-primary-500 hover:bg-primary-50' }}"
data-product-id="{{ $product->id }}"
data-upvoted="{{ $product->isUpvotedBy(auth()->user()) ? 'true' : 'false' }}">
<svg class="h-5 w-5" fill="{{ $product->isUpvotedBy(auth()->user()) ? 'currentColor' : 'none' }}" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path>
</svg>
<span class="upvote-count font-semibold">{{ $product->upvotes()->count() }}</span>
</button>
<!-- Bookmark Button -->
<button
class="bookmark-btn p-2 rounded-md border transition-colors {{ $product->isBookmarkedBy(auth()->user()) ? 'border-primary-500 bg-primary-50 text-primary-700' : 'border-gray-300 bg-white text-gray-700 hover:border-gray-400' }}"
data-product-id="{{ $product->id }}"
data-bookmarked="{{ $product->isBookmarkedBy(auth()->user()) ? 'true' : 'false' }}">
<svg class="h-5 w-5" fill="{{ $product->isBookmarkedBy(auth()->user()) ? 'currentColor' : 'none' }}" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"></path>
</svg>
</button>
@else
<div class="flex items-center gap-2 px-4 py-2 rounded-md border border-gray-300 bg-gray-50 text-gray-700">
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7"></path>
</svg>
<span class="font-semibold">{{ $product->upvotes()->count() }}</span>
</div>
@endauth
@can('edit-product', $product)
<a href="{{ route('products.edit', $product) }}" class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
Edit
</a>
@endcan
@can('delete-product', $product)
<form action="{{ route('products.destroy', $product) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this product?');">
@csrf
@method('DELETE')
<button type="submit" class="inline-flex items-center px-3 py-2 border border-red-300 shadow-sm text-sm font-medium rounded-md text-red-700 bg-white hover:bg-red-50">
Delete
</button>
</form>
@endcan
</div>
</div>
</div>
<!-- Product Content -->
<div class="px-6 py-8">
<!-- Product Thumbnail -->
@if($product->thumbnail_url)
<div class="mb-8 rounded-lg overflow-hidden border border-gray-200">
<img src="{{ $product->thumbnail_url }}"
alt="{{ $product->title }}"
class="w-full h-auto max-h-96 object-contain bg-gray-50">
</div>
@endif
<div class="card">
<div class="card-body">
<!-- Product Header -->
<div class="d-flex justify-content-between align-items-start mb-4">
<div class="flex-grow-1">
<h1 class="mb-2">{{ $product->title }}</h1>
<p class="text-muted mb-0">
<span class="badge bg-secondary">{{ $product->category->name }}</span>
@if($product->isPending())
<span class="badge bg-warning text-dark">Pending Review</span>
@elseif($product->isApproved())
<span class="badge bg-success">Approved</span>
@elseif($product->isRejected())
<span class="badge bg-danger">Rejected</span>
@endif
</p>
</div>
<div class="d-flex align-items-center gap-2">
@auth
<!-- Upvote Button -->
<button
class="btn btn-outline-primary upvote-btn {{ $product->isUpvotedBy(auth()->user()) ? 'active' : '' }}"
data-product-id="{{ $product->id }}"
data-upvoted="{{ $product->isUpvotedBy(auth()->user()) ? 'true' : 'false' }}">
<i class="bi bi-arrow-up-circle"></i>
<span class="upvote-count">{{ $product->upvotes()->count() }}</span>
</button>
<!-- Product Description -->
<div class="mb-8">
<h2 class="text-xl font-semibold text-gray-900 mb-4">About</h2>
<p class="text-gray-700 text-lg leading-relaxed whitespace-pre-line">{{ $product->description }}</p>
</div>
<!-- Bookmark Button -->
<button
class="btn btn-outline-secondary bookmark-btn {{ $product->isBookmarkedBy(auth()->user()) ? 'active' : '' }}"
data-product-id="{{ $product->id }}"
data-bookmarked="{{ $product->isBookmarkedBy(auth()->user()) ? 'true' : 'false' }}">
<i class="bi {{ $product->isBookmarkedBy(auth()->user()) ? 'bi-bookmark-fill' : 'bi-bookmark' }}"></i>
</button>
<!-- Visit Website Button -->
<div class="mb-8">
<a href="{{ $product->website_url }}"
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 shadow-sm">
Visit Website
<svg class="ml-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
</svg>
</a>
</div>
<!-- Product Metadata -->
@if($product->isApproved() && $product->approved_at)
<div class="pt-6 border-t border-gray-200">
<dl class="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
<div>
<dt class="text-sm font-medium text-gray-500">Submitted by</dt>
<dd class="mt-1 text-sm text-gray-900">
<a href="{{ route('profile.show', $product->user) }}" class="hover:text-primary-600">
{{ $product->user->name }}
</a>
</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Submitted on</dt>
<dd class="mt-1 text-sm text-gray-900">{{ $product->created_at->format('F j, Y') }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Approved on</dt>
<dd class="mt-1 text-sm text-gray-900">{{ $product->approved_at->format('F j, Y') }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Category</dt>
<dd class="mt-1 text-sm text-gray-900">{{ $product->category->name }}</dd>
</div>
</dl>
</div>
@endif
</div>
</div>
<!-- Comments Section -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 mt-6">
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-xl font-semibold text-gray-900">
Comments ({{ $product->comments()->count() }})
</h2>
</div>
<div class="px-6 py-6">
@auth
<!-- Comment Form -->
<form action="{{ route('products.comments.store', $product) }}" method="POST" class="mb-8">
@csrf
<div>
<label for="body" class="sr-only">Add a comment</label>
<textarea
id="body"
name="body"
rows="3"
required
maxlength="1000"
placeholder="Share your thoughts about this product..."
class="block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm @error('body') border-red-300 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500 @enderror">{{ old('body') }}</textarea>
@error('body')
<p class="mt-2 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div class="mt-3 flex justify-end">
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
Post Comment
</button>
</div>
</form>
@else
<div class="text-center py-6 bg-gray-50 rounded-lg mb-8">
<p class="text-gray-600">
<a href="{{ route('login') }}" class="font-medium text-primary-600 hover:text-primary-500">Log in</a>
to post a comment
</p>
</div>
@endauth
<!-- Comments List -->
<div class="space-y-6">
@forelse($product->comments as $comment)
<div class="flex gap-4">
<!-- Avatar -->
<div class="flex-shrink-0">
@if($comment->user->avatar_url)
<img src="{{ $comment->user->avatar_url }}"
alt="{{ $comment->user->name }}"
class="h-10 w-10 rounded-full object-cover">
@else
<div class="text-muted">
<i class="bi bi-arrow-up-circle"></i>
<span>{{ $product->upvotes()->count() }}</span> upvotes
<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>
@endauth
@can('edit-product', $product)
<a href="{{ route('products.edit', $product) }}" class="btn btn-sm btn-outline-primary">Edit</a>
@endcan
@can('delete-product', $product)
<form action="{{ route('products.destroy', $product) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this product?');">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-outline-danger">Delete</button>
</form>
@endcan
@endif
</div>
</div>
<!-- Product Thumbnail -->
@if($product->thumbnail_url)
<div class="mb-4">
<img src="{{ $product->thumbnail_url }}" alt="{{ $product->title }}" class="img-fluid rounded" style="max-height: 400px;">
</div>
@endif
<!-- Product Description -->
<div class="mb-4">
<h4>About</h4>
<p class="lead">{{ $product->description }}</p>
</div>
<!-- Product Links -->
<div class="mb-4">
<a href="{{ $product->website_url }}" target="_blank" rel="noopener" class="btn btn-primary btn-lg">
Visit Website →
</a>
</div>
<!-- Product Metadata -->
<hr>
<div class="row text-muted small">
<div class="col-md-6">
<strong>Submitted by:</strong>
<a href="{{ route('profile.show', $product->user) }}">{{ $product->user->name }}</a>
</div>
<div class="col-md-6 text-md-end">
<strong>Submitted:</strong> {{ $product->created_at->format('F j, Y') }}
</div>
</div>
@if($product->isApproved() && $product->approved_at)
<div class="row text-muted small mt-2">
<div class="col-md-12">
<strong>Approved:</strong> {{ $product->approved_at->format('F j, Y') }}
</div>
</div>
@endif
</div>
</div>
<!-- Comments Section -->
<div class="card mt-3">
<div class="card-header">
<h5 class="mb-0">Comments ({{ $product->comments()->count() }})</h5>
</div>
<div class="card-body">
@auth
<!-- Comment Form -->
<form action="{{ route('products.comments.store', $product) }}" method="POST" class="mb-4">
@csrf
<div class="mb-3">
<textarea
class="form-control @error('body') is-invalid @enderror"
name="body"
rows="3"
placeholder="Share your thoughts about this product..."
required
maxlength="1000">{{ old('body') }}</textarea>
@error('body')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<button type="submit" class="btn btn-primary">Post Comment</button>
</form>
@else
<p class="text-muted">
<a href="{{ route('login') }}">Login</a> to post a comment.
</p>
@endauth
<!-- Comments List -->
@forelse($product->comments as $comment)
<div class="border-top pt-3 mt-3">
<div class="d-flex">
<div class="me-3">
@if($comment->user->avatar_url)
<img src="{{ $comment->user->avatar_url }}" alt="{{ $comment->user->name }}" class="rounded-circle" style="width: 40px; height: 40px; object-fit: cover;">
@else
<div class="bg-secondary text-white rounded-circle d-flex align-items-center justify-content-center" style="width: 40px; height: 40px;">
{{ strtoupper(substr($comment->user->name, 0, 1)) }}
</div>
@endif
</div>
<div class="flex-grow-1">
<div class="d-flex justify-content-between align-items-start">
<div>
<strong>{{ $comment->user->name }}</strong>
<span class="text-muted small">· {{ $comment->created_at->diffForHumans() }}</span>
</div>
@can('delete-comment', $comment)
<form action="{{ route('comments.destroy', $comment) }}" method="POST" class="d-inline">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-link text-danger p-0" onclick="return confirm('Are you sure you want to delete this comment?');">
Delete
</button>
</form>
@endcan
</div>
<p class="mb-0 mt-2">{{ $comment->body }}</p>
<!-- Comment Content -->
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between">
<div class="flex items-center gap-2">
<a href="{{ route('profile.show', $comment->user) }}" class="font-medium text-gray-900 hover:text-primary-600">
{{ $comment->user->name }}
</a>
<span class="text-gray-500 text-sm">·</span>
<span class="text-gray-500 text-sm">{{ $comment->created_at->diffForHumans() }}</span>
</div>
@can('delete-comment', $comment)
<form action="{{ route('comments.destroy', $comment) }}" method="POST" onsubmit="return confirm('Are you sure you want to delete this comment?');">
@csrf
@method('DELETE')
<button type="submit" class="text-sm text-red-600 hover:text-red-700">
Delete
</button>
</form>
@endcan
</div>
</div>
@empty
<p class="text-muted text-center py-4">No comments yet. Be the first to comment!</p>
@endforelse
</div>
</div>
<!-- Moderator Actions -->
@can('approve-product')
@if($product->isPending() || $product->isRejected())
<div class="card mt-3">
<div class="card-header bg-warning">
<h5 class="mb-0">Moderator Actions</h5>
</div>
<div class="card-body">
<form action="{{ route('products.approve', $product) }}" method="POST" class="d-inline">
@csrf
<button type="submit" class="btn btn-success">Approve Product</button>
</form>
<form action="{{ route('products.reject', $product) }}" method="POST" class="d-inline">
@csrf
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to reject this product?');">Reject Product</button>
</form>
<p class="mt-2 text-gray-700 whitespace-pre-line">{{ $comment->body }}</p>
</div>
</div>
@endif
@endcan
<div class="mt-3">
<a href="{{ route('products.index') }}" class="btn btn-secondary">← Back to Products</a>
@empty
<div class="text-center py-12 bg-gray-50 rounded-lg">
<svg class="mx-auto h-12 w-12 text-gray-400" 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="mt-2 text-gray-600">No comments yet. Be the first to share your thoughts!</p>
</div>
@endforelse
</div>
</div>
</div>
</div>
@push('styles')
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
@endpush
<!-- Moderator Actions -->
@can('approve-product')
@if($product->isPending() || $product->isRejected())
<div class="bg-yellow-50 border border-yellow-200 rounded-lg mt-6">
<div class="px-6 py-4 border-b border-yellow-200 bg-yellow-100">
<h3 class="text-lg font-semibold text-yellow-900">Moderator Actions</h3>
</div>
<div class="px-6 py-4 flex gap-3">
<form action="{{ route('products.approve', $product) }}" method="POST">
@csrf
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700">
Approve Product
</button>
</form>
<form action="{{ route('products.reject', $product) }}" method="POST" onsubmit="return confirm('Are you sure you want to reject this product?');">
@csrf
<button type="submit" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700">
Reject Product
</button>
</form>
</div>
</div>
@endif
@endcan
<!-- Back Button -->
<div class="mt-6">
<a href="{{ route('products.index') }}" class="inline-flex items-center text-sm font-medium text-gray-600 hover:text-gray-900">
<svg class="mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
</svg>
Back to Products
</a>
</div>
</div>
@push('scripts')
<script>
@@ -234,10 +319,16 @@
if (data.success) {
// Update button state
this.setAttribute('data-upvoted', data.upvoted ? 'true' : 'false');
const svg = this.querySelector('svg');
if (data.upvoted) {
this.classList.add('active');
this.classList.remove('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-primary-500', 'hover:bg-primary-50');
this.classList.add('border-primary-500', 'bg-primary-50', 'text-primary-700');
svg.setAttribute('fill', 'currentColor');
} else {
this.classList.remove('active');
this.classList.remove('border-primary-500', 'bg-primary-50', 'text-primary-700');
this.classList.add('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-primary-500', 'hover:bg-primary-50');
svg.setAttribute('fill', 'none');
}
// Update count
@@ -270,16 +361,16 @@
if (data.success) {
// Update button state
this.setAttribute('data-bookmarked', data.bookmarked ? 'true' : 'false');
const icon = this.querySelector('i');
const svg = this.querySelector('svg');
if (data.bookmarked) {
this.classList.add('active');
icon.classList.remove('bi-bookmark');
icon.classList.add('bi-bookmark-fill');
this.classList.remove('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-gray-400');
this.classList.add('border-primary-500', 'bg-primary-50', 'text-primary-700');
svg.setAttribute('fill', 'currentColor');
} else {
this.classList.remove('active');
icon.classList.remove('bi-bookmark-fill');
icon.classList.add('bi-bookmark');
this.classList.remove('border-primary-500', 'bg-primary-50', 'text-primary-700');
this.classList.add('border-gray-300', 'bg-white', 'text-gray-700', 'hover:border-gray-400');
svg.setAttribute('fill', 'none');
}
}
} catch (error) {