adapt location step for new DB design

This commit is contained in:
Bilal Catic
2019-09-13 12:37:53 +02:00
parent fbf7aabe93
commit db58d1e98b

View File

@@ -1,4 +1,4 @@
const { currentRERequest } = require("../helpers/url");
const { currentSearchRequest } = require("../helpers/url");
const getLocation = async (req, res) => {
const title = "U kojem naselju tražite nekretninu?";
@@ -11,21 +11,22 @@ const getLocation = async (req, res) => {
};
const postLocation = async (req, res) => {
let request = await currentRERequest(req);
let searchRequest = await currentSearchRequest(req);
const northWest = [req.body.west, req.body.north];
const northEast = [req.body.east, req.body.north];
const southEast = [req.body.east, req.body.south];
const southWest = [req.body.west, req.body.south];
request.locationInput =
const locationInputValue =
req.body.locationInput && req.body.locationInput.length > 0
? req.body.locationInput
: null;
request.boundingBox = {
searchRequest.areaToSearch = {
type: "Polygon",
coordinates: [[northWest, northEast, southEast, southWest, northWest]]
coordinates: [[northWest, northEast, southEast, southWest, northWest]],
crs: { type: "name", properties: { name: "EPSG:4326" } }
};
let locationInputData;
@@ -37,10 +38,10 @@ const postLocation = async (req, res) => {
}
}
await request.save();
await searchRequest.save();
const nextStepPage = req.query.nextStep || "povrsina";
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}`;
const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
res.redirect(nextStepUrl);
};