use single ENUMS; change old realEstateType enums
This commit is contained in:
@@ -4,12 +4,13 @@ const AD_TYPE = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const AD_CATEGORY = {
|
const AD_CATEGORY = {
|
||||||
CATEGORY_FLAT: "FLAT",
|
FLAT: { id: "FLAT", title: "Stan", hasGardenSize: false },
|
||||||
CATEGORY_HOUSE: "HOUSE",
|
HOUSE: { id: "HOUSE", title: "Kuća", hasGardenSize: true },
|
||||||
CATEGORY_OFFICE: "OFFICE",
|
//OFFICE: { id: "OFFICE", title: "Kancelarija", hasGardenSize: false },
|
||||||
CATEGORY_LAND: "LAND",
|
//LAND: { id: "LAND", title: "Zemljište", hasGardenSize: true },
|
||||||
CATEGORY_APARTMENT: "APARTMENT",
|
APARTMENT: { id: "APARTMENT", title: "Apartman", hasGardenSize: false }
|
||||||
CATEGORY_GARAGE: "GARAGE"
|
//GARAGE: { id: "GARAGE", title: "Garaža", hasGardenSize: false },
|
||||||
|
//COTTAGE: { id: "COTTAGE", title: "Vikendica", hasGardenSize: true }
|
||||||
};
|
};
|
||||||
|
|
||||||
const AD_STATUS = {
|
const AD_STATUS = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const { currentSearchRequest } = require("../helpers/url");
|
const { currentSearchRequest } = require("../helpers/url");
|
||||||
const { getRealEstateTypeEnum } = require("../helpers/enums");
|
const { AD_CATEGORY } = require("../common/enums");
|
||||||
|
|
||||||
const getGardenSize = (req, res) => {
|
const getGardenSize = (req, res) => {
|
||||||
const title = "Koliko okućnice tražite ?";
|
const title = "Koliko okućnice tražite ?";
|
||||||
@@ -28,7 +28,7 @@ const postGardenSize = async (req, res) => {
|
|||||||
const nextStepPage = req.query.nextStep || "cijena";
|
const nextStepPage = req.query.nextStep || "cijena";
|
||||||
const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
|
const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
|
||||||
|
|
||||||
const realEstateType = getRealEstateTypeEnum(searchRequest.realEstateType);
|
const realEstateType = AD_CATEGORY[searchRequest.realEstateType];
|
||||||
if (realEstateType && realEstateType.hasGardenSize) {
|
if (realEstateType && realEstateType.hasGardenSize) {
|
||||||
const gardenSizeMin = req.body.from || 0;
|
const gardenSizeMin = req.body.from || 0;
|
||||||
const gardenSizeMax = req.body.to || 0;
|
const gardenSizeMax = req.body.to || 0;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
const { currentSearchRequest } = require("../helpers/url");
|
const { currentSearchRequest } = require("../helpers/url");
|
||||||
const {
|
const { AD_CATEGORY } = require("../common/enums");
|
||||||
realEstateTypes,
|
|
||||||
getEnumTypeTitle,
|
|
||||||
getRealEstateTypeEnum
|
|
||||||
} = require("../helpers/enums");
|
|
||||||
|
|
||||||
const getQueryReview = async (req, res) => {
|
const getQueryReview = async (req, res) => {
|
||||||
const title = "Da li je ovo to što ste tražili ?";
|
const title = "Da li je ovo to što ste tražili ?";
|
||||||
@@ -25,13 +21,13 @@ const getQueryReview = async (req, res) => {
|
|||||||
priceMax
|
priceMax
|
||||||
} = searchRequest.dataValues;
|
} = searchRequest.dataValues;
|
||||||
|
|
||||||
const realEstateTypeObject = getRealEstateTypeEnum(realEstateType);
|
const realEstateTypeObject = AD_CATEGORY[realEstateType];
|
||||||
const enableGardenSizeEdit = realEstateTypeObject
|
const enableGardenSizeEdit = realEstateTypeObject
|
||||||
? realEstateTypeObject.hasGardenSize
|
? realEstateTypeObject.hasGardenSize
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
const realEstateTypeTitle = realEstateType
|
const realEstateTypeTitle = realEstateTypeObject
|
||||||
? getEnumTypeTitle(realEstateTypes, realEstateType)
|
? realEstateTypeObject.title
|
||||||
: "-";
|
: "-";
|
||||||
|
|
||||||
const locationTitle = "Location description - PLACEHOLDER";
|
const locationTitle = "Location description - PLACEHOLDER";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const { currentSearchRequest } = require("../helpers/url");
|
const { currentSearchRequest } = require("../helpers/url");
|
||||||
const { sizes, getRealEstateTypeEnum } = require("../helpers/enums");
|
const { AD_CATEGORY } = require("../common/enums");
|
||||||
|
|
||||||
const getSize = (req, res) => {
|
const getSize = (req, res) => {
|
||||||
const title = "Od koliko kvadrata tražite nekretninu ?";
|
const title = "Od koliko kvadrata tražite nekretninu ?";
|
||||||
@@ -24,7 +24,7 @@ const getSize = (req, res) => {
|
|||||||
const postSize = async (req, res) => {
|
const postSize = async (req, res) => {
|
||||||
const searchRequest = await currentSearchRequest(req);
|
const searchRequest = await currentSearchRequest(req);
|
||||||
|
|
||||||
const realEstateType = getRealEstateTypeEnum(searchRequest.realEstateType);
|
const realEstateType = AD_CATEGORY[searchRequest.realEstateType];
|
||||||
const sizeMin = req.body.from || 0;
|
const sizeMin = req.body.from || 0;
|
||||||
const sizeMax = req.body.to || 0;
|
const sizeMax = req.body.to || 0;
|
||||||
//TODO: Validation, check if real estate type is valid, ...
|
//TODO: Validation, check if real estate type is valid, ...
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const { APP_URL } = require("../config/appConfig");
|
const { APP_URL } = require("../config/appConfig");
|
||||||
const { getRealEstateTypeEnum } = require("./enums");
|
const { AD_CATEGORY } = require("../common/enums");
|
||||||
const { getRegionName, getMunicipalityName } = require("./codes");
|
const { getRegionName, getMunicipalityName } = require("./codes");
|
||||||
const { allRERequestByUiid } = require("./db/dbHelper");
|
const { allRERequestByUiid } = require("./db/dbHelper");
|
||||||
let AWS = require("aws-sdk");
|
let AWS = require("aws-sdk");
|
||||||
@@ -49,9 +49,8 @@ const sendTemplatedEmail = async (email, request) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getGreetingsEmailHTML = realEstateRequest => {
|
const getGreetingsEmailHTML = realEstateRequest => {
|
||||||
const realEstateType = getRealEstateTypeEnum(
|
const realEstateType = AD_CATEGORY[realEstateRequest.realEstateType];
|
||||||
realEstateRequest.realEstateType
|
|
||||||
);
|
|
||||||
const gardenSize = realEstateType.hasGardenSize
|
const gardenSize = realEstateType.hasGardenSize
|
||||||
? `<div><strong>Kvadratura okućnice: Od ${realEstateRequest.gardenSizeMin} do ${realEstateRequest.gardenSizeMax} m2 </strong></div>`
|
? `<div><strong>Kvadratura okućnice: Od ${realEstateRequest.gardenSizeMin} do ${realEstateRequest.gardenSizeMax} m2 </strong></div>`
|
||||||
: ``;
|
: ``;
|
||||||
@@ -77,9 +76,7 @@ const getGreetingsEmailHTML = realEstateRequest => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getGreetingsEmailTextVersion = realEstateRequest => {
|
const getGreetingsEmailTextVersion = realEstateRequest => {
|
||||||
const realEstateType = getRealEstateTypeEnum(
|
const realEstateType = AD_CATEGORY[realEstateRequest.realEstateType];
|
||||||
realEstateRequest.realEstateType
|
|
||||||
);
|
|
||||||
const gardenSize = realEstateType.hasGardenSize
|
const gardenSize = realEstateType.hasGardenSize
|
||||||
? `Kvadratura okućnice od ${realEstateRequest.gardenSizeMin} do ${realEstateRequest.gardenSizeMax}`
|
? `Kvadratura okućnice od ${realEstateRequest.gardenSizeMin} do ${realEstateRequest.gardenSizeMax}`
|
||||||
: "";
|
: "";
|
||||||
@@ -153,9 +150,8 @@ const sendBulkEmail = async marketAlerts => {
|
|||||||
for (request in groupedRERequests) {
|
for (request in groupedRERequests) {
|
||||||
const marketAlert = groupedRERequests[request];
|
const marketAlert = groupedRERequests[request];
|
||||||
let extractedData = toAWSArray(marketAlert.marketAlertArray);
|
let extractedData = toAWSArray(marketAlert.marketAlertArray);
|
||||||
const realEstateType = getRealEstateTypeEnum(
|
const realEstateType =
|
||||||
marketAlert.requestObject.realEstateType
|
AD_CATEGORY[marketAlert.requestObject.realEstateType].title || "-";
|
||||||
).title;
|
|
||||||
const region = getRegionName(marketAlert.requestObject.region);
|
const region = getRegionName(marketAlert.requestObject.region);
|
||||||
const municipality = getMunicipalityName(
|
const municipality = getMunicipalityName(
|
||||||
marketAlert.requestObject.region,
|
marketAlert.requestObject.region,
|
||||||
@@ -240,7 +236,7 @@ const createMarketAlertEmailTemplate = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getSubject = realEstateType => {
|
const getSubject = realEstateType => {
|
||||||
return getRealEstateTypeEnum(realEstateType).title;
|
return AD_CATEGORY[realEstateType].title || "-";
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
const realEstateTypes = [
|
|
||||||
{ title: "Kuća", id: "kuca", hasGardenSize: true, olxid: 24 },
|
|
||||||
{ title: "Stan", id: "stan", hasGardenSize: false, olxid: 23 },
|
|
||||||
{ title: "Vikendica", id: "vikendica", hasGardenSize: true, olxid: 26 }
|
|
||||||
];
|
|
||||||
|
|
||||||
const sizes = [
|
|
||||||
{ title: "do 50 m2", id: "50m2" },
|
|
||||||
{ title: "do 75 m2", id: "75m2" },
|
|
||||||
{ title: "do 100 m2", id: "100m2" },
|
|
||||||
{ title: "do 150 m2", id: "150m2" },
|
|
||||||
{ title: "do 200 m2", id: "200m2" },
|
|
||||||
{ title: "preko 200 m2", id: "moreThan200m2" }
|
|
||||||
];
|
|
||||||
|
|
||||||
const gardenSizes = [
|
|
||||||
{ title: "do 100 m2", id: "100m2" },
|
|
||||||
{ title: "do 500 m2", id: "500m2" },
|
|
||||||
{ title: "do 1 dunum", id: "1000m2" },
|
|
||||||
{ title: "do 2 dunuma", id: "2000m2" },
|
|
||||||
{ title: "do 3 dunuma", id: "3000m2" },
|
|
||||||
{ title: "preko 3 dunuma", id: "moreThan3000m2" }
|
|
||||||
];
|
|
||||||
|
|
||||||
const prices = [
|
|
||||||
{ title: "do 50 000 KM", id: "50kKM" },
|
|
||||||
{ title: "do 100 000 KM", id: "100kKM" },
|
|
||||||
{ title: "do 150 000 KM", id: "150kKM" },
|
|
||||||
{ title: "do 200 000 KM", id: "200kKM" },
|
|
||||||
{ title: "do 250 000 KM", id: "250kKM" },
|
|
||||||
{ title: "preko 250 000 KM", id: "moreThan250kKM" }
|
|
||||||
];
|
|
||||||
|
|
||||||
const getEnumObject = (enumType, enumId) => {
|
|
||||||
return enumType.find(enumValue => enumValue.id === enumId);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getRealEstateTypeEnum = enumId => {
|
|
||||||
return getEnumObject(realEstateTypes, enumId) || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEnumTypeTitle = (enumType, enumId) => {
|
|
||||||
const enumObject = getEnumObject(enumType, enumId);
|
|
||||||
if (!enumObject) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return enumObject.title;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
realEstateTypes,
|
|
||||||
sizes,
|
|
||||||
gardenSizes,
|
|
||||||
prices,
|
|
||||||
getRealEstateTypeEnum,
|
|
||||||
getEnumTypeTitle
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user