adapt price and query review steps for new DB design
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { currentRERequest } = require("../helpers/url");
|
||||
const { currentSearchRequest } = require("../helpers/url");
|
||||
const {
|
||||
realEstateTypes,
|
||||
getEnumTypeTitle,
|
||||
@@ -7,23 +7,23 @@ const {
|
||||
|
||||
const getQueryReview = async (req, res) => {
|
||||
const title = "Da li je ovo to što ste tražili ?";
|
||||
const request = await currentRERequest(req);
|
||||
const searchRequest = await currentSearchRequest(req);
|
||||
const nextStep = req.query.nextStep;
|
||||
|
||||
if (!request || !request.dataValues) {
|
||||
if (!searchRequest || !searchRequest.dataValues) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
id,
|
||||
realEstateType,
|
||||
sizeMin,
|
||||
sizeMax,
|
||||
gardenSizeMin,
|
||||
gardenSizeMax,
|
||||
priceMin,
|
||||
priceMax,
|
||||
locationInput
|
||||
} = request.dataValues;
|
||||
priceMax
|
||||
} = searchRequest.dataValues;
|
||||
|
||||
const realEstateTypeObject = getRealEstateTypeEnum(realEstateType);
|
||||
const enableGardenSizeEdit = realEstateTypeObject
|
||||
@@ -32,58 +32,55 @@ const getQueryReview = async (req, res) => {
|
||||
|
||||
const realEstateTypeTitle = realEstateType
|
||||
? getEnumTypeTitle(realEstateTypes, realEstateType)
|
||||
: null;
|
||||
: "-";
|
||||
|
||||
const locationTitle = locationInput ? locationInput : "-";
|
||||
const locationTitle = "Location description - PLACEHOLDER";
|
||||
const sizeTitle = sizeMin && sizeMax ? `${sizeMin} - ${sizeMax} m2` : "-";
|
||||
const gardenSizeTitle =
|
||||
enableGardenSizeEdit && gardenSizeMin && gardenSizeMax
|
||||
? `${gardenSizeMin} - ${gardenSizeMax} m2`
|
||||
: "-";
|
||||
const priceTitle =
|
||||
priceMin && priceMax ? `${priceMin} - ${priceMax} KM` : "-";
|
||||
|
||||
const sizeTitle = sizeMin ? sizeMin + "-" + sizeMax + " m2" : null;
|
||||
const gardenSizeTitle = gardenSizeMin
|
||||
? gardenSizeMin + "-" + gardenSizeMax + " m2"
|
||||
: null;
|
||||
const priceTitle = priceMin ? priceMin + "-" + priceMax + " KM" : null;
|
||||
|
||||
const uniqueId = request.dataValues.uniqueId
|
||||
? request.dataValues.uniqueId
|
||||
: "";
|
||||
|
||||
const queryData = [
|
||||
const queryReviewData = [
|
||||
{
|
||||
id: "realEstateType",
|
||||
title: realEstateTypeTitle,
|
||||
url: `/vrstanekretnine/${uniqueId}?nextStep=pregled`
|
||||
url: `/vrstanekretnine/${id}?nextStep=pregled`
|
||||
},
|
||||
{
|
||||
id: "location",
|
||||
title: locationTitle,
|
||||
url: `/lokacija/${uniqueId}?nextStep=pregled`
|
||||
url: `/lokacija/${id}?nextStep=pregled`
|
||||
},
|
||||
{
|
||||
id: "size",
|
||||
title: sizeTitle,
|
||||
url: `/povrsina/${uniqueId}?nextStep=pregled`
|
||||
url: `/povrsina/${id}?nextStep=pregled`
|
||||
},
|
||||
{
|
||||
id: "gardenSize",
|
||||
title: gardenSizeTitle,
|
||||
url: enableGardenSizeEdit ? `/okucnica/${uniqueId}?nextStep=pregled` : ""
|
||||
url: enableGardenSizeEdit ? `/okucnica/${id}?nextStep=pregled` : ""
|
||||
},
|
||||
{
|
||||
id: "price",
|
||||
title: priceTitle,
|
||||
url: `/cijena/${uniqueId}?nextStep=pregled`
|
||||
url: `/cijena/${id}?nextStep=pregled`
|
||||
}
|
||||
];
|
||||
|
||||
res.render("queryReview", {
|
||||
nextStep,
|
||||
queryData,
|
||||
queryReviewData,
|
||||
title
|
||||
});
|
||||
};
|
||||
|
||||
const postQueryReview = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
const nextStep = req.query.nextStep || `/posalji/${request.uniqueId}`;
|
||||
const searchRequest = await currentSearchRequest(req);
|
||||
const nextStep = req.query.nextStep || `/posalji/${searchRequest.id}`;
|
||||
|
||||
res.redirect(nextStep);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user