Redesign db and adapt search request #29

Merged
bilal.catic merged 20 commits from redesign-DB-and-adapt-search-request into master 2019-09-13 18:55:13 +02:00
Showing only changes of commit db58d1e98b - Show all commits

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);
};