diff --git a/app/common/enums.js b/app/common/enums.js index b7a650c..b488b21 100644 --- a/app/common/enums.js +++ b/app/common/enums.js @@ -4,12 +4,13 @@ const AD_TYPE = { }; const AD_CATEGORY = { - CATEGORY_FLAT: "FLAT", - CATEGORY_HOUSE: "HOUSE", - CATEGORY_OFFICE: "OFFICE", - CATEGORY_LAND: "LAND", - CATEGORY_APARTMENT: "APARTMENT", - CATEGORY_GARAGE: "GARAGE" + FLAT: { id: "FLAT", title: "Stan", hasGardenSize: false }, + HOUSE: { id: "HOUSE", title: "Kuća", hasGardenSize: true }, + //OFFICE: { id: "OFFICE", title: "Kancelarija", hasGardenSize: false }, + //LAND: { id: "LAND", title: "Zemljište", hasGardenSize: true }, + APARTMENT: { id: "APARTMENT", title: "Apartman", hasGardenSize: false } + //GARAGE: { id: "GARAGE", title: "Garaža", hasGardenSize: false }, + //COTTAGE: { id: "COTTAGE", title: "Vikendica", hasGardenSize: true } }; const AD_STATUS = { diff --git a/app/controllers/gardenSizes.js b/app/controllers/gardenSizes.js index 4fb5c8e..221e5a0 100644 --- a/app/controllers/gardenSizes.js +++ b/app/controllers/gardenSizes.js @@ -1,5 +1,5 @@ const { currentSearchRequest } = require("../helpers/url"); -const { getRealEstateTypeEnum } = require("../helpers/enums"); +const { AD_CATEGORY } = require("../common/enums"); const getGardenSize = (req, res) => { const title = "Koliko okućnice tražite ?"; @@ -28,7 +28,7 @@ const postGardenSize = async (req, res) => { const nextStepPage = req.query.nextStep || "cijena"; const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; - const realEstateType = getRealEstateTypeEnum(searchRequest.realEstateType); + const realEstateType = AD_CATEGORY[searchRequest.realEstateType]; if (realEstateType && realEstateType.hasGardenSize) { const gardenSizeMin = req.body.from || 0; const gardenSizeMax = req.body.to || 0; diff --git a/app/controllers/queryReview.js b/app/controllers/queryReview.js index ac4bd1f..6ea8bd8 100644 --- a/app/controllers/queryReview.js +++ b/app/controllers/queryReview.js @@ -1,9 +1,5 @@ const { currentSearchRequest } = require("../helpers/url"); -const { - realEstateTypes, - getEnumTypeTitle, - getRealEstateTypeEnum -} = require("../helpers/enums"); +const { AD_CATEGORY } = require("../common/enums"); const getQueryReview = async (req, res) => { const title = "Da li je ovo to što ste tražili ?"; @@ -25,13 +21,13 @@ const getQueryReview = async (req, res) => { priceMax } = searchRequest.dataValues; - const realEstateTypeObject = getRealEstateTypeEnum(realEstateType); + const realEstateTypeObject = AD_CATEGORY[realEstateType]; const enableGardenSizeEdit = realEstateTypeObject ? realEstateTypeObject.hasGardenSize : false; - const realEstateTypeTitle = realEstateType - ? getEnumTypeTitle(realEstateTypes, realEstateType) + const realEstateTypeTitle = realEstateTypeObject + ? realEstateTypeObject.title : "-"; const locationTitle = "Location description - PLACEHOLDER"; diff --git a/app/controllers/sizes.js b/app/controllers/sizes.js index 8c2c843..288410c 100644 --- a/app/controllers/sizes.js +++ b/app/controllers/sizes.js @@ -1,5 +1,5 @@ const { currentSearchRequest } = require("../helpers/url"); -const { sizes, getRealEstateTypeEnum } = require("../helpers/enums"); +const { AD_CATEGORY } = require("../common/enums"); const getSize = (req, res) => { const title = "Od koliko kvadrata tražite nekretninu ?"; @@ -24,7 +24,7 @@ const getSize = (req, res) => { const postSize = async (req, res) => { const searchRequest = await currentSearchRequest(req); - const realEstateType = getRealEstateTypeEnum(searchRequest.realEstateType); + const realEstateType = AD_CATEGORY[searchRequest.realEstateType]; const sizeMin = req.body.from || 0; const sizeMax = req.body.to || 0; //TODO: Validation, check if real estate type is valid, ... diff --git a/app/helpers/awsEmail.js b/app/helpers/awsEmail.js index bb1c80c..a8cfc9f 100644 --- a/app/helpers/awsEmail.js +++ b/app/helpers/awsEmail.js @@ -1,5 +1,5 @@ const { APP_URL } = require("../config/appConfig"); -const { getRealEstateTypeEnum } = require("./enums"); +const { AD_CATEGORY } = require("../common/enums"); const { getRegionName, getMunicipalityName } = require("./codes"); const { allRERequestByUiid } = require("./db/dbHelper"); let AWS = require("aws-sdk"); @@ -49,9 +49,8 @@ const sendTemplatedEmail = async (email, request) => { }; const getGreetingsEmailHTML = realEstateRequest => { - const realEstateType = getRealEstateTypeEnum( - realEstateRequest.realEstateType - ); + const realEstateType = AD_CATEGORY[realEstateRequest.realEstateType]; + const gardenSize = realEstateType.hasGardenSize ? `