44 lines
919 B
JavaScript
44 lines
919 B
JavaScript
const { currentSearchRequest } = require("../helpers/url");
|
|
|
|
const getPrice = (req, res) => {
|
|
const title = "Koja Vam okvirna cijena odgovara ?";
|
|
|
|
const unit = " KM";
|
|
const rangeFrom = {
|
|
min: 1000,
|
|
max: 250000,
|
|
value: 0,
|
|
step: 1000
|
|
};
|
|
|
|
const rangeTo = {
|
|
min: 1000,
|
|
max: 250000,
|
|
value: 50000,
|
|
step: 1000
|
|
};
|
|
|
|
res.render("price", { rangeFrom, rangeTo, unit, title });
|
|
};
|
|
|
|
const postPrice = async (req, res) => {
|
|
const searchRequest = await currentSearchRequest(req);
|
|
|
|
const nextStepPage = req.query.nextStep || "pregled";
|
|
const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
|
|
const priceMin = req.body.from || 0;
|
|
const priceMax = req.body.to || 0;
|
|
//TODO: price validation
|
|
|
|
searchRequest.priceMin = priceMin;
|
|
searchRequest.priceMax = priceMax;
|
|
await searchRequest.save();
|
|
|
|
res.redirect(nextStepUrl);
|
|
};
|
|
|
|
module.exports = {
|
|
getPrice,
|
|
postPrice
|
|
};
|