Files
jouwdriedee/resources/views/admin/products/index.blade.php
T

212 lines
13 KiB
PHP

@extends('layouts.admin')
@section('title', 'Producten Beheren | Jouwdriedee Beheer')
@section('content')
<div class="space-y-6">
<!-- Header -->
<div class="flex flex-col sm:flex-row sm:items-center justify-between pb-6 border-b border-slate-200/60 gap-4">
<div>
<span class="text-[11px] font-semibold uppercase tracking-wider text-slate-400 block mb-1">Catalogus & Assortiment</span>
<h1 class="font-heading text-2xl sm:text-3xl font-bold text-slate-900 tracking-tight">Producten ({{ $products->total() }})</h1>
<p class="text-xs sm:text-sm text-slate-500 mt-1">Beheer prijzen, teksten, kostprijscalculaties en afbeeldingen van alle 3D prints.</p>
</div>
<div class="flex items-center space-x-2.5 self-start sm:self-auto">
<a href="{{ route('admin.makerworld.index') }}" class="px-3.5 py-2 rounded-lg bg-white hover:bg-slate-50 text-slate-700 text-xs font-medium transition flex items-center space-x-1.5 border border-slate-200/80 shadow-2xs">
<i data-lucide="download-cloud" class="w-3.5 h-3.5 text-slate-400"></i>
<span>MakerWorld Sync</span>
</a>
<a href="{{ route('admin.products.create') }}" class="px-3.5 py-2 rounded-lg bg-slate-900 hover:bg-slate-800 text-white font-medium text-xs transition flex items-center space-x-1.5 shadow-2xs">
<i data-lucide="plus" class="w-3.5 h-3.5"></i>
<span>Nieuw Product</span>
</a>
</div>
</div>
<!-- Status Filter Tabs (Sleek Segmented Control) -->
<div class="flex items-center space-x-1.5 p-1 bg-slate-100/80 rounded-xl w-fit overflow-x-auto text-xs">
<a href="{{ route('admin.products.index', array_merge(request()->except('tab', 'page'), ['tab' => 'all'])) }}" class="px-3 py-1.5 rounded-lg transition flex items-center space-x-1.5 {{ ($tab ?? 'all') === 'all' ? 'bg-white text-slate-900 font-semibold shadow-2xs' : 'text-slate-600 hover:text-slate-900' }}">
<span>Alle</span>
<span class="text-[11px] text-slate-400">({{ $totalAll ?? $products->total() }})</span>
</a>
<a href="{{ route('admin.products.index', array_merge(request()->except('tab', 'page'), ['tab' => 'published'])) }}" class="px-3 py-1.5 rounded-lg transition flex items-center space-x-1.5 {{ ($tab ?? 'all') === 'published' ? 'bg-white text-slate-900 font-semibold shadow-2xs' : 'text-slate-600 hover:text-slate-900' }}">
<span class="w-1.5 h-1.5 rounded-full bg-emerald-500"></span>
<span>Live in Webshop</span>
<span class="text-[11px] text-slate-400">({{ $totalPublished ?? 0 }})</span>
</a>
<a href="{{ route('admin.products.index', array_merge(request()->except('tab', 'page'), ['tab' => 'draft'])) }}" class="px-3 py-1.5 rounded-lg transition flex items-center space-x-1.5 {{ ($tab ?? 'all') === 'draft' ? 'bg-white text-slate-900 font-semibold shadow-2xs' : 'text-slate-600 hover:text-slate-900' }}">
<span>Concepten / Staging</span>
@if(($totalDraft ?? 0) > 0)
<span class="px-1.5 py-0.2 rounded-full text-[10px] font-semibold bg-amber-100 text-amber-800">
{{ $totalDraft }}
</span>
@endif
</a>
<a href="{{ route('admin.products.index', array_merge(request()->except('tab', 'page'), ['tab' => 'makerworld'])) }}" class="px-3 py-1.5 rounded-lg transition flex items-center space-x-1.5 {{ ($tab ?? 'all') === 'makerworld' ? 'bg-white text-slate-900 font-semibold shadow-2xs' : 'text-slate-600 hover:text-slate-900' }}">
<span>MakerWorld</span>
<span class="text-[11px] text-slate-400">({{ $totalMakerWorld ?? 0 }})</span>
</a>
</div>
<!-- Search & Filters -->
<div class="p-3 rounded-xl bg-white border border-slate-200/60 shadow-2xs flex flex-col sm:flex-row items-center justify-between gap-3">
<form action="{{ route('admin.products.index') }}" method="GET" class="w-full sm:w-auto flex-1 flex items-center space-x-2">
<div class="relative flex-1 max-w-sm">
<input
type="text"
name="q"
value="{{ request('q') }}"
placeholder="Zoek op naam..."
class="w-full bg-slate-50 border border-slate-200/80 rounded-lg pl-8 pr-3 py-1.5 text-xs text-slate-800 placeholder-slate-400 focus:outline-none focus:ring-1 focus:ring-slate-400 focus:bg-white transition"
>
<i data-lucide="search" class="w-3.5 h-3.5 text-slate-400 absolute left-2.5 top-1/2 -translate-y-1/2"></i>
</div>
<select name="category_id" onchange="this.form.submit()" class="bg-slate-50 border border-slate-200/80 rounded-lg px-2.5 py-1.5 text-xs text-slate-700 focus:outline-none focus:ring-1 focus:ring-slate-400">
<option value="">Alle Categorieën</option>
@foreach($categories as $cat)
<option value="{{ $cat->id }}" {{ request('category_id') == $cat->id ? 'selected' : '' }}>{{ $cat->name }}</option>
@endforeach
</select>
<button type="submit" class="px-3 py-1.5 bg-slate-900 hover:bg-slate-800 text-white rounded-lg text-xs font-medium transition">
Filter
</button>
@if(request()->hasAny(['q', 'category_id']))
<a href="{{ route('admin.products.index') }}" class="text-xs text-rose-600 hover:underline">Wissen</a>
@endif
</form>
@if(($totalDraft ?? 0) > 0)
<a href="{{ route('admin.makerworld.staging') }}" class="text-xs text-slate-600 hover:text-slate-900 font-medium flex items-center space-x-1">
<span>Naar Artikel Beheer ({{ $totalDraft }} nieuw)</span>
<i data-lucide="arrow-right" class="w-3 h-3"></i>
</a>
@endif
</div>
<!-- Products Table (Clean & Airy) -->
<div class="rounded-xl bg-white border border-slate-200/60 overflow-hidden shadow-2xs">
<div class="overflow-x-auto">
<table class="w-full text-left text-xs text-slate-600">
<thead class="bg-slate-50/70 text-[11px] uppercase tracking-wider text-slate-400 font-semibold border-b border-slate-200/60">
<tr>
<th class="py-3 px-4">Product</th>
<th class="py-3 px-4">Categorie</th>
<th class="py-3 px-4">Prijs</th>
<th class="py-3 px-4">Specificaties</th>
<th class="py-3 px-4">Status</th>
<th class="py-3 px-4 text-right">Acties</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100 font-normal">
@forelse($products as $product)
<tr class="hover:bg-slate-50/50 transition">
<td class="py-3 px-4">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-lg bg-slate-100 overflow-hidden border border-slate-200/60 shrink-0 relative group">
<img src="{{ $product->image_url }}" alt="{{ $product->name }}" class="w-full h-full object-cover">
@if(!empty($product->gallery_images) && count($product->gallery_images) > 0)
<span class="absolute bottom-0 right-0 px-1 py-0.2 rounded-tl-sm bg-slate-900/80 text-white font-mono text-[8px]" title="{{ count($product->gallery_images) + 1 }} foto's in galerij">
+{{ count($product->gallery_images) }}
</span>
@endif
</div>
<div>
<a href="{{ route('admin.products.edit', $product) }}" class="font-semibold text-slate-900 hover:text-sky-600 transition block text-xs">
{{ $product->name }}
</a>
<span class="text-[10px] text-slate-400 font-mono">/{{ $product->slug }}</span>
</div>
</div>
</td>
<td class="py-3 px-4">
@if($product->category)
<span class="px-2 py-0.5 rounded-md bg-slate-100 text-slate-600 text-[11px] font-medium">
{{ $product->category->name }}
</span>
@else
<span class="text-slate-400">-</span>
@endif
</td>
<td class="py-3 px-4">
<span class="font-bold text-slate-900 font-heading text-xs">{{ $product->formatted_price }}</span>
</td>
<td class="py-3 px-4 text-[11px] text-slate-400 space-y-0.5">
<div>{{ $product->dimensions ?? 'Standaard' }}</div>
<div>~{{ $product->weight_grams ?? 0 }}g &bull; {{ $product->print_time_hours ?? 0 }}u</div>
</td>
<td class="py-3 px-4">
<div class="flex flex-col gap-1 items-start">
@if($product->status === 'draft')
<span class="inline-flex items-center space-x-1 px-2 py-0.5 rounded-md bg-amber-50 text-amber-800 text-[10px] font-semibold border border-amber-200/60">
<span>Concept</span>
</span>
@elseif($product->is_active)
<span class="inline-flex items-center space-x-1.5 text-emerald-700 text-[11px] font-medium">
<span class="w-1.5 h-1.5 rounded-full bg-emerald-500"></span>
<span>Live</span>
</span>
@else
<span class="inline-flex items-center space-x-1.5 text-slate-400 text-[11px]">
<span class="w-1.5 h-1.5 rounded-full bg-slate-300"></span>
<span>Verborgen</span>
</span>
@endif
@if($product->makerworld_id)
<span class="text-[10px] text-slate-400 font-mono">
MW #{{ $product->makerworld_id }}
</span>
@endif
</div>
</td>
<td class="py-3 px-4 text-right">
<div class="flex items-center justify-end space-x-1">
<a href="{{ route('product.show', $product->slug) }}" target="_blank" class="p-1.5 rounded-md text-slate-400 hover:text-slate-700 hover:bg-slate-100 transition" title="Bekijk in Shop">
<i data-lucide="external-link" class="w-3.5 h-3.5"></i>
</a>
<a href="{{ route('admin.products.edit', $product) }}" class="p-1.5 rounded-md text-slate-500 hover:text-slate-900 hover:bg-slate-100 transition" title="Bewerken & Prijscalculator">
<i data-lucide="pencil" class="w-3.5 h-3.5"></i>
</a>
<form action="{{ route('admin.products.destroy', $product) }}" method="POST" onsubmit="return confirm('Weet je zeker dat je dit product wilt verwijderen?')">
@csrf
@method('DELETE')
<button type="submit" class="p-1.5 rounded-md text-slate-400 hover:text-rose-600 hover:bg-rose-50 transition cursor-pointer" title="Verwijderen">
<i data-lucide="trash-2" class="w-3.5 h-3.5"></i>
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="p-8 text-center text-slate-400">
Geen producten gevonden.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if($products->hasPages())
<div class="p-3.5 border-t border-slate-100 bg-slate-50/50">
{{ $products->links() }}
</div>
@endif
</div>
</div>
@endsection