[Back] @extends('layouts.public')
@section('content')
<div class="flex items-center justify-between mb-6">
<h1 class="text-2xl font-bold">Manage Products</h1>
<a href="{{ route('admin.products.create') }}" class="px-4 py-2 rounded bg-black text-white">
+ Add Product
</a>
</div>
<div class="bg-white rounded-xl shadow overflow-hidden">
<table class="w-full text-sm">
<thead class="bg-gray-50">
<tr>
<th class="p-4 text-left">Name</th>
<th class="p-4 text-left">Slug</th>
<th class="p-4 text-left">Price</th>
<th class="p-4 text-left">Active</th>
<th class="p-4 text-right">Actions</th>
</tr>
</thead>
<tbody>
@forelse($products as $p)
<tr class="border-t">
<td class="p-4 font-medium">{{ $p->name }}</td>
<td class="p-4 text-gray-600">{{ $p->slug }}</td>
<td class="p-4">RM {{ number_format($p->price_cents / 100, 2) }}</td>
<td class="p-4">
<span class="px-2 py-1 rounded text-xs {{ $p->is_active ? 'bg-green-100' : 'bg-gray-100' }}">
{{ $p->is_active ? 'Yes' : 'No' }}
</span>
</td>
<td class="p-4 text-right">
<a class="underline" href="{{ route('products.show', $p->slug) }}" target="_blank">View</a>
<a class="underline ml-3" href="{{ route('admin.products.edit', $p) }}">Edit</a>
<form class="inline" method="POST" action="{{ route('admin.products.destroy', $p) }}">
@csrf
@method('DELETE')
<button class="underline text-red-600 ml-3" onclick="return confirm('Delete this product?')">
Delete
</button>
</form>
</td>
</tr>
@empty
<tr>
<td class="p-6 text-gray-600" colspan="5">No products found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-6">
{{ $products->links() }}
</div>
@endsection