2019-05-17 11:32:41 +02:00
|
|
|
const { currentRERequest } = require('../helpers/url');
|
|
|
|
|
|
|
|
|
|
const getPrice = (req,res) => {
|
2019-06-03 10:34:59 +02:00
|
|
|
|
|
|
|
|
const unit = " KM"
|
2019-05-29 11:03:01 +02:00
|
|
|
const rangeFrom = {
|
2019-05-30 10:43:47 +02:00
|
|
|
min : 1000,
|
2019-05-29 11:03:01 +02:00
|
|
|
max : 250000,
|
|
|
|
|
value : 0,
|
|
|
|
|
step : 1000
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rangeTo = {
|
2019-05-30 10:43:47 +02:00
|
|
|
min : 1000,
|
2019-05-29 11:03:01 +02:00
|
|
|
max : 250000,
|
|
|
|
|
value : 50000,
|
|
|
|
|
step : 1000
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-06-03 10:34:59 +02:00
|
|
|
res.render('price', {rangeFrom, rangeTo, unit });
|
2019-05-17 11:32:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const postPrice = async (req, res) => {
|
|
|
|
|
const request = await currentRERequest(req);
|
2019-05-21 15:25:28 +02:00
|
|
|
|
|
|
|
|
const nextStepPage = req.query.nextStep || 'pregled';
|
|
|
|
|
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
|
|
|
|
|
|
2019-05-30 10:43:47 +02:00
|
|
|
request.priceMin = req.body.from;
|
|
|
|
|
request.priceMax = req.body.to;
|
2019-05-17 11:32:41 +02:00
|
|
|
await request.save();
|
2019-05-21 15:25:28 +02:00
|
|
|
|
|
|
|
|
res.redirect(nextStepUrl);
|
2019-05-17 11:32:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
getPrice,
|
|
|
|
|
postPrice
|
|
|
|
|
};
|