work on the frontend
This commit is contained in:
@@ -1,176 +1,201 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@php
|
||||
$title = 'Discover Products - ' . config('app.name');
|
||||
@endphp
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Discover Products</h1>
|
||||
@auth
|
||||
<a href="{{ route('products.create') }}" class="btn btn-primary">Submit a Product</a>
|
||||
@endauth
|
||||
</div>
|
||||
<!-- Hero Section -->
|
||||
<div class="bg-gradient-to-br from-primary-50 via-white to-accent-50 border-b border-gray-200">
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 sm:py-16">
|
||||
<div class="text-center max-w-3xl mx-auto">
|
||||
<h1 class="text-4xl sm:text-5xl font-bold text-gray-900 mb-4">
|
||||
Discover the best tech from Europe
|
||||
</h1>
|
||||
<p class="text-lg text-gray-600 mb-8">
|
||||
Find amazing products built by European makers and companies
|
||||
</p>
|
||||
|
||||
<!-- Search & Filter Form -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<form method="GET" action="{{ route('products.index') }}" id="filterForm">
|
||||
<div class="row g-3">
|
||||
<!-- Search Input -->
|
||||
<div class="col-md-4">
|
||||
<label for="search" class="form-label fw-semibold">Search Products</label>
|
||||
<input
|
||||
type="text"
|
||||
name="search"
|
||||
id="search"
|
||||
value="{{ request('search') }}"
|
||||
class="form-control"
|
||||
placeholder="Search by title or description..."
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- Category Filter -->
|
||||
<div class="col-md-3">
|
||||
<label for="category" class="form-label fw-semibold">Category</label>
|
||||
<select name="category" id="category" class="form-select">
|
||||
<option value="">All Categories</option>
|
||||
@foreach($categories as $category)
|
||||
<option value="{{ $category->id }}" {{ request('category') == $category->id ? 'selected' : '' }}>
|
||||
{{ $category->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Date Range Filter -->
|
||||
<div class="col-md-2">
|
||||
<label for="date_range" class="form-label fw-semibold">Time Period</label>
|
||||
<select name="date_range" id="date_range" class="form-select">
|
||||
<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>
|
||||
<option value="month" {{ request('date_range') === 'month' ? 'selected' : '' }}>This Month</option>
|
||||
<option value="year" {{ request('date_range') === 'year' ? 'selected' : '' }}>This Year</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Sort By -->
|
||||
<div class="col-md-2">
|
||||
<label for="sort" class="form-label fw-semibold">Sort By</label>
|
||||
<select name="sort" id="sort" class="form-select">
|
||||
<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>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="col-md-1 d-flex align-items-end">
|
||||
<div class="btn-group w-100" role="group">
|
||||
<button type="submit" class="btn btn-primary" title="Apply Filters">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
<a href="{{ route('products.index') }}" class="btn btn-outline-secondary" title="Clear Filters">
|
||||
<i class="bi bi-x-circle"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(request()->hasAny(['search', 'category', 'date_range', 'sort']))
|
||||
<div class="mt-3">
|
||||
<small class="text-muted">
|
||||
<strong>Active Filters:</strong>
|
||||
@if(request('search'))
|
||||
<span class="badge bg-secondary me-1">Search: "{{ request('search') }}"</span>
|
||||
@endif
|
||||
@if(request('category'))
|
||||
<span class="badge bg-secondary me-1">Category: {{ $categories->find(request('category'))->name ?? 'Unknown' }}</span>
|
||||
@endif
|
||||
@if(request('date_range'))
|
||||
<span class="badge bg-secondary me-1">Period: {{ ucfirst(request('date_range')) }}</span>
|
||||
@endif
|
||||
@if(request('sort') && request('sort') !== 'newest')
|
||||
<span class="badge bg-secondary me-1">Sort: {{ ucfirst(request('sort')) }}</span>
|
||||
@endif
|
||||
</small>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
</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
|
||||
|
||||
<!-- Results Summary -->
|
||||
@if($products->total() > 0)
|
||||
<div class="mb-3">
|
||||
<p class="text-muted">
|
||||
Showing {{ $products->firstItem() }} to {{ $products->lastItem() }} of {{ $products->total() }} product(s)
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Products Grid -->
|
||||
<div class="row">
|
||||
@forelse($products as $product)
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card h-100">
|
||||
@if($product->thumbnail_url)
|
||||
<img src="{{ $product->thumbnail_url }}" class="card-img-top" alt="{{ $product->title }}" style="height: 200px; object-fit: cover;">
|
||||
@else
|
||||
<div class="bg-light d-flex align-items-center justify-content-center" style="height: 200px;">
|
||||
<span class="text-muted">No image</span>
|
||||
</div>
|
||||
@endif
|
||||
<div class="card-body d-flex flex-column">
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<h5 class="card-title mb-0">{{ $product->title }}</h5>
|
||||
@if(isset($product->upvotes_count))
|
||||
<span class="badge bg-primary rounded-pill">
|
||||
<i class="bi bi-arrow-up"></i> {{ $product->upvotes_count }}
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
<p class="card-text text-muted small mb-2">
|
||||
<span class="badge bg-secondary">{{ $product->category->name }}</span>
|
||||
</p>
|
||||
<p class="card-text flex-grow-1">{{ Str::limit($product->description, 100) }}</p>
|
||||
<div class="mt-auto">
|
||||
<a href="{{ route('products.show', $product) }}" class="btn btn-sm btn-primary">View Details</a>
|
||||
<a href="{{ $product->website_url }}" target="_blank" rel="noopener" class="btn btn-sm btn-outline-primary">Visit Website</a>
|
||||
</div>
|
||||
<div class="mt-2 text-muted small">
|
||||
By {{ $product->user->name }} · {{ $product->created_at->diffForHumans() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Hero Search -->
|
||||
<div class="max-w-2xl mx-auto">
|
||||
<form method="GET" action="{{ route('products.index') }}">
|
||||
<div class="relative">
|
||||
<input type="text"
|
||||
name="search"
|
||||
value="{{ request('search') }}"
|
||||
placeholder="Search for products..."
|
||||
class="w-full px-6 py-4 text-lg border-2 border-gray-300 rounded-full focus:border-primary-500 focus:ring-2 focus:ring-primary-200 transition-all duration-200">
|
||||
<button type="submit"
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2 bg-primary-600 text-white px-6 py-2 rounded-full hover:bg-primary-700 transition-colors">
|
||||
<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="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
@empty
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">
|
||||
@if(request()->hasAny(['search', 'category', 'date_range']))
|
||||
No products found matching your filters. Try adjusting your search criteria.
|
||||
@else
|
||||
No products found. Be the first to submit one!
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforelse
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
@if($products->hasPages())
|
||||
<div class="d-flex justify-content-center">
|
||||
{{ $products->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<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">
|
||||
<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">
|
||||
<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">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Filters Grid -->
|
||||
<div :class="{ 'hidden': !showFilters }"
|
||||
class="lg:block grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4">
|
||||
<!-- Search (hidden on desktop as it's in hero) -->
|
||||
<div class="lg:hidden">
|
||||
<input type="text"
|
||||
name="search"
|
||||
value="{{ request('search') }}"
|
||||
placeholder="Search..."
|
||||
class="input">
|
||||
</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">
|
||||
<option value="">All Categories</option>
|
||||
@foreach($categories as $category)
|
||||
<option value="{{ $category->id }}" {{ request('category') == $category->id ? 'selected' : '' }}>
|
||||
{{ $category->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</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">
|
||||
<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>
|
||||
<option value="month" {{ request('date_range') === 'month' ? 'selected' : '' }}>This Month</option>
|
||||
<option value="year" {{ request('date_range') === 'year' ? 'selected' : '' }}>This Year</option>
|
||||
</select>
|
||||
</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">
|
||||
<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>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex items-end space-x-2">
|
||||
<button type="submit" class="btn-primary flex-1 lg:flex-none">
|
||||
Apply
|
||||
</button>
|
||||
<a href="{{ route('products.index') }}" class="btn-outline flex-1 lg:flex-none">
|
||||
Clear
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Active Filters Tags -->
|
||||
@if(request()->hasAny(['search', 'category', 'date_range', 'sort']))
|
||||
<div class="flex flex-wrap gap-2 pt-4 border-t border-gray-200">
|
||||
<span class="text-sm font-medium text-gray-700">Active filters:</span>
|
||||
@if(request('search'))
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm bg-primary-100 text-primary-800">
|
||||
Search: "{{ request('search') }}"
|
||||
<a href="{{ route('products.index', request()->except('search')) }}" class="ml-2 hover:text-primary-900">×</a>
|
||||
</span>
|
||||
@endif
|
||||
@if(request('category'))
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm bg-primary-100 text-primary-800">
|
||||
{{ $categories->find(request('category'))->name ?? 'Unknown' }}
|
||||
<a href="{{ route('products.index', request()->except('category')) }}" class="ml-2 hover:text-primary-900">×</a>
|
||||
</span>
|
||||
@endif
|
||||
@if(request('date_range'))
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm bg-primary-100 text-primary-800">
|
||||
{{ ucfirst(request('date_range')) }}
|
||||
<a href="{{ route('products.index', request()->except('date_range')) }}" class="ml-2 hover:text-primary-900">×</a>
|
||||
</span>
|
||||
@endif
|
||||
@if(request('sort') && request('sort') !== 'newest')
|
||||
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm bg-primary-100 text-primary-800">
|
||||
{{ ucfirst(request('sort')) }}
|
||||
<a href="{{ route('products.index', request()->except('sort')) }}" class="ml-2 hover:text-primary-900">×</a>
|
||||
</span>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Results Summary -->
|
||||
@if($products->total() > 0)
|
||||
<div class="mb-6">
|
||||
<p class="text-sm text-gray-600">
|
||||
Showing <span class="font-semibold text-gray-900">{{ $products->firstItem() }}</span> to
|
||||
<span class="font-semibold text-gray-900">{{ $products->lastItem() }}</span> of
|
||||
<span class="font-semibold text-gray-900">{{ $products->total() }}</span> products
|
||||
</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Products Grid -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
|
||||
@forelse($products as $product)
|
||||
@include('components.product.card', ['product' => $product])
|
||||
@empty
|
||||
<!-- Empty State -->
|
||||
<div class="col-span-full">
|
||||
<div class="text-center py-16">
|
||||
<svg class="mx-auto h-16 w-16 text-gray-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-2">No products found</h3>
|
||||
<p class="text-gray-600 mb-6">
|
||||
@if(request()->hasAny(['search', 'category', 'date_range']))
|
||||
Try adjusting your search or filters to find what you're looking for.
|
||||
@else
|
||||
Be the first to submit a product!
|
||||
@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">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
|
||||
</svg>
|
||||
<span>Submit a Product</span>
|
||||
</a>
|
||||
@endauth
|
||||
</div>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
@if($products->hasPages())
|
||||
<div class="flex justify-center">
|
||||
{{ $products->links() }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user