242 lines
6.3 KiB
PHP
242 lines
6.3 KiB
PHP
<style>
|
||
.page-wrapper {
|
||
display: flex;
|
||
min-height: 100vh;
|
||
font-family: sans-serif;
|
||
}
|
||
|
||
/* Sidebar */
|
||
.sidebar {
|
||
width: 200px;
|
||
background: #fff;
|
||
border-right: 1px solid #000;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.sidebar-header {
|
||
padding: 16px;
|
||
font-size: 18px;
|
||
border-bottom: 1px solid #000;
|
||
}
|
||
|
||
.sidebar-item {
|
||
padding: 16px;
|
||
border-bottom: 1px solid #000;
|
||
text-align: center;
|
||
}
|
||
|
||
.sidebar-img {
|
||
width: 80px;
|
||
height: 80px;
|
||
object-fit: cover;
|
||
box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.2);
|
||
}
|
||
|
||
.sidebar-text {
|
||
font-size: 12px;
|
||
margin-top: 6px;
|
||
color: #444;
|
||
}
|
||
|
||
/* Main Content */
|
||
.content {
|
||
flex: 1;
|
||
padding: 24px;
|
||
background: #f5f5f5;
|
||
}
|
||
|
||
.food-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||
gap: 20px;
|
||
}
|
||
|
||
.food-card {
|
||
background: #fff;
|
||
border: 1px solid #ddd;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.food-img {
|
||
width: 100%;
|
||
height: 150px;
|
||
object-fit: cover;
|
||
}
|
||
|
||
.food-body {
|
||
padding: 12px;
|
||
}
|
||
|
||
.food-title {
|
||
font-size: 16px;
|
||
margin: 0 0 8px;
|
||
}
|
||
|
||
.food-price {
|
||
color: #666;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.food-input {
|
||
width: 100%;
|
||
padding: 6px;
|
||
border: 1px solid #ccc;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
/* Cart Modal */
|
||
.cart-modal {
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background: rgba(0, 0, 0, 0.4);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
z-index: 1000;
|
||
}
|
||
|
||
.cart-box {
|
||
background: white;
|
||
padding: 24px;
|
||
width: 90%;
|
||
max-width: 400px;
|
||
border-radius: 6px;
|
||
position: relative;
|
||
}
|
||
|
||
.cart-close {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 14px;
|
||
background: none;
|
||
border: none;
|
||
font-size: 24px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.cart-item {
|
||
display: flex;
|
||
gap: 12px;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.cart-item img {
|
||
width: 60px;
|
||
height: 60px;
|
||
object-fit: cover;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.cart-button {
|
||
margin-top: 24px;
|
||
padding: 10px 16px;
|
||
background: black;
|
||
color: white;
|
||
border: none;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
}
|
||
</style>
|
||
|
||
{{-- Content with sidebar --}}
|
||
<div class="page-wrapper">
|
||
<aside class="sidebar">
|
||
<div class="sidebar-header">DFOOD</div>
|
||
|
||
<div class="sidebar-item">
|
||
<img src="https://storage.googleapis.com/a1aa/image/0f402ec1-07d3-4638-73a2-283040ae99f2.jpg" alt="Promo"
|
||
class="sidebar-img">
|
||
<div class="sidebar-text">Limited Promo</div>
|
||
</div>
|
||
|
||
<div class="sidebar-item">
|
||
<img src="https://storage.googleapis.com/a1aa/image/0f402ec1-07d3-4638-73a2-283040ae99f2.jpg" alt="Makanan"
|
||
class="sidebar-img">
|
||
<div class="sidebar-text">Makanan</div>
|
||
</div>
|
||
|
||
<div class="sidebar-item">
|
||
<img src="https://storage.googleapis.com/a1aa/image/0f402ec1-07d3-4638-73a2-283040ae99f2.jpg" alt="Minuman"
|
||
class="sidebar-img">
|
||
<div class="sidebar-text">Minuman</div>
|
||
</div>
|
||
</aside>
|
||
|
||
<!-- Food Items Grid -->
|
||
<main class="content">
|
||
<div class="food-grid">
|
||
@foreach ($this->foodItems as $food)
|
||
<div class="food-card">
|
||
<img src="{{ $food['image_url'] }}" alt="{{ $food['name'] }}" class="food-img">
|
||
<div class="food-body">
|
||
<h3 class="food-title">{{ $food['name'] }}</h3>
|
||
<p class="food-price">Rp{{ number_format($food['price'], 0, ',', '.') }}</p>
|
||
<input type="number" min="0" wire:model="cart.{{ $food['id'] }}" class="food-input"
|
||
placeholder="Qty">
|
||
</div>
|
||
</div>
|
||
@endforeach
|
||
</div>
|
||
|
||
<button class="cart-button" wire:click="openCart">Lihat Keranjang</button>
|
||
|
||
@if ($showCart)
|
||
<div class="cart-modal">
|
||
<div class="cart-box">
|
||
<button class="cart-close" wire:click="closeCart">×</button>
|
||
<h2>Keranjang Anda</h2>
|
||
@forelse ($cartItems as $item)
|
||
<div class="cart-item">
|
||
<img src="{{ $item['image_url'] }}" alt="{{ $item['name'] }}">
|
||
<div>
|
||
<strong>{{ $item['name'] }}</strong><br>
|
||
Qty: {{ $item['qty'] }} <br>
|
||
Total: Rp{{ number_format($item['total_price'], 0, ',', '.') }}
|
||
</div>
|
||
</div>
|
||
@empty
|
||
<p>Keranjang kosong</p>
|
||
@endforelse
|
||
|
||
<hr>
|
||
<p><strong>Total: Rp{{ number_format($cartTotal, 0, ',', '.') }}</strong></p>
|
||
|
||
<button wire:click="checkout">Checkout</button>
|
||
</div>
|
||
</div>
|
||
@endif
|
||
</main>
|
||
</div>
|
||
|
||
{{-- Midtrans snap token trigger --}}
|
||
<script src="https://app.sandbox.midtrans.com/snap/snap.js" data-client-key="{{ config('services.midtrans.client_key') }}"></script>
|
||
<script>
|
||
window.addEventListener('midtransSnapToken', event => {
|
||
const token = event.detail.token;
|
||
snap.pay(token, {
|
||
onSuccess: function(result) {
|
||
Livewire.dispatch('paymentSuccess', result);
|
||
},
|
||
onPending: function(result) {
|
||
Livewire.dispatch('paymentSuccess', result);
|
||
},
|
||
onError: function(result) {
|
||
alert('Error: ' + result.status_message);
|
||
},
|
||
onClose: function() {
|
||
console.log('Customer closed the payment popup without finishing the payment');
|
||
}
|
||
});
|
||
});
|
||
|
||
window.addEventListener('notify', event => {
|
||
alert(event.detail.message);
|
||
});
|
||
</script>
|
||
|