From e0a1444b55881f901a5d96a528ed87c90b453a22 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Mon, 14 Oct 2019 11:20:45 +0200 Subject: [PATCH 1/5] show error page when no search request is found --- app/controllers/queryReview.js | 3 ++- app/helpers/db/searchRequest.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/queryReview.js b/app/controllers/queryReview.js index 76cf977..79c9fe6 100644 --- a/app/controllers/queryReview.js +++ b/app/controllers/queryReview.js @@ -66,7 +66,8 @@ const getQueryReview = async (req, res) => { const searchRequest = await currentSearchRequest(req); if (!searchRequest || !searchRequest.dataValues) { - return null; + res.render("notFound", { title: " " }); + return; } const title = "Da li je ovo to što ste tražili ?"; diff --git a/app/helpers/db/searchRequest.js b/app/helpers/db/searchRequest.js index 08e8922..6e47b5d 100644 --- a/app/helpers/db/searchRequest.js +++ b/app/helpers/db/searchRequest.js @@ -4,7 +4,11 @@ const sequelize = require("sequelize"); const Op = sequelize.Op; const getSearchRequest = async searchRequestId => { - return await db.SearchRequest.findByPk(searchRequestId); + try { + return await db.SearchRequest.findByPk(searchRequestId); + } catch (error) { + return null; + } }; const createSearchRequest = async (searchRequestFields = {}) => { -- 2.47.3 From 2a1361733f8ed3f4a5772b670bafa9bebd6eeafd Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Tue, 15 Oct 2019 18:34:34 +0200 Subject: [PATCH 2/5] change real estate type selection design --- app/views/realEstateType.ejs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/realEstateType.ejs b/app/views/realEstateType.ejs index bf8a5b9..abc6da9 100644 --- a/app/views/realEstateType.ejs +++ b/app/views/realEstateType.ejs @@ -1,16 +1,17 @@
- +
-- 2.47.3 From 566f9c4345b57703cc9cc5a860858799210e3780 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Tue, 15 Oct 2019 18:46:11 +0200 Subject: [PATCH 3/5] fix null value for garden size when real estate type is changed --- app/common/enums.js | 3 ++- app/controllers/queryReview.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/common/enums.js b/app/common/enums.js index d851854..0601a9e 100644 --- a/app/common/enums.js +++ b/app/common/enums.js @@ -86,7 +86,8 @@ const AD_CATEGORY = { title: "Vikendica", hasGardenSize: true, priceSliderOptions: PRICE_SLIDER_OPTIONS, - sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS + sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS, + gardenSizeSliderOptions: GARDEN_SIZE_SLIDER_OPTIONS } }; diff --git a/app/controllers/queryReview.js b/app/controllers/queryReview.js index 79c9fe6..294d07d 100644 --- a/app/controllers/queryReview.js +++ b/app/controllers/queryReview.js @@ -37,7 +37,7 @@ const getQueryReviewData = searchRequest => { { id: "realEstateType", title: realEstateTypeTitle, - url: `/vrstanekretnine/${id}?nextStep=pregled` + url: `/vrstanekretnine/${id}?nextStep=filteri` }, { id: "location", -- 2.47.3 From acdeca94dff274088bb15fc31e1067b0195d5d0e Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Tue, 15 Oct 2019 18:51:19 +0200 Subject: [PATCH 4/5] redirect to Not Found page when search request param is missing from URL --- app/controllers/location.js | 5 +++++ app/controllers/realEstateFilters.js | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/controllers/location.js b/app/controllers/location.js index 43f6c29..e0bd4ca 100644 --- a/app/controllers/location.js +++ b/app/controllers/location.js @@ -13,6 +13,11 @@ const getLocation = async (req, res) => { const postLocation = async (req, res) => { let searchRequest = await currentSearchRequest(req); + if (!searchRequest || !searchRequest.dataValues) { + res.render("notFound", { title: " " }); + return; + } + const northWest = [req.body.west, req.body.north]; const northEast = [req.body.east, req.body.north]; const southEast = [req.body.east, req.body.south]; diff --git a/app/controllers/realEstateFilters.js b/app/controllers/realEstateFilters.js index 4630352..c29b2c4 100644 --- a/app/controllers/realEstateFilters.js +++ b/app/controllers/realEstateFilters.js @@ -3,6 +3,12 @@ const { AD_CATEGORY } = require("../common/enums"); const getFilters = async (req, res) => { const searchRequest = await currentSearchRequest(req); + + if (!searchRequest || !searchRequest.dataValues) { + res.render("notFound", { title: " " }); + return; + } + const title = "Filteri za pretraživanje"; const { @@ -47,6 +53,11 @@ const getFilters = async (req, res) => { const postFilters = async (req, res) => { const searchRequest = await currentSearchRequest(req); + if (!searchRequest || !searchRequest.dataValues) { + res.render("notFound", { title: " " }); + return; + } + const nextStepPage = req.query.nextStep || "pregled"; const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; -- 2.47.3 From 205892112d8d320421ee95f82c8dd9d28658cb26 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Tue, 15 Oct 2019 18:56:52 +0200 Subject: [PATCH 5/5] add waves effect to the real estate type selection items --- app/views/queryReview.ejs | 2 +- app/views/realEstateType.ejs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/queryReview.ejs b/app/views/queryReview.ejs index cf7004c..d80640e 100644 --- a/app/views/queryReview.ejs +++ b/app/views/queryReview.ejs @@ -5,7 +5,7 @@
  • <%= stepData.title || '-' %> - edit + edit
  • diff --git a/app/views/realEstateType.ejs b/app/views/realEstateType.ejs index abc6da9..6e2b6ae 100644 --- a/app/views/realEstateType.ejs +++ b/app/views/realEstateType.ejs @@ -3,7 +3,7 @@
    <% for(const realEstateType of realEstateTypes) { %> - -- 2.47.3