Browse Source

ready to live

master
yusmardianto 3 years ago
parent
commit
53139fd38b
5 changed files with 134 additions and 31 deletions
  1. +32
    -0
      api/Booking/booking.js
  2. +24
    -23
      components/Booking/checkout.js
  3. +4
    -2
      package.json
  4. +3
    -4
      pages/review.js
  5. +71
    -2
      yarn.lock

+ 32
- 0
api/Booking/booking.js View File

@@ -76,7 +76,39 @@ async function getReview(transactionID, token="") {
return res;
}

async function getReviewPayment(transactionID, token="") {
var res = await apollo.query(
`
query($input: ID!) {
booking(transactionID:$input) {
id
transactionID
namaPemesan
emailPemesan
teleponPemesan
pemesan
checkIn
checkOut
jumlahPengunjung
namaKamar
requestKamar
hargaKamar
ppnKamar
hargaTotal
catatan
}
}
`,
token,
{
"input": transactionID
}
);
return res;
}

module.exports = {
getReviewPayment: getReviewPayment,
AddBooking: AddBooking,
getReview: getReview,
};

+ 24
- 23
components/Booking/checkout.js View File

@@ -7,24 +7,33 @@ 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('');

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;
}
var [TglCheckIn, setCheckIn] = useState('');
var [TglCheckOut, setCheckOut] = useState('');

const UUID = CreateID(10);
console.log("hasil : ", UUID);
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,
@@ -40,7 +49,7 @@ const Checkout = function ({ backend, checkoutItem, ...props }) {
hargaKamar: "",
namaKamar: "",
ppnKamar: 0.1,
hargaTotal: checkoutItem[0].hargaKamar + checkoutItem[0].hargaKamar * 0.1,
hargaTotal: "",
});

const disablePastDate = () => {
@@ -51,15 +60,6 @@ const Checkout = function ({ backend, checkoutItem, ...props }) {
return yyyy + "-" + mm + "-" + dd;
};

const [TglCheckIn, setCheckIn] = useState('');
const [TglCheckOut, setCheckOut] = useState('');

const date = (new Date(TglCheckIn)).getTime();
const today = (new Date(TglCheckOut)).getTime();
const msDay = 24 * 60 * 60 * 1000;

const days = Math.floor((today - date) / msDay);

const Router = useRouter();

return (
@@ -85,6 +85,7 @@ const Checkout = function ({ backend, checkoutItem, ...props }) {
...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));
@@ -306,7 +307,7 @@ const Checkout = function ({ backend, checkoutItem, ...props }) {
<div className="form-check">
<input
name="requestKamar"
type="checkbox"
type="radio"
className="form-check-input"
value={option.namaFasilitas}
onInput={(e) => {


+ 4
- 2
package.json View File

@@ -14,14 +14,16 @@
"@emotion/react": "^11.6.0",
"@emotion/styled": "^11.6.0",
"@mui/material": "^5.1.1",
"@nextui-org/react": "^1.0.1-alpha.57",
"animate.css": "^4.1.1",
"axios": "^0.21.1",
"cross-fetch": "^3.1.4",
"dotenv": "^10.0.0",
"formik": "^2.2.9",
"graphql": "^16.0.1",
"next": "^10.0.7",
"midtrans-client": "^1.2.3",
"midtrans-payment": "^1.2.7",
"next": "^10.0.7",
"nodemailer": "^6.5.0",
"nodemailer-sendgrid-transport": "^0.2.0",
"react": "^17.0.1",
@@ -46,4 +48,4 @@
"sweetalert2-react-content": "^3.3.1"
},
"license": "MIT"
}
}

+ 3
- 4
pages/review.js View File

@@ -30,7 +30,7 @@ export async function getServerSideProps(context) {
}

// midtrans
var parameters = await GetReviewItem.getReview();
var parameters = await GetReviewItem.getReview(query.s || 0);
console.log("parameters", parameters);
var transactionToken = [];
if (parameters["STATUS"] === 1) {
@@ -42,16 +42,15 @@ export async function getServerSideProps(context) {
});
let parameter = {
"transaction_details": {
// "order_id": parameters["DATA"]["bookings"][0]["NamaPemesan"],
"order_id": parameters["DATA"]["bookings"][0]["transactionID"],
"gross_amount": parameters["DATA"]["bookings"][0]["hargaTotal"],
"order_id":"Trx-Ord-2545343543",
// "gross_amount":33750000,
}, "credit_card": {
"secure": true
},
"customer_details": {
"first_name": parameters["DATA"]["bookings"][0]["namaPemesan"],
"phone": parameters["DATA"]["bookings"][0]["teleponPemesan"],
"email": parameters["DATA"]["bookings"][0]["emailPemesan"],
// "first_name":"Yusmar",
// "phone":"087797315685",
"billing_address":


+ 71
- 2
yarn.lock View File

@@ -46,7 +46,7 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz#5ac822ce97eec46741ab70a517971e443a70c5a9"
integrity sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ==

"@babel/helper-validator-identifier@^7.15.7":
"@babel/helper-validator-identifier@^7.14.9", "@babel/helper-validator-identifier@^7.15.7":
version "7.15.7"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz#220df993bfe904a4a6b02ab4f3385a5ebf6e2389"
integrity sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==
@@ -60,6 +60,13 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/plugin-syntax-jsx@7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.14.5.tgz#000e2e25d8673cce49300517a3eda44c263e4201"
integrity sha512-ohuFIsOMXJnbOMRfX7/w7LocdR6R7whhuRD4ax8IipLcLPlZGJKkBxgHp++U4N/vKyU16/YDQr2f5seajD3jIw==
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"

"@babel/plugin-syntax-jsx@^7.12.13":
version "7.16.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.16.0.tgz#f9624394317365a9a88c82358d3f8471154698f1"
@@ -81,6 +88,14 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/types@7.15.0":
version "7.15.0"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.0.tgz#61af11f2286c4e9c69ca8deb5f4375a73c72dcbd"
integrity sha512-OBvfqnllOIdX4ojTHpwZbpvz4j3EWyjkZEdmjH0/cgsd6QOdSgU8rLSk6ard/pcW7rlmjdVSX/AWOaORR1uNOQ==
dependencies:
"@babel/helper-validator-identifier" "^7.14.9"
to-fast-properties "^2.0.0"

"@babel/types@7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.8.3.tgz#5a383dffa5416db1b73dedffd311ffd0788fb31c"
@@ -397,6 +412,13 @@
resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-10.2.3.tgz#2f3e42fe6680798f276e3621345c2886b231348b"
integrity sha512-qtBF56vPC6d6a8p7LYd0iRjW89fhY80kAIzmj+VonvIGjK/nymBjcFUhbKiMFqlhsarCksnhwX+Zmn95Dw9qvA==

"@nextui-org/react@^1.0.1-alpha.57":
version "1.0.1-alpha.57"
resolved "https://registry.yarnpkg.com/@nextui-org/react/-/react-1.0.1-alpha.57.tgz#814fd7a9f1ac079408f67d3a5012ba0ab8e11996"
integrity sha512-Z1g35WjuDPaVcWIr2QifygeIDGUSlzmjHpmZj41YI0nisnEoJvkct0DGhimP/UvF9pTHL933fh+ow5o0FJgoIg==
dependencies:
styled-jsx "^4.0.1"

"@opentelemetry/api@0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-0.14.0.tgz#4e17d8d2f1da72b19374efa7b6526aa001267cae"
@@ -1303,6 +1325,11 @@ deep-is@~0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831"
integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==

deepmerge@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.2.1.tgz#5d3ff22a01c00f645405a2fbc17d0778a1801170"
integrity sha512-R9hc1Xa/NOBi9WRVUWg19rl1UB7Tt4kuPd+thNJgFZoxXsTz7ncaPaeIm+40oSGuP33DfMb4sZt1QIGiJzC4EA==

define-properties@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1"
@@ -1746,6 +1773,19 @@ form-data@~2.3.2:
combined-stream "^1.0.6"
mime-types "^2.1.12"

formik@^2.2.9:
version "2.2.9"
resolved "https://registry.yarnpkg.com/formik/-/formik-2.2.9.tgz#8594ba9c5e2e5cf1f42c5704128e119fc46232d0"
integrity sha512-LQLcISMmf1r5at4/gyJigGn0gOwFbeEAlji+N9InZF6LIMXnFNkO42sCI8Jt84YZggpD4cPWObAZaxpEFtSzNA==
dependencies:
deepmerge "^2.1.1"
hoist-non-react-statics "^3.3.0"
lodash "^4.17.21"
lodash-es "^4.17.21"
react-fast-compare "^2.0.1"
tiny-warning "^1.0.2"
tslib "^1.10.0"

fs-extra@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd"
@@ -2375,7 +2415,7 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"

lodash-es@^4.2.1:
lodash-es@^4.17.21, lodash-es@^4.2.1:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==
@@ -3010,6 +3050,11 @@ react-dom@^17.0.1:
object-assign "^4.1.1"
scheduler "^0.20.2"

react-fast-compare@^2.0.1:
version "2.0.4"
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"
integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==

react-feather@^2.0.9:
version "2.0.9"
resolved "https://registry.yarnpkg.com/react-feather/-/react-feather-2.0.9.tgz#6e42072130d2fa9a09d4476b0e61b0ed17814480"
@@ -3527,6 +3572,20 @@ styled-jsx@3.3.2:
stylis "3.5.4"
stylis-rule-sheet "0.0.10"

styled-jsx@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-4.0.1.tgz#ae3f716eacc0792f7050389de88add6d5245b9e9"
integrity sha512-Gcb49/dRB1k8B4hdK8vhW27Rlb2zujCk1fISrizCcToIs+55B4vmUM0N9Gi4nnVfFZWe55jRdWpAqH1ldAKWvQ==
dependencies:
"@babel/plugin-syntax-jsx" "7.14.5"
"@babel/types" "7.15.0"
convert-source-map "1.7.0"
loader-utils "1.2.3"
source-map "0.7.3"
string-hash "1.1.3"
stylis "3.5.4"
stylis-rule-sheet "0.0.10"

stylis-rule-sheet@0.0.10:
version "0.0.10"
resolved "https://registry.yarnpkg.com/stylis-rule-sheet/-/stylis-rule-sheet-0.0.10.tgz#44e64a2b076643f4b52e5ff71efc04d8c3c4a430"
@@ -3613,6 +3672,11 @@ timers-browserify@2.0.12, timers-browserify@^2.0.4:
dependencies:
setimmediate "^1.0.4"

tiny-warning@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754"
integrity sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==

to-arraybuffer@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43"
@@ -3677,6 +3741,11 @@ ts-pnp@^1.1.6:
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==

tslib@^1.10.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.1.0, tslib@^2.3.0:
version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"


Loading…
Cancel
Save