TA/web_JMW/resources/views/user/all-cars.blade.php

545 lines
14 KiB
PHP

<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="csrf-token" content="{{ csrf_token() }}" />
<title>Daftar Semua Mobil Bekas</title>
<style>
:root {
font-family: Inter, system-ui, sans-serif;
color: #111827;
background: #f8fafc;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}
.page-shell {
max-width: 1280px;
margin: 0 auto;
padding: 32px 24px 64px;
}
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 40px;
gap: 16px;
flex-wrap: wrap;
}
.page-header h1 {
margin: 0;
font-size: 2.2rem;
color: #111827;
}
.header-actions {
display: flex;
gap: 12px;
align-items: center;
}
.back-button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
border: none;
border-radius: 999px;
padding: 12px 20px;
font-weight: 600;
text-decoration: none;
transition: transform 0.2s ease, background 0.2s ease;
cursor: pointer;
background: #ffffff;
color: #4338ca;
border: 1px solid #c7d2fe;
box-shadow: 0 12px 24px rgba(67, 56, 202, 0.08);
font-size: 0.95rem;
}
.back-button:hover {
transform: translateY(-1px);
background: #eef2ff;
}
.user-profile-link {
text-decoration: none;
color: inherit;
}
.user-profile {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.95);
color: #0f172a;
border: 1px solid rgba(148, 163, 184, 0.25);
box-shadow: 0 14px 35px rgba(15, 23, 42, 0.12);
}
.profile-avatar {
width: 38px;
height: 38px;
border-radius: 50%;
display: grid;
place-items: center;
background: #4338ca;
color: white;
font-weight: 700;
font-size: 0.95rem;
}
.profile-info span {
display: block;
font-weight: 700;
font-size: 0.95rem;
color: #0f172a;
}
.profile-info small {
display: block;
color: #64748b;
font-size: 0.78rem;
}
.section-heading {
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
flex-wrap: wrap;
margin: 0 0 24px;
}
.section-heading h2 {
margin: 0;
font-size: 1.6rem;
}
.section-heading span {
color: #6b7280;
font-size: 0.95rem;
}
.market-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 22px;
}
.pagination-wrap {
display: flex;
justify-content: center;
margin-top: 34px;
}
.pagination {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
gap: 8px;
margin: 0;
padding: 0;
list-style: none;
}
.page-item {
display: flex;
}
.page-link,
.page-item span {
min-width: 42px;
height: 42px;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 14px;
border-radius: 999px;
border: 1px solid #c7d2fe;
background: #ffffff;
color: #4338ca;
font-weight: 800;
text-decoration: none;
box-shadow: 0 12px 24px rgba(67, 56, 202, 0.08);
}
.page-link:hover {
background: #eef2ff;
transform: translateY(-1px);
}
.page-item.active span {
background: #4338ca;
color: #ffffff;
border-color: #4338ca;
}
.page-item.disabled span {
color: #94a3b8;
background: #f8fafc;
border-color: #e2e8f0;
box-shadow: none;
}
.card-link {
display: block;
text-decoration: none;
color: inherit;
}
.card-link:hover .listing-card {
transform: translateY(-3px);
box-shadow: 0 24px 60px rgba(15, 23, 42, 0.1);
}
.listing-card {
background: white;
border-radius: 18px;
border: 1px solid #e5e7eb;
overflow: hidden;
display: flex;
flex-direction: column;
min-height: 100%;
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.listing-card:hover {
transform: translateY(-3px);
box-shadow: 0 24px 60px rgba(15, 23, 42, 0.1);
}
.listing-image {
position: relative;
aspect-ratio: 4 / 3;
width: 100%;
background: #f8fafc;
display: grid;
place-items: center;
color: #0f172a;
text-align: center;
overflow: hidden;
}
.listing-image img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
transition: transform 0.3s ease;
}
.listing-image:hover img {
transform: scale(1.02);
}
.listing-image::after {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(180deg, rgba(255,255,255,0.2), transparent 60%);
pointer-events: none;
}
.listing-content {
padding: 18px;
display: flex;
flex-direction: column;
gap: 12px;
flex: 1;
}
.listing-top {
display: flex;
justify-content: space-between;
align-items: flex-end;
gap: 6px;
}
.price {
font-size: 1.35rem;
font-weight: 800;
line-height: 1.1;
color: #0f172a;
}
.year {
color: #475569;
font-size: 0.95rem;
font-weight: 600;
}
.listing-content h3 {
margin: 0;
font-size: 1.1rem;
line-height: 1.25;
font-weight: 700;
color: #111827;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.listing-content p {
margin: 0;
color: #475569;
line-height: 1.5;
min-height: 3rem;
font-size: 0.95rem;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.listing-footer {
display: flex;
justify-content: flex-start;
}
.date-badge {
color: #475569;
font-size: 0.84rem;
padding: 6px 10px;
border-radius: 12px;
background: #f8fafc;
font-weight: 600;
}
.favorite-button {
position: absolute;
top: 12px;
right: 12px;
width: 36px;
height: 36px;
border-radius: 50%;
border: none;
background: rgba(255, 255, 255, 0.9);
display: grid;
place-items: center;
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
cursor: pointer;
transition: all 0.2s ease;
z-index: 10;
}
.favorite-button:hover {
transform: scale(1.1);
background: #ffffff;
}
.favorite-button.favorited svg {
fill: #ef4444;
}
.favorite-button svg {
width: 18px;
height: 18px;
fill: #64748b;
transition: fill 0.2s ease;
}
.empty-state {
grid-column: 1 / -1;
text-align: center;
background: white;
border-radius: 28px;
padding: 48px 32px;
box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
margin-top: 24px;
}
.empty-state h2 {
margin: 0;
font-size: 1.75rem;
}
.empty-state p {
margin: 16px 0 0;
color: #6b7280;
line-height: 1.75;
}
@media (max-width: 768px) {
.page-header {
flex-direction: column;
align-items: flex-start;
}
.page-header h1 {
font-size: 1.75rem;
}
.market-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 640px) {
.page-shell {
padding: 24px 16px 48px;
}
.market-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="page-shell">
<div class="page-header">
<div>
<h1>Daftar Mobil Bekas</h1>
</div>
<div class="header-actions">
<a href="{{ route('mobil-bekas') }}" class="back-button">← Kembali</a>
@if(Auth::check())
<a href="{{ route('user.profile') }}" class="user-profile-link">
<div class="user-profile">
<div class="profile-avatar">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 12C14.7614 12 17 9.76142 17 7C17 4.23858 14.7614 2 12 2C9.23858 2 7 4.23858 7 7C7 9.76142 9.23858 12 12 12Z" fill="white"/>
<path d="M4 22C4 17.5817 7.58172 14 12 14C16.4183 14 20 17.5817 20 22H4Z" fill="white"/>
</svg>
</div>
<div class="profile-info">
<span>{{ Auth::user()->name }}</span>
<small>Profil Anda</small>
</div>
</div>
</a>
@endif
</div>
</div>
@if($categories->isEmpty())
<div class="empty-state">
<h2>Belum ada listing mobil bekas.</h2>
<p>Silakan tambahkan mobil bekas lewat halaman manajemen kategori agar tampil di marketplace ini.</p>
</div>
@else
<div class="section-heading">
<div>
<h2>Semua Mobil Bekas</h2>
</div>
<span>{{ $categories->total() }} listing</span>
</div>
<div class="market-grid">
@foreach($categories as $category)
<a href="{{ route('mobil-bekas.detail', $category) }}" class="card-link">
<article class="listing-card">
<div class="listing-image">
<img src="{{ $category->image_url }}" alt="{{ $category->image ? $category->name : 'Gambar default ' . $category->name }}" />
@if(Auth::check())
<button class="favorite-button {{ $category->isFavoritedBy(Auth::user()->username) ? 'favorited' : '' }}"
data-category-id="{{ $category->id }}"
type="button">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
</svg>
</button>
@endif
</div>
<div class="listing-content">
<div class="listing-top">
<div class="price">Rp {{ number_format($category->price, 0, ',', '.') }}</div>
@if($category->year)
<div class="year">{{ $category->year }}</div>
@endif
</div>
<h3>{{ $category->name }}</h3>
<p>{{ \Illuminate\Support\Str::limit($category->description, 80) }}</p>
<div class="listing-footer">
<span class="date-badge">{{ $category->created_at && $category->created_at->isToday() ? 'HARI INI' : $category->created_at->format('d M Y') }}</span>
</div>
</div>
</article>
</a>
@endforeach
</div>
<div class="pagination-wrap">
@if($categories->hasPages())
<ul class="pagination">
<li class="page-item {{ $categories->onFirstPage() ? 'disabled' : '' }}">
@if($categories->onFirstPage())
<span>&lsaquo;</span>
@else
<a class="page-link" href="{{ $categories->previousPageUrl() }}" rel="prev">&lsaquo;</a>
@endif
</li>
@foreach($categories->getUrlRange(1, $categories->lastPage()) as $page => $url)
<li class="page-item {{ $page === $categories->currentPage() ? 'active' : '' }}">
@if($page === $categories->currentPage())
<span>{{ $page }}</span>
@else
<a class="page-link" href="{{ $url }}">{{ $page }}</a>
@endif
</li>
@endforeach
<li class="page-item {{ $categories->hasMorePages() ? '' : 'disabled' }}">
@if($categories->hasMorePages())
<a class="page-link" href="{{ $categories->nextPageUrl() }}" rel="next">&rsaquo;</a>
@else
<span>&rsaquo;</span>
@endif
</li>
</ul>
@endif
</div>
@endif
</div>
<script>
// Handle favorite button clicks
document.querySelectorAll('.favorite-button').forEach(button => {
button.addEventListener('click', async function(e) {
e.preventDefault();
e.stopPropagation();
const categoryId = this.getAttribute('data-category-id');
const isFavorited = this.classList.contains('favorited');
const url = isFavorited
? `/favorites/${categoryId}`
: `/favorites/${categoryId}`;
const method = isFavorited ? 'DELETE' : 'POST';
try {
const response = await fetch(url, {
method: method,
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
'Content-Type': 'application/json',
},
});
if (response.ok) {
this.classList.toggle('favorited');
}
} catch (error) {
console.error('Error:', error);
}
});
});
</script>
</body>
</html>