Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding alert to cancel & success booking #72

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions resources/views/home/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<livewire:schedule-calendar :labs="$labs" />

@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>

Livewire.on('close-modal', function () {
Expand All @@ -32,12 +33,22 @@
});

Livewire.on('success-booking', function () {
const toasty = document.getElementById('static-example');
toasty.classList.replace('data-[te-toast-show]:hidden', 'data-[te-toast-show]:block')
// const toasty = document.getElementById('static-example');
// toasty.classList.replace('data-[te-toast-show]:hidden', 'data-[te-toast-show]:block')

setTimeout(() => {
toasty.classList.replace('data-[te-toast-show]:block', 'data-[te-toast-show]:hidden')
}, 5000);
// setTimeout(() => {
// toasty.classList.replace('data-[te-toast-show]:block', 'data-[te-toast-show]:hidden')
// }, 5000);

Swal.fire({
position: "top-end",
title: 'Success!',
text: 'Booking anda berhasil didaftarkan!.',
showConfirmButton: false,
timerProgressBar: true,
timer: 1500,
icon:'success',
})
});

</script>
Expand Down
39 changes: 35 additions & 4 deletions resources/views/livewire/booking-history.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class="text-left w-full bg-transparent px-4 py-2 text-sm font-normal text-neutra
<h1 class=" text-lg font-semibold mt-5 text-neutral-600 dark:text-neutral-200 ">Mendatang</h1>

@foreach ($upcomingHistories as $history)
<div class="block rounded-lg bg-white shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700 mt-3 w-full">
<div class="block rounded-lg bg-white shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] dark:bg-neutral-700 mt-3 w-full"
wire:key="{{ $history->id }}">
<div class="border-b-2 border-neutral-100 px-6 py-3 dark:border-neutral-600 dark:text-neutral-50 text-xl font-semibold ">
{{ $history->reason_to_booking }} | <span class="font-medium text-lg">R. {{ str_replace('Ruang ', '', $history->lab->name) }}</span>
</div>
Expand All @@ -96,11 +97,10 @@ class="text-left w-full bg-transparent px-4 py-2 text-sm font-normal text-neutra
{{ $history->start_time }} - {{ $history->end_time }}
</p>

<form action="{{ route('labs-booking.destroy', $history->id) }}" method="POST">
<form action="{{ route('labs-booking.destroy', $history->id) }}" method="POST" id="deleteForm">
@csrf
@method('delete')
<button type="submit" class="px-4 py-2 bg-red-500 font-semibold text-white text-sm rounded-md"
onclick="return confirm('Apakah anda yakin ingin membatalkan booking ini?')"
<button type="submit" class="px-4 py-2 bg-red-500 font-semibold text-white text-sm rounded-md" id="cancelBtn"
>Batalkan Peminjam</button></form>
</form>
</div>
Expand Down Expand Up @@ -131,6 +131,37 @@ class="text-left w-full bg-transparent px-4 py-2 text-sm font-normal text-neutra
{{ $loadAmount }}
<button wire:click="loadMore">Load More</button>

@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>

document.getElementById('cancelBtn').addEventListener('click', function(e){
e.preventDefault()
Swal.fire({
title: 'Apakah anda yakin?',
text: "untuk membatalkan peminjaman ruangan ini.",
icon: 'warning',
iconColor: '#172554',
showCancelButton: true,
confirmButtonColor: '#EF4444',
cancelButtonColor: '#172554',
confirmButtonText: 'Ya, Batalkan!'
}).then((result) => {
if (result.isConfirmed) {
document.getElementById('deleteForm').submit();
Swal.fire({
position: "top-end",
title: 'Cancelled!',
text: 'Booking anda berhasil dibatalkan.',
showConfirmButton: false,
timerProgressBar: true,
timer: 2000,
icon:'success',
})
}
})})
</script>
@endpush
</div>


4 changes: 2 additions & 2 deletions resources/views/livewire/schedule-calendar.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<div class="lg:overflow-visible overflow-x-scroll" id="contentScroll">
<div class="overflow-x-scroll max-w-full" id="contentScroll">
<table class="mt-[73px] mx-auto w-full">
<thead class="transition-shadow ease-in-out duration-300 bg-white" id="thead">
<thead class="transition-shadow ease-in-out duration-300 bg-white">
<tr class="sticky top-[73px] shadow-lg z-40">
<th class="py-2 border-r h-10 bg-blue-950 text-white">
Ruang
Expand Down
Loading