Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move logic to backend #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Move logic to backend #6

wants to merge 2 commits into from

Conversation

merveuygunerdol
Copy link
Owner

No description provided.

index.js Outdated
@@ -3,14 +3,24 @@ const cors = require('cors');
const bodyparser = require('body-parser');
const app = express();

require('./database-connection');
require('./database-connection.js')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need .js in module names, please remove these.

axios.post('http://localhost:3000/seat-plan', selectedSeat)
.then((response) => {
console.log(response.data)
commit('SET_DATA', selectedSeat)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this syntax is wrong — you have to pass in an object.

index.js Outdated
res.send('hello')
})

app.get('/seat-plan', (req, res, next) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should remove these handlers.


const flightSchema = mongoose.Schema({
seatPlan: {
type: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure it's a string? what would be its value? I think a flight has N rows of 6 seats each, and you should track if any of the seats are empty or reserved, and their prices...


const FlightService = require('../services/flight-service.js')

router.post('/seat-plan', async (req, res, next) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you should get the chosen seat id from the request, and modify the current flight accordingly — see if the user can actually reserve this seat.

so the method call should be FlightService.chooseSeat(req.body) instead of a generic add — we're not adding a flight seating plan, we're not the admin who are designing flights, we are customers who just want to book a predefined seat in the flight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants