import React, { useState } from 'react'; import * as Icon from 'react-feather'; import { useRouter } from 'next/router' import NumberFormat from 'react-number-format'; //sweet alert import swal from 'sweetalert'; function CreateID(length) { var result = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; var charactersLength = characters.length; for (var i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } const UUID = CreateID(10); // console.log("hasil : ", UUID); const Checkout = function ({ backend, checkoutItem, ...props }) { // const [HargaFasilitas, setHargaFasilitas] = useState(''); // const [NamaFasilitas, setNamaFasilitas] = useState(''); var [TglCheckIn, setCheckIn] = useState(''); var [TglCheckOut, setCheckOut] = useState(''); var date = (new Date(TglCheckIn)).getTime(); var today = (new Date(TglCheckOut)).getTime(); const msDay = 24 * 60 * 60 * 1000; var days = Math.floor((today - date) / msDay); const [formValue, setFormValue] = React.useState({ transactionID: UUID, namaPemesan: "", emailPemesan: "", teleponPemesan: "", pemesan: "", checkIn: "", checkOut: "", jumlahPengunjung: "", requestKamar: "", catatan: "", hargaKamar: "", namaKamar: "", ppnKamar: 0.1, hargaTotal: "", }); const disablePastDate = () => { const today = new Date(); const dd = String(today.getDate() + 1).padStart(2, "0"); const mm = String(today.getMonth() + 1).padStart(2, "0"); const yyyy = today.getFullYear(); return yyyy + "-" + mm + "-" + dd; }; const Router = useRouter(); return ( <>

Important Notice


As COVID-19 situation evolves, make sure the cancellation policy suits your needs.
In reference to the circular letter by the government regarding the spread control of Covid-19, please ensure that you are aware of your booking's refund, cancellation, and reschedule policy.

{ e.preventDefault(); var newformValue = { ...formValue, namaKamar: checkoutItem[0].namaKamar, hargaKamar: checkoutItem[0].hargaKamar, hargaTotal: checkoutItem[0].hargaKamar * days + checkoutItem[0].hargaKamar * days * 0.1, } setFormValue(newformValue) // console.log(JSON.stringify(newformValue)); const response = await fetch( "/api/Booking/CreateBooking", { method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(newformValue), } ); // console.log("response :", response); if (response.ok) { var res = await response.json(); // console.log("cek response :", res); if (res["STATUS"] === 1) { res["DATA"]["booking"]; swal("Produk Berhasil Ditambah ke Keranjang", "Silahkan Cek Keranjang Belanja Anda", "success"); Router.push({ pathname: '/review', query: { s: UUID } }) } else { swal("Produk Gagal Ditambah ke Keranjang", "Silahkan Coba Lagi", "error"); } } else { swal("Transaksi Gagal", "Silahkan Coba Lagi", "error"); } return false; }} >

Masukan Informasi Pemesan

{ setFormValue({ ...formValue, namaPemesan: e.target.value.toString(), }) }} />
{ setFormValue({ ...formValue, emailPemesan: e.target.value.toString(), }) }} />
{ setFormValue({ ...formValue, teleponPemesan: e.target.value.toString(), }) }} />

Catania {checkoutItem[0].namaKamar}

Fasilitas :

Free Wifi

Telepon


setCheckIn(e.target.value)} onInput={(e) => { setFormValue({ ...formValue, checkIn: e.target.value, }) }} />
setCheckOut(e.target.value)} onInput={(e) => { setFormValue({ ...formValue, checkOut: e.target.value, }) }} />

Permintaan Khusus Untuk Kamar

{checkoutItem[0]["fasilitas_kamars"].map((option) => (
{ setFormValue({ ...formValue, requestKamar: e.target.value.toString(), }) }} />
))}

Total Pesanan

Jenis Kamar Total
Catania {checkoutItem[0].namaKamar}
Total Hari {days} Hari
Pajak 10%
Total
) } export default Checkout;