Files
old-web/app/controllers/realEstateTypes.js

34 lines
737 B
JavaScript
Raw Normal View History

const db = require('../models/index');
2019-04-16 06:27:11 +02:00
2019-05-15 15:27:10 +02:00
const realEstateTypes = [
2019-05-16 19:40:26 +02:00
{ ime: "Kuća", id: "kuca" },
{ ime: "Stan", id: "stan" },
2019-04-14 06:01:37 +02:00
{ ime: "Vikendica", id: "vikendica" }
];
2019-04-14 06:01:37 +02:00
2019-05-15 15:27:10 +02:00
const getRealEstateTypes = (req,res) => {
2019-05-16 19:40:26 +02:00
const nextStep = req.query.nextStep;
res.render('realEstateType', {
nextStep,
realEstateTypes: realEstateTypes
2019-04-14 06:01:37 +02:00
});
2019-05-16 19:40:26 +02:00
};
2019-03-26 05:06:15 +01:00
2019-05-15 15:27:10 +02:00
const postRealEstateTypes = (req, res) => {
2019-04-27 07:08:36 +02:00
let nextStep = req.query.nextStep;
db.RealEstateRequest.create({
2019-05-15 15:27:10 +02:00
realEstateType: req.body.realestatetype
2019-04-16 06:27:11 +02:00
}).then( (result) => {
2019-04-27 07:08:36 +02:00
nextStep = nextStep || `/grad/${result.uniqueId}`;
2019-05-16 19:40:26 +02:00
res.redirect(nextStep);
2019-04-16 06:27:11 +02:00
}).catch( (e) => {
res.send(e);
2019-05-16 19:40:26 +02:00
});
};
2019-04-16 06:27:11 +02:00
2019-05-16 19:40:26 +02:00
module.exports = {
2019-05-15 15:27:10 +02:00
getRealEstateTypes,
postRealEstateTypes
2019-03-26 05:06:15 +01:00
};