tampilan ui ux
This commit is contained in:
parent
bbec273eea
commit
4cd4abccd7
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\PaketFoto;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddPaketModal extends Component
|
||||
{
|
||||
public $search = '';
|
||||
public $pakets;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->loadPakets();
|
||||
}
|
||||
|
||||
public function loadPakets()
|
||||
{
|
||||
$this->pakets = PaketFoto::where('nama_paket_foto', 'like', '%' . $this->search . '%')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->loadPakets();
|
||||
}
|
||||
|
||||
public function addPaket($paketId)
|
||||
{
|
||||
$this->dispatch('paket-added', paketId: $paketId);
|
||||
$this->dispatch('close-modal');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.add-paket-modal');
|
||||
}
|
||||
}
|
|
@ -6,11 +6,16 @@
|
|||
use App\Models\Reservasii;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
#[Title('Booking - SiKolaself')]
|
||||
class BookingPage extends Component
|
||||
{
|
||||
public $paketfoto;
|
||||
public $selectedPakets = [];
|
||||
public $showModal = false;
|
||||
public $search = '';
|
||||
public $pakets;
|
||||
public $nama = '';
|
||||
public $tanggal = '';
|
||||
public $waktu = '';
|
||||
|
@ -27,13 +32,80 @@ public function mount($id = null)
|
|||
{
|
||||
if ($id) {
|
||||
$this->paketfoto = PaketFoto::findOrFail($id);
|
||||
$this->selectedPakets[] = [
|
||||
'id' => $this->paketfoto->id,
|
||||
'nama' => $this->paketfoto->nama_paket_foto,
|
||||
'harga' => $this->paketfoto->harga_paket_foto,
|
||||
'gambar' => $this->paketfoto->gambar,
|
||||
'warna' => ''
|
||||
];
|
||||
} else {
|
||||
$this->paketfoto = PaketFoto::first();
|
||||
}
|
||||
|
||||
// Set tanggal default ke hari ini
|
||||
$this->tanggal = now()->format('Y-m-d');
|
||||
$this->updateUnavailableTimes();
|
||||
$this->loadPakets();
|
||||
}
|
||||
|
||||
public function loadPakets()
|
||||
{
|
||||
$this->pakets = PaketFoto::where('nama_paket_foto', 'like', '%' . $this->search . '%')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function updatedSearch()
|
||||
{
|
||||
$this->loadPakets();
|
||||
}
|
||||
|
||||
#[On('paket-added')]
|
||||
public function handlePaketAdded($paketId)
|
||||
{
|
||||
$paket = PaketFoto::find($paketId);
|
||||
if ($paket) {
|
||||
// Cek apakah paket sudah ada di selectedPakets
|
||||
$exists = collect($this->selectedPakets)->contains('id', $paket->id);
|
||||
if (!$exists) {
|
||||
$this->selectedPakets[] = [
|
||||
'id' => $paket->id,
|
||||
'nama' => $paket->nama_paket_foto,
|
||||
'harga' => $paket->harga_paket_foto,
|
||||
'gambar' => $paket->gambar,
|
||||
'warna' => ''
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addPaket($paketId)
|
||||
{
|
||||
$paket = PaketFoto::find($paketId);
|
||||
if ($paket) {
|
||||
// Cek apakah paket sudah ada di selectedPakets
|
||||
$exists = collect($this->selectedPakets)->contains('id', $paket->id);
|
||||
if (!$exists) {
|
||||
$this->selectedPakets[] = [
|
||||
'id' => $paket->id,
|
||||
'nama' => $paket->nama_paket_foto,
|
||||
'harga' => $paket->harga_paket_foto,
|
||||
'gambar' => $paket->gambar,
|
||||
'warna' => ''
|
||||
];
|
||||
}
|
||||
}
|
||||
$this->showModal = false;
|
||||
}
|
||||
|
||||
public function removePaket($index)
|
||||
{
|
||||
unset($this->selectedPakets[$index]);
|
||||
$this->selectedPakets = array_values($this->selectedPakets);
|
||||
}
|
||||
|
||||
public function updatePaketWarna($index, $warna)
|
||||
{
|
||||
$this->selectedPakets[$index]['warna'] = $warna;
|
||||
}
|
||||
|
||||
public function updatedTanggal()
|
||||
|
@ -117,11 +189,11 @@ public function applyPromo()
|
|||
|
||||
public function getTotalPriceProperty()
|
||||
{
|
||||
$total = $this->paketfoto->harga_paket_foto;
|
||||
$total = collect($this->selectedPakets)->sum('harga');
|
||||
if ($this->promoApplied) {
|
||||
$total -= $this->promoDiscount;
|
||||
}
|
||||
return max(0, $total); // Pastikan total tidak negatif
|
||||
return max(0, $total);
|
||||
}
|
||||
|
||||
public function placeOrder()
|
||||
|
@ -133,6 +205,7 @@ public function placeOrder()
|
|||
'warna' => 'required',
|
||||
'promo' => '',
|
||||
'tipe_pembayaran' => 'required',
|
||||
'selectedPakets' => 'required|array|min:1',
|
||||
], [
|
||||
'nama.required' => 'Nama lengkap harus diisi',
|
||||
'nama.min' => 'Nama lengkap minimal 3 karakter',
|
||||
|
@ -141,15 +214,15 @@ public function placeOrder()
|
|||
'waktu.required' => 'Waktu booking harus dipilih',
|
||||
'warna.required' => 'Background harus dipilih',
|
||||
'tipe_pembayaran.required' => 'Tipe pembayaran harus dipilih',
|
||||
'selectedPakets.required' => 'Pilih minimal satu paket foto',
|
||||
'selectedPakets.min' => 'Pilih minimal satu paket foto',
|
||||
]);
|
||||
|
||||
// Validasi waktu yang dipilih
|
||||
if (in_array($this->waktu, $this->unavailableTimes)) {
|
||||
$this->addError('waktu', 'Waktu yang dipilih tidak tersedia');
|
||||
return;
|
||||
}
|
||||
|
||||
// Membuat reservasi baru
|
||||
$reservasi = Reservasii::create([
|
||||
'user_id' => auth()->id(),
|
||||
'nama' => $this->nama,
|
||||
|
@ -158,20 +231,20 @@ public function placeOrder()
|
|||
'promo_id' => $this->promoData ? $this->promoData->id : null,
|
||||
'total' => $this->totalPrice,
|
||||
'tipe_pembayaran' => $this->tipe_pembayaran,
|
||||
'metode_pembayaran' => 'transfer', // Default transfer, bisa diubah sesuai pilihan
|
||||
'metode_pembayaran' => 'transfer',
|
||||
'status_pembayaran' => 'pending'
|
||||
]);
|
||||
|
||||
// Membuat detail reservasi
|
||||
foreach ($this->selectedPakets as $paket) {
|
||||
$reservasi->detail()->create([
|
||||
'paket_foto_id' => $this->paketfoto->id,
|
||||
'paket_foto_id' => $paket['id'],
|
||||
'warna' => $this->warna,
|
||||
'jumlah' => 1,
|
||||
'harga' => $this->paketfoto->harga_paket_foto,
|
||||
'total_harga' => $this->totalPrice,
|
||||
'harga' => $paket['harga'],
|
||||
'total_harga' => $paket['harga'],
|
||||
]);
|
||||
}
|
||||
|
||||
// Tampilkan pesan sukses dan redirect ke halaman upload bukti pembayaran
|
||||
session()->flash('message', 'Booking berhasil dibuat! Silahkan upload bukti pembayaran.');
|
||||
return redirect()->route('upload.bukti.pembayaran', $reservasi->id);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class HomePage extends Component
|
|||
{
|
||||
public function render()
|
||||
{
|
||||
$paketfoto = PaketFoto::where('status', 1)->get();
|
||||
$paketfoto = PaketFoto::where('status', 1)->take(4)->get();
|
||||
return view('livewire.home-page', [
|
||||
'paketfoto' => $paketfoto
|
||||
]);
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
@if($showModal)
|
||||
<div class="fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
||||
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
||||
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div>
|
||||
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span>
|
||||
<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
|
||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mt-3 text-center sm:mt-0 sm:text-left w-full">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title">
|
||||
Tambah
|
||||
</h3>
|
||||
<div class="mt-4">
|
||||
<input type="text" wire:model.live="search" placeholder="Cari paket foto..." class="w-full rounded-lg border py-2 px-3 dark:bg-gray-700 dark:text-white dark:border-none">
|
||||
</div>
|
||||
<div class="mt-4 max-h-96 overflow-y-auto">
|
||||
<ul class="divide-y divide-gray-200">
|
||||
@forelse($pakets as $paket)
|
||||
<li class="py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<img src="{{ url('storage', $paket->gambar) }}" alt="{{ $paket->nama_paket_foto }}" class="w-12 h-12 rounded-full">
|
||||
<div class="ml-4">
|
||||
<p class="text-sm font-medium text-gray-900">{{ $paket->nama_paket_foto }}</p>
|
||||
<p class="text-sm text-gray-500">{{ Number::currency($paket->harga_paket_foto, 'IDR') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button wire:click="addPaket({{ $paket->id }})" class="bg-gray-500 text-white px-4 py-2 rounded-lg hover:bg-gray-600">
|
||||
Pilih
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
@empty
|
||||
<li class="py-3 text-center text-gray-500">
|
||||
Tidak ada paket ditemukan
|
||||
</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
|
||||
<button type="button" wire:click="$set('showModal', false)" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
|
||||
Tutup
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
|
@ -1,3 +1,4 @@
|
|||
<div>
|
||||
<div class="w-full max-w-[85rem] py-10 px-4 sm:px-6 lg:px-8 mx-auto">
|
||||
<h1 class="text-2xl font-bold text-gray-800 dark:text-white mb-4">
|
||||
Reservasi
|
||||
|
@ -161,11 +162,7 @@ class="{{ $isUnavailable ? 'text-gray-400 bg-gray-100' : '' }}"
|
|||
Subtotal
|
||||
</span>
|
||||
<span>
|
||||
@if($paketfoto)
|
||||
{{ Number::currency($paketfoto->harga_paket_foto, 'IDR') }}
|
||||
@else
|
||||
{{ Number::currency(0, 'IDR') }}
|
||||
@endif
|
||||
{{ Number::currency(collect($selectedPakets)->sum('harga'), 'IDR') }}
|
||||
</span>
|
||||
</div>
|
||||
@if($promoApplied)
|
||||
|
@ -193,36 +190,100 @@ class="{{ $isUnavailable ? 'text-gray-400 bg-gray-100' : '' }}"
|
|||
Reservasi Sekarang
|
||||
</button>
|
||||
<div class="bg-white mt-4 rounded-xl shadow p-4 sm:p-7 dark:bg-slate-900">
|
||||
<div class="text-xl font-bold underline text-gray-700 dark:text-white mb-2">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<div class="text-xl font-bold underline text-gray-700 dark:text-white">
|
||||
Paket Foto
|
||||
</div>
|
||||
<button type="button" wire:click="$set('showModal', true)" class="bg-gray-500 text-white px-4 py-2 rounded-lg hover:bg-gray-600">
|
||||
Tambah Paket
|
||||
</button>
|
||||
</div>
|
||||
<ul class="divide-y divide-gray-200 dark:divide-gray-700" role="list">
|
||||
@if($paketfoto)
|
||||
<li class="py-3 sm:py-4" wire:key="{{ $paketfoto->id }}">
|
||||
@forelse($selectedPakets as $index => $paket)
|
||||
<li class="py-3 sm:py-4" wire:key="{{ $paket['id'] }}">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<img alt="{{ $paketfoto->nama_paket_foto }}" class="w-12 h-12 rounded-full" src="{{ url('storage', $paketfoto->gambar) }}"> </img>
|
||||
<img alt="{{ $paket['nama'] }}" class="w-12 h-12 rounded-full" src="{{ url('storage', $paket['gambar']) }}">
|
||||
</div>
|
||||
<div class="flex-1 min-w-0 ms-4">
|
||||
<p class="text-sm font-medium text-gray-900 truncate dark:text-white">
|
||||
{{ $paketfoto->nama_paket_foto }}
|
||||
{{ $paket['nama'] }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="inline-flex items-center text-base font-semibold text-gray-900 dark:text-white">
|
||||
{{ Number::currency($paketfoto->harga_paket_foto, 'IDR') }}
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="text-base font-semibold text-gray-900 dark:text-white">
|
||||
{{ Number::currency($paket['harga'], 'IDR') }}
|
||||
</div>
|
||||
<button type="button" wire:click="removePaket({{ $index }})" class="text-red-500 hover:text-red-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@else
|
||||
@empty
|
||||
<li class="py-3 sm:py-4">
|
||||
<div class="flex items-center justify-center">
|
||||
<p class="text-sm text-gray-500">No package selected</p>
|
||||
<p class="text-sm text-gray-500">Belum ada paket dipilih</p>
|
||||
</div>
|
||||
</li>
|
||||
@endif
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@if($showModal)
|
||||
<div class="fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
|
||||
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
||||
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div>
|
||||
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">​</span>
|
||||
<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
|
||||
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||
<div class="sm:flex sm:items-start">
|
||||
<div class="mt-3 text-center sm:mt-0 sm:text-left w-full">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900" id="modal-title">
|
||||
Tambah Paket Foto
|
||||
</h3>
|
||||
<div class="mt-4">
|
||||
<input type="text" wire:model.live="search" placeholder="Cari paket foto..." class="w-full rounded-lg border py-2 px-3 dark:bg-gray-700 dark:text-white dark:border-none">
|
||||
</div>
|
||||
<div class="mt-4 max-h-96 overflow-y-auto">
|
||||
<ul class="divide-y divide-gray-200">
|
||||
@forelse($pakets as $paket)
|
||||
<li class="py-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<img src="{{ url('storage', $paket->gambar) }}" alt="{{ $paket->nama_paket_foto }}" class="w-12 h-12 rounded-full">
|
||||
<div class="ml-4">
|
||||
<p class="text-sm font-medium text-gray-900">{{ $paket->nama_paket_foto }}</p>
|
||||
<p class="text-sm text-gray-500">{{ Number::currency($paket->harga_paket_foto, 'IDR') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button wire:click="addPaket({{ $paket->id }})" class="bg-gray-500 text-white px-4 py-2 rounded-lg hover:bg-gray-600">
|
||||
Pilih
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
@empty
|
||||
<li class="py-3 text-center text-gray-500">
|
||||
Tidak ada paket ditemukan
|
||||
</li>
|
||||
@endforelse
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
|
||||
<button type="button" wire:click="$set('showModal', false)" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
|
||||
Tutup
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
Loading…
Reference in New Issue