465 lines
12 KiB
PHP
465 lines
12 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>Rekomendasi Mobil Sesuai Budget</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;
|
|
gap: 16px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 32px;
|
|
}
|
|
|
|
.page-header h1 {
|
|
margin: 0;
|
|
font-size: 2.2rem;
|
|
color: #111827;
|
|
}
|
|
|
|
.page-header p {
|
|
margin: 8px 0 0;
|
|
color: #475569;
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.back-button,
|
|
.button-primary {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
border: none;
|
|
border-radius: 999px;
|
|
padding: 14px 24px;
|
|
font-weight: 700;
|
|
text-decoration: none;
|
|
cursor: pointer;
|
|
transition: transform 0.2s ease, background 0.2s ease;
|
|
}
|
|
|
|
.back-button {
|
|
background: #ffffff;
|
|
color: #4338ca;
|
|
border: 1px solid #c7d2fe;
|
|
box-shadow: 0 12px 24px rgba(67, 56, 202, 0.08);
|
|
}
|
|
|
|
.button-primary {
|
|
background: #4338ca;
|
|
color: #ffffff;
|
|
box-shadow: 0 18px 40px rgba(67, 56, 202, 0.18);
|
|
}
|
|
|
|
.back-button:hover,
|
|
.button-primary:hover {
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.back-button:hover {
|
|
background: #eef2ff;
|
|
}
|
|
|
|
.button-primary:hover {
|
|
background: #3730a3;
|
|
}
|
|
|
|
.filter-panel {
|
|
padding: 24px;
|
|
background: #ffffff;
|
|
border-radius: 28px;
|
|
box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
|
|
display: grid;
|
|
grid-template-columns: 1fr auto;
|
|
gap: 20px;
|
|
align-items: end;
|
|
margin-bottom: 36px;
|
|
}
|
|
|
|
.filter-fields {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
gap: 16px;
|
|
}
|
|
|
|
.filter-panel label {
|
|
display: block;
|
|
margin-bottom: 10px;
|
|
font-weight: 800;
|
|
color: #111827;
|
|
}
|
|
|
|
.filter-panel input {
|
|
width: 100%;
|
|
padding: 16px;
|
|
border-radius: 16px;
|
|
border: 1px solid #d1d5db;
|
|
font-size: 1rem;
|
|
color: #111827;
|
|
min-height: 54px;
|
|
}
|
|
|
|
.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 p {
|
|
margin: 8px 0 0;
|
|
color: #475569;
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.section-heading span {
|
|
color: #6b7280;
|
|
font-size: 0.95rem;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.market-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
gap: 22px;
|
|
}
|
|
|
|
.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-image {
|
|
position: relative;
|
|
aspect-ratio: 4 / 3;
|
|
width: 100%;
|
|
background: #f8fafc;
|
|
display: grid;
|
|
place-items: 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-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: 8px;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
|
|
.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 {
|
|
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: 900px) {
|
|
.market-grid {
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
}
|
|
|
|
.filter-panel {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.filter-fields {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.page-shell {
|
|
padding: 24px 16px 48px;
|
|
}
|
|
|
|
.page-header h1 {
|
|
font-size: 1.75rem;
|
|
}
|
|
|
|
.market-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="page-shell">
|
|
<div class="page-header">
|
|
<div>
|
|
<h1>Rekomendasi Mobil Sesuai Budget</h1>
|
|
<p>Masukkan budget, tahun, dan mesin cc untuk melihat mobil bekas yang paling cocok untuk anda.</p>
|
|
</div>
|
|
<a href="{{ route('mobil-bekas') }}" class="back-button">← Kembali</a>
|
|
</div>
|
|
|
|
<form class="filter-panel" method="GET" action="{{ route('rekomendasi-budget') }}">
|
|
<div class="filter-fields">
|
|
<div>
|
|
<label for="budget">Budget Maksimal</label>
|
|
<input id="budget" type="number" name="budget" value="{{ old('budget', $budget) }}" min="0" step="1" />
|
|
</div>
|
|
<div>
|
|
<label for="year">Tahun Minimal</label>
|
|
<input id="year" type="number" name="year" value="{{ old('year', $year) }}" min="1900" max="{{ date('Y') }}" step="1" />
|
|
</div>
|
|
<div>
|
|
<label for="mesin_cc">Mesin CC</label>
|
|
<input id="mesin_cc" type="number" name="mesin_cc" value="{{ old('mesin_cc', $mesinCc) }}" min="0" step="1" />
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="button-primary">Cari Mobil</button>
|
|
</form>
|
|
|
|
@if(!$budget)
|
|
<div class="empty-state">
|
|
<h2>Masukkan budget terlebih dahulu.</h2>
|
|
<p>Tersedia {{ $availableCount }} mobil bekas yang bisa dicocokkan dengan budget Anda.</p>
|
|
</div>
|
|
@else
|
|
<div class="section-heading">
|
|
<div>
|
|
<h2>Hasil Rekomendasi Budget</h2>
|
|
</div>
|
|
<span>{{ $recommended->count() }} pilihan cocok</span>
|
|
</div>
|
|
|
|
@if($recommended->isEmpty())
|
|
<div class="empty-state">
|
|
<h2>Tidak ada mobil sesuai budget.</h2>
|
|
<p>Coba naikkan budget atau tambahkan listing mobil bekas baru di halaman admin.</p>
|
|
</div>
|
|
@else
|
|
<div class="market-grid">
|
|
@foreach($recommended 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>
|
|
<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>
|
|
@endif
|
|
@endif
|
|
</div>
|
|
|
|
<script>
|
|
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 method = isFavorited ? 'DELETE' : 'POST';
|
|
|
|
try {
|
|
const response = await fetch(`/favorites/${categoryId}`, {
|
|
method: method,
|
|
headers: {
|
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
this.classList.toggle('favorited');
|
|
} else {
|
|
alert(data.message || 'Gagal memperbarui favorit.');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error:', error);
|
|
alert(error.message || 'Terjadi kesalahan. Silakan coba lagi.');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|