Hi guys, i need some help with a website i'm building.
I'm building a website to book tables in restaurants. From the gist above, i have the reserve route, that's not used for rendering nothing, the restaurant template .pug that has the form that posts to the reserve route, and the reserve mongoose model.
The flow i want to achieve is a user selects a restaurant, chooses a date and time and number of people. then hit's the book (reservar) button. the form makes a post to the reserve route that should:
- create a new Reserve model with the details of the... reserve
- send an email to the restaurant asking if they have availability for what the user is asking (i'm thinking of sending an email with 2 buttons that post to a keystone route for handling, like in SydJS website: https://github.com/JedWatson/sydjs-site/blob/master/routes/views/session/forgot-password.js )
- set the reserve state to sent/initiated or whatever seems more appropriate
- when restaurant responds, check if it's a yes or no, and set the reserve state accordingly (denied, if negative response | accepted if positive)
- email user with the response, in case he doesn't want to check his app profile/dashboard
- have the state pass to ended when the reserve date has passed
Can please someone give me some help with this?! I'm having some issues understanding the update hanler, and/or the need for it. Maybe i can just use the mongoose save() function ??? I can't get a clear "vision" on how to get the flow right. and also my code is crappy!!