adapt price and query review steps for new DB design

This commit is contained in:
Bilal Catic
2019-09-13 14:17:46 +02:00
parent ff68e96f4f
commit e26c2b6e8d
3 changed files with 35 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
const { currentRERequest } = require("../helpers/url");
const { currentSearchRequest } = require("../helpers/url");
const getPrice = (req, res) => {
const title = "Koja Vam okvirna cijena odgovara ?";
@@ -22,14 +22,17 @@ const getPrice = (req, res) => {
};
const postPrice = async (req, res) => {
const request = await currentRERequest(req);
const searchRequest = await currentSearchRequest(req);
const nextStepPage = req.query.nextStep || "pregled";
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
const priceMin = req.body.from || 0;
const priceMax = req.body.to || 0;
//TODO: price validation
request.priceMin = req.body.from;
request.priceMax = req.body.to;
await request.save();
searchRequest.priceMin = priceMin;
searchRequest.priceMax = priceMax;
await searchRequest.save();
res.redirect(nextStepUrl);
};