2019-04-20 05:26:14 +02:00
|
|
|
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-20 05:26:14 +02:00
|
|
|
];
|
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;
|
2019-04-20 05:26:14 +02:00
|
|
|
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) => {
|
2019-04-20 05:26:14 +02:00
|
|
|
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
|
|
|
};
|