diff --git a/client/package-lock.json b/client/package-lock.json index 58eac06..9943bab 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -3396,6 +3396,11 @@ "strip-eof": "1.0.0" } }, + "exenv": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz", + "integrity": "sha1-KueOhdmJQVhnCwPUe+wfA72Ru50=" + }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -8403,6 +8408,32 @@ } } }, + "react-lifecycles-compat": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", + "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" + }, + "react-modal": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.5.1.tgz", + "integrity": "sha512-GxL7ycOgKC+p641cR+V1bw5dC1faL2N86/AJlzbMVmvt1totoylgkJmn9zvLuHeuarGbB7CLfHMGpeRowaj2jQ==", + "requires": { + "exenv": "1.2.2", + "prop-types": "15.6.2", + "react-lifecycles-compat": "3.0.4", + "warning": "3.0.0" + }, + "dependencies": { + "warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", + "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", + "requires": { + "loose-envify": "1.4.0" + } + } + } + }, "react-router": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz", diff --git a/client/package.json b/client/package.json index 1d0ca86..54ba96f 100644 --- a/client/package.json +++ b/client/package.json @@ -6,6 +6,7 @@ "react": "^16.4.1", "react-dom": "^16.4.1", "react-google-maps": "^9.4.5", + "react-modal": "^3.5.1", "react-router-dom": "^4.3.1", "react-scripts": "1.1.4" }, diff --git a/client/src/components/Button/button.css b/client/src/components/Button/button.css index 3498276..4501395 100644 --- a/client/src/components/Button/button.css +++ b/client/src/components/Button/button.css @@ -30,4 +30,19 @@ height: 50px; margin-top: 20px; } + .customer-btn-check-style{ + background-color: #4F5352; + border: none; + color: #313232; + font-weight: bold; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 19px; + cursor: pointer; + border-radius: 7px; + width: 150px; + height: 50px; + margin-top: 10px; + } } diff --git a/client/src/components/Input/input.css b/client/src/components/Input/input.css index 4387987..f59dde1 100644 --- a/client/src/components/Input/input.css +++ b/client/src/components/Input/input.css @@ -106,4 +106,8 @@ background-image: url(/assets/imgs/flightno.png); background-size: 17px; } + .phone-img { + background-image: url(/assets/imgs/phone.png); + background-size: 17px; + } } diff --git a/client/src/pages/customer-pages/Home/home.css b/client/src/pages/customer-pages/Home/home.css index 3188225..29b614d 100644 --- a/client/src/pages/customer-pages/Home/home.css +++ b/client/src/pages/customer-pages/Home/home.css @@ -18,4 +18,14 @@ margin-bottom: 40px; font-weight: normal; } + .customer-modal-subtitle { + font-size: 20px; + font-family: 'Voces'; + margin-bottom: 30px; + } + .update-image { + width: 40px; + height: 40px; + margin-bottom: 10px; + } } diff --git a/client/src/pages/customer-pages/Home/index.js b/client/src/pages/customer-pages/Home/index.js index 84094ed..33c1462 100644 --- a/client/src/pages/customer-pages/Home/index.js +++ b/client/src/pages/customer-pages/Home/index.js @@ -1,5 +1,6 @@ import React, { Component } from "react"; import SweetAlert from "react-bootstrap-sweetalert"; +import Modal from "react-modal"; import { Input, @@ -9,12 +10,68 @@ import { } from "../../../components"; import "./home.css"; +const customStyles = { + content: { + top: "50%", + left: "50%", + right: "auto", + bottom: "auto", + marginRight: "-50%", + transform: "translate(-50%, -50%)", + width: "300px", + height: "400px", + background: "#5A9389" + } +}; + +Modal.setAppElement("#root"); class Home extends Component { state = { textInputValueFlightNo: "", - checkboxValue: true, + textInputValuepPhone: "", + checkboxValue: false, isAvailable: false, - alert: null + alert: null, + modalIsOpen: false + }; + + openModal = () => { + this.setState({ modalIsOpen: true }); + }; + + afterOpenModal = () => { + // references are now sync'd and can be accessed. + // this.subtitle.style.color = "#0f0"; + }; + + closeModal = () => { + const { textInputValuepPhone } = this.state; + if (textInputValuepPhone !== "") { + const data = JSON.stringify({ + textInputValuepPhone + }); + fetch("/api/v1/check_phone", { + credentials: "same-origin", + headers: { + "content-type": "application/json" + }, + method: "POST", + body: data + }) + .then(response => response.json(data)) + .then(data => { + if (data.isAvailable) { + this.setState({ modalIsOpen: false }); + } else { + this.invalidFlightNoAlert("Invalied Phone no.!"); + } + }) + .catch(err => { + console.log("There has been an error ", err); + }); + } else { + this.invalidFlightNoAlert("Invalied Phone no.!"); + } }; handleNoInputChange = e => { @@ -22,6 +79,11 @@ class Home extends Component { textInputValueFlightNo: e.target.value }); }; + handlePhoneInputChange = e => { + this.setState({ + textInputValuepPhone: e.target.value + }); + }; handlecheckboxChange = () => { this.setState({ @@ -29,7 +91,7 @@ class Home extends Component { }); }; - invalidFlightNoAlert = () => { + invalidFlightNoAlert = msg => { const getAlert = () => ( this.hideAlert()} > - Invalied Flight no.! + {msg} ); @@ -55,39 +117,101 @@ class Home extends Component { handleCheck = e => { e.preventDefault(); - const { textInputValueFlightNo } = this.state; - console.log(textInputValueFlightNo); - const data = JSON.stringify({ - textInputValueFlightNo - }); - fetch("/api/v1/check_flight", { - credentials: "same-origin", - headers: { - "content-type": "application/json" - }, - method: "POST", - body: data - }) - .then(response => response.json(data)) - .then(data => { - sessionStorage.setItem("flight_no", data.flight_no); - console.log(data.flight_no); + const { + textInputValueFlightNo, + textInputValuepPhone, + checkboxValue + } = this.state; - if (data.isAvailable) { - this.setState({ - isAvailable: true + if (checkboxValue === false) { + if (textInputValueFlightNo !== "") { + const data = JSON.stringify({ + textInputValueFlightNo + }); + fetch("/api/v1/check_flight", { + credentials: "same-origin", + headers: { + "content-type": "application/json" + }, + method: "POST", + body: data + }) + .then(response => response.json(data)) + .then(data => { + sessionStorage.setItem("flight_no", data.flight_no); + if (data.isAvailable) { + this.setState({ + isAvailable: true + }); + data.isAvailable && (window.location = "/flightinfo"); + } else { + this.setState({ + isAvailable: false + }); + this.invalidFlightNoAlert("Invalied Flight no.!"); + } + }) + .catch(err => { + console.log("There has been an error ", err); }); - data.isAvailable && (window.location = "/flightinfo"); - } else { - this.setState({ - isAvailable: false + } else { + this.invalidFlightNoAlert("Invalied Flight no.!"); + } + } else { + if (textInputValuepPhone === "") { + this.openModal(); + } else { + const data1 = JSON.stringify({ + textInputValuepPhone + }); + fetch("/api/v1/update_customer", { + credentials: "same-origin", + headers: { + "content-type": "application/json" + }, + method: "POST", + body: data1 + }) + .then(response => response.json(data1)) + .then(data => { + if (data.isAvailable) { + if (textInputValueFlightNo !== "") { + const data = JSON.stringify({ + textInputValueFlightNo + }); + fetch("/api/v1/check_flight", { + credentials: "same-origin", + headers: { + "content-type": "application/json" + }, + method: "POST", + body: data + }) + .then(response => response.json(data)) + .then(data => { + sessionStorage.setItem("flight_no", data.flight_no); + if (data.isAvailable) { + this.setState({ + isAvailable: true + }); + data.isAvailable && (window.location = "/flightinfo"); + } else { + this.setState({ + isAvailable: false + }); + this.invalidFlightNoAlert("Invalied Flight no.!"); + } + }) + .catch(err => { + console.log("There has been an error ", err); + }); + } else { + this.invalidFlightNoAlert("Invalied Flight no.!"); + } + } }); - this.invalidFlightNoAlert(); - } - }) - .catch(err => { - console.log("There has been an error ", err); - }); + } + } }; render() { @@ -121,10 +245,37 @@ class Home extends Component { type="checkbox" onTextInputChange={this.handlecheckboxChange} /> - + {/* onClick={this.openModal} */} + + + update +
+ To be in update just
enter your phone +
+ + - +
); } diff --git a/package-lock.json b/package-lock.json index 424ba89..1042332 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,7 +56,6 @@ "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", - "dev": true, "requires": { "co": "4.6.0", "fast-deep-equal": "1.1.0", @@ -187,6 +186,24 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "requires": { + "safer-buffer": "2.1.2" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", @@ -204,12 +221,27 @@ "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=" }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, "atob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", "dev": true }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + }, "axobject-query": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.0.1.tgz", @@ -1057,6 +1089,15 @@ } } }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, "bcryptjs": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", @@ -1241,6 +1282,11 @@ "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", "dev": true }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -1350,8 +1396,7 @@ "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" }, "collection-visit": { "version": "1.0.0", @@ -1376,6 +1421,14 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=" }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "1.0.0" + } + }, "commander": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", @@ -1580,6 +1633,14 @@ "integrity": "sha1-AxkcQyy27qFou3fzpV/9zLiXhRQ=", "dev": true }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "1.0.0" + } + }, "date-fns": { "version": "1.29.0", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz", @@ -1685,11 +1746,21 @@ } } }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" }, + "deprecate": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/deprecate/-/deprecate-1.0.0.tgz", + "integrity": "sha1-ZhSQ7SQokWpsiIPYg05WRvTkpKg=" + }, "destroy": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", @@ -1738,6 +1809,16 @@ "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", "dev": true }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "optional": true, + "requires": { + "jsbn": "0.1.1", + "safer-buffer": "2.1.2" + } + }, "ecdsa-sig-formatter": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz", @@ -2274,6 +2355,11 @@ } } }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, "extend-shallow": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", @@ -2371,11 +2457,15 @@ } } }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, "fast-deep-equal": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" }, "fast-diff": { "version": "1.1.2", @@ -2386,8 +2476,7 @@ "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, "fast-levenshtein": { "version": "2.0.6", @@ -2499,6 +2588,21 @@ "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", "dev": true }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.6", + "mime-types": "2.1.19" + } + }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", @@ -2569,6 +2673,14 @@ "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", "dev": true }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "1.0.0" + } + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -2697,6 +2809,20 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" + }, + "har-validator": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz", + "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==", + "requires": { + "ajv": "5.5.2", + "har-schema": "2.0.0" + } + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -2789,6 +2915,16 @@ "statuses": "1.4.0" } }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "requires": { + "assert-plus": "1.0.0", + "jsprim": "1.4.1", + "sshpk": "1.14.2" + } + }, "iconv-lite": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", @@ -3170,6 +3306,11 @@ "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", "dev": true }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -3193,6 +3334,11 @@ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, "jest-docblock": { "version": "21.2.0", "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz", @@ -3214,6 +3360,12 @@ "esprima": "4.0.1" } }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, "jsesc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", @@ -3224,11 +3376,15 @@ "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, "json-schema-traverse": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", @@ -3236,6 +3392,11 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", @@ -3264,6 +3425,17 @@ } } }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, "jsx-ast-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", @@ -3695,6 +3867,11 @@ "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -4012,6 +4189,11 @@ "through": "2.3.8" } }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" + }, "pg": { "version": "7.4.3", "resolved": "https://registry.npmjs.org/pg/-/pg-7.4.3.tgz", @@ -4115,6 +4297,11 @@ "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", "dev": true }, + "pop-iterate": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pop-iterate/-/pop-iterate-1.0.1.tgz", + "integrity": "sha1-zqz9q0q/NT16DyqqLB/Hs/lBO6M=" + }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", @@ -4218,6 +4405,11 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, + "psl": { + "version": "1.1.29", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz", + "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==" + }, "pstree.remy": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.0.tgz", @@ -4227,6 +4419,21 @@ "ps-tree": "1.1.0" } }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "q": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/q/-/q-2.0.3.tgz", + "integrity": "sha1-dbjbAlWhpa+C9Yw/Oqoe/sfQ0TQ=", + "requires": { + "asap": "2.0.6", + "pop-iterate": "1.0.1", + "weak-map": "1.0.5" + } + }, "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", @@ -4471,6 +4678,45 @@ "is-finite": "1.0.2" } }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "requires": { + "aws-sign2": "0.7.0", + "aws4": "1.8.0", + "caseless": "0.12.0", + "combined-stream": "1.0.6", + "extend": "3.0.2", + "forever-agent": "0.6.1", + "form-data": "2.3.2", + "har-validator": "5.1.0", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.19", + "oauth-sign": "0.9.0", + "performance-now": "2.1.0", + "qs": "6.5.2", + "safe-buffer": "5.1.2", + "tough-cookie": "2.4.3", + "tunnel-agent": "0.6.0", + "uuid": "3.3.2" + }, + "dependencies": { + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + } + } + }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -4536,6 +4782,11 @@ "glob": "7.1.2" } }, + "rootpath": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/rootpath/-/rootpath-0.1.2.tgz", + "integrity": "sha1-Wzeah9ypBum5HWkKWZQ5vvJn6ms=" + }, "run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", @@ -4584,6 +4835,11 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "scmp": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/scmp/-/scmp-0.0.3.tgz", + "integrity": "sha1-NkjfLXKUZB5/eGc//CloHZutkHM=" + }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -4951,6 +5207,22 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "sshpk": { + "version": "1.14.2", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz", + "integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=", + "requires": { + "asn1": "0.2.4", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.2", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.2", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "safer-buffer": "2.1.2", + "tweetnacl": "0.14.5" + } + }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -5165,6 +5437,15 @@ "nopt": "1.0.10" } }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "requires": { + "psl": "1.1.29", + "punycode": "1.4.1" + } + }, "tree-kill": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.0.tgz", @@ -5175,6 +5456,43 @@ "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=" }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "twilio": { + "version": "3.19.1", + "resolved": "https://registry.npmjs.org/twilio/-/twilio-3.19.1.tgz", + "integrity": "sha512-aGE8Y3VHG+Mp1xQWxE8cK3QzawEkwHlIPz/9uukHpjhNviB398LsUzkzpZlVMdfs/u7qmOcSCDJG0VNdRPbr/g==", + "requires": { + "deprecate": "1.0.0", + "jsonwebtoken": "8.3.0", + "lodash": "4.17.10", + "moment": "2.19.3", + "q": "2.0.3", + "request": "2.88.0", + "rootpath": "0.1.2", + "scmp": "0.0.3", + "xmlbuilder": "9.0.1" + }, + "dependencies": { + "moment": { + "version": "2.19.3", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.19.3.tgz", + "integrity": "sha1-vbmdJw1tf9p4zA+6zoVeJ/59pp8=" + } + } + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -5400,6 +5718,21 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" + } + }, + "weak-map": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/weak-map/-/weak-map-1.0.5.tgz", + "integrity": "sha1-eWkVhNmGB/UHC9O3CkDmuyLkAes=" + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -5463,6 +5796,11 @@ "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", "dev": true }, + "xmlbuilder": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.1.tgz", + "integrity": "sha1-kc1wiXdVNj66V8Et3uq0o0GmH2U=" + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/server/controllers/api/checkPhone.js b/server/controllers/api/checkPhone.js new file mode 100644 index 0000000..630f63c --- /dev/null +++ b/server/controllers/api/checkPhone.js @@ -0,0 +1,12 @@ +import models from '../../database/models/index'; + +export default(req, res) => { + const { textInputValuepPhone } = req.body; + models.Customers.findOne({ where: { phone: textInputValuepPhone } }).then((result) => { + if (result && result.dataValues) { + res.send({ isAvailable: true }); + } else { + res.send({ isAvailable: false }); + } + }); +}; diff --git a/server/controllers/api/editFlight.js b/server/controllers/api/editFlight.js index 7bd8972..600f136 100644 --- a/server/controllers/api/editFlight.js +++ b/server/controllers/api/editFlight.js @@ -1,24 +1,47 @@ - import models from '../../database/models/index'; import sendSmsNotifications from './sendSms'; -export default(req, res, next) => { +export default (req, res, next) => { const { - gateNo, status, terminalNo, departureTime, + gateNo, + status, + terminalNo, + departureTime, } = req.body; - const { flightId: flightNo } = req.params; + const { + flightId: flightNo, + } = req.params; models.Flights .update({ - gate: gateNo, status, terminal_no: terminalNo, departure_time: departureTime, - }, { where: { flight_no: flightNo }, returning: true, plain: true }) + gate: gateNo, + status, + terminal_no: terminalNo, + departure_time: departureTime, + }, { + where: { + flight_no: flightNo, + }, + returning: true, + plain: true, + }) .then((result) => { if (result) { - models.Customers.findAll({ where: { flight_id: result[1].dataValues.id, notify_me: true } }).then((customerResult) => { - const { departure_time: departureTime1, terminal_no: terminalNo1, status: status1 } = result[1].dataValues; - + models.Customers.findAll({ + where: { + flight_id: result[1].dataValues.id, + notify_me: true, + }, + }).then((customerResult) => { + const { + departure_time: departureTime1, + terminal_no: terminalNo1, + status: status1, + } = result[1].dataValues; sendSmsNotifications(departureTime1, terminalNo1, status1); - res.status(200).send({ succesfullyEdited: true }); + res.status(200).send({ + succesfullyEdited: true, + }); }).catch(e => next(e)); } }).catch(e => next(e)); diff --git a/server/controllers/api/index.js b/server/controllers/api/index.js index acf0d57..1533951 100644 --- a/server/controllers/api/index.js +++ b/server/controllers/api/index.js @@ -5,6 +5,8 @@ import flights from './flights'; import updateFlight from './updateFlight'; import editFlightInformation from './editFlight'; import getFlightfromFlightNo from './checkFlight'; +import checkPhone from './checkPhone'; +import udateCustomer from './udateCustomer'; const router = express.Router(); @@ -17,6 +19,8 @@ router.post('/flight/:flightId', editFlightInformation); router.post('/check_flight', getFlightfromFlightNo); router.post('/get_flight_details', updateFlight); +router.post('/check_phone', checkPhone); +router.post('/update_customer', udateCustomer); export default router; diff --git a/server/controllers/api/udateCustomer.js b/server/controllers/api/udateCustomer.js new file mode 100644 index 0000000..fc208a1 --- /dev/null +++ b/server/controllers/api/udateCustomer.js @@ -0,0 +1,26 @@ +import models from '../../database/models/index'; + +export default (req, res, next) => { + const { + textInputValuepPhone, + } = req.body; + + models.Customers + .update({ + notify_me: true, + }, { + where: { + phone: textInputValuepPhone, + }, + returning: true, + plain: true, + }) + .then((result) => { + if (result) { + res.send({ isAvailable: true }); + console.log('updated'); + } else { + res.send({ isAvailable: false }); + } + }).catch(e => next(e)); +}; diff --git a/server/controllers/api/updateFlight.js b/server/controllers/api/updateFlight.js index b580083..46ec370 100644 --- a/server/controllers/api/updateFlight.js +++ b/server/controllers/api/updateFlight.js @@ -2,7 +2,6 @@ import models from '../../database/models/index'; export default (req, res, next) => { const flightNumber = req.params.flightId || req.body.flightNo; - models.Flights.findOne({ where: { flight_no: flightNumber } }).then((result) => { const resultFlightInformation = result.dataValues; res.status(200).send({ data: resultFlightInformation });