Files
old-web/app/controllers/realEstateTypes.js
Bilal Catic 1542310a81 clean code
2019-05-16 19:58:48 +02:00

33 lines
736 B
JavaScript

const db = require('../models/index');
const realEstateTypes = [
{ ime: "Kuća", id: "kuca" },
{ ime: "Stan", id: "stan" },
{ ime: "Vikendica", id: "vikendica" }
];
const getRealEstateTypes = (req,res) => {
const nextStep = req.query.nextStep;
res.render('realEstateType', {
nextStep,
realEstateTypes: realEstateTypes
});
};
const postRealEstateTypes = (req, res) => {
let nextStep = req.query.nextStep;
db.RealEstateRequest.create({
realEstateType: req.body.realestatetype
}).then( (result) => {
nextStep = nextStep || `/grad/${result.uniqueId}`;
res.redirect(nextStep);
}).catch( (e) => {
res.send(e);
});
};
module.exports = {
getRealEstateTypes,
postRealEstateTypes
};