Skip to content

Commit

Permalink
Resolved conflict with master
Browse files Browse the repository at this point in the history
  • Loading branch information
nataphilips committed Dec 1, 2019
2 parents 3e188ef + 9ed8728 commit 62e438f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
5 changes: 3 additions & 2 deletions barberia/src/App/pages/Confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import moment from "moment";

import "./confirmation.css";


function Confirmation({ time, formDate, baseDate, ...props }) {
//states that store form's user information
let [name, setName] = useState(null);
const [name, setName] = useState(null);
const [email, setEmail] = useState(null);
const [phone, setPhone] = useState(null);
const [error_ms, setError_ms] = useState("");
Expand Down Expand Up @@ -132,7 +133,7 @@ function Confirmation({ time, formDate, baseDate, ...props }) {
</form>
<p>date picked is {moment(formDate.toJSON()).format("MMM Do YY")}</p>
<p>
time picked is {time} <br />
time picked is {time.toString()} <br />
</p>
</div>
);
Expand Down
19 changes: 15 additions & 4 deletions barberia/src/App/pages/Congratulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ import "./congratulation.css";

function congratulation({ ...props }) {
const userData = JSON.parse(localStorage.getItem("confirmationData"));
const { email, phone } = userData;
const { email, phone, name } = userData;

const moveTo = destination => {
window.location.assign(destination);
const moveTo = home => {
window.location.assign(home);
};

const deleteLastBooking = () => {};
const deleteLastBooking = () => {

return fetch("/api/cancelbooking", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(userData)
})
.then(window.location.assign("/"))
.catch(err => console.log(err));
};

return (
<div>
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ router.get("/getBusyTimeSlots", (req, res) => {
.catch(err => console.log(err));
});

router.post("/cancelbooking", (req, res) => {
const data = req.body;
queries.cancelbooking(data).catch(err => console.log(err));
});

router.get("*", (req, res) => {
console.log("you arrived at a none query page");
res.sendFile(path.join(__dirname + "/barberia/build/index.html"));
});

Expand Down
10 changes: 10 additions & 0 deletions src/queries/cancelbooking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const databaseConnection = require("../database/db_connection.js");

const cancelbooking = rawData => {
const data = rawData;
return databaseConnection.query(
`DELETE FROM bookings WHERE (booking_date='${data.date}' AND booking_time='${data.time}' AND customer_name='${data.name}')`
);
};

module.exports = cancelbooking;
4 changes: 3 additions & 1 deletion src/queries/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const getAllBookings = require("./getAllBookings");
const saveNewBooking = require("./saveNewBooking");
const getBusyTimeSlots = require("./getUnavailableTimes");
const cancelbooking = require("./cancelbooking");

module.exports = {
getAllBookings,
saveNewBooking,
getBusyTimeSlots
getBusyTimeSlots,
cancelbooking
};

0 comments on commit 62e438f

Please sign in to comment.