Open SJBroida opened 2 years ago
/reservations/new
page will
<input name="first_name" />
<input name="last_name" />
<input name="mobile_number" />
<input name="reservation_date" />
<input name="reservation_time" />
<input name="people" />
Submit
button that, when clicked, saves the new reservation, then displays the /dashboard
page for the date of the new reservationCancel
button that, when clicked, returns the user to the previous page/dashboard
page will
/dashboard?date=2035-12-30
then send a GET to /reservations?date=2035-12-30
to list the reservations for that date). The date is defaulted to today, and the reservations are sorted by time./reservations
API will have the same validations as above and will return 400, along with an informative error message, when a validation error happens.
./back-end/src/db/seeds/00-reservations.json
Hint Dates and times in JavaScript and databases can be challenging.
The users have confirmed that they will be using Chrome to access the site. This means you can use
<input type="date" />
and<input type="time" />
, which are supported by Chrome but may not work in other browsers.
<input type="date" />
will store the date inYYYY-MM-DD
format. This is a format that works well with the PostgreSQLdate
data type.
<input type="time" />
will store the time inHH:MM:SS
format. This is a format that works well with the PostgreSQLtime
data type.Optional If you want to add support to other browsers such as Safari or IE, you can use the pattern and placeholder attributes along with the date and time inputs in your form. For the date input you can use
<input type="date" placeholder="YYYY-MM-DD" pattern="\d{4}-\d{2}-\d{2}"/>
, and for the time input you can use<input type="time" placeholder="HH:MM" pattern="[0-9]{2}:[0-9]{2}"/>
. You can read more about handling browser support here.You can assume that all dates and times will be in your local time zone.
Hint In the backend code, be sure to wrap any async controller functions in an
asyncErrorBoundary
call to ensure errors in async code are property handled.
In back-end/src/errors/asyncErrorBoundary.js
function asyncErrorBoundary(delegate, defaultStatus) {
return (request, response, next) => {
Promise.resolve()
.then(() => delegate(request, response, next))
.catch((error = {}) => {
const { status = defaultStatus, message = error } = error;
next({
status,
message,
});
});
};
}
module.exports = asyncErrorBoundary;
Use in controllers as part of module.exports
. For example:
module.exports = {
create: asyncErrorBoundary(create)
}
User Story 1:
As a restaurant manager I want to create a new reservation when a customer calls so that I know how many customers will arrive at the restaurant on a given day.