use single ENUMS; change old realEstateType enums
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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, ...
|
||||
|
||||
@@ -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
|
||||
? `<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 realEstateType = getRealEstateTypeEnum(
|
||||
realEstateRequest.realEstateType
|
||||
);
|
||||
const realEstateType = AD_CATEGORY[realEstateRequest.realEstateType];
|
||||
const gardenSize = realEstateType.hasGardenSize
|
||||
? `Kvadratura okućnice od ${realEstateRequest.gardenSizeMin} do ${realEstateRequest.gardenSizeMax}`
|
||||
: "";
|
||||
@@ -153,9 +150,8 @@ const sendBulkEmail = async marketAlerts => {
|
||||
for (request in groupedRERequests) {
|
||||
const marketAlert = groupedRERequests[request];
|
||||
let extractedData = toAWSArray(marketAlert.marketAlertArray);
|
||||
const realEstateType = getRealEstateTypeEnum(
|
||||
marketAlert.requestObject.realEstateType
|
||||
).title;
|
||||
const realEstateType =
|
||||
AD_CATEGORY[marketAlert.requestObject.realEstateType].title || "-";
|
||||
const region = getRegionName(marketAlert.requestObject.region);
|
||||
const municipality = getMunicipalityName(
|
||||
marketAlert.requestObject.region,
|
||||
@@ -240,7 +236,7 @@ const createMarketAlertEmailTemplate = async () => {
|
||||
};
|
||||
|
||||
const getSubject = realEstateType => {
|
||||
return getRealEstateTypeEnum(realEstateType).title;
|
||||
return AD_CATEGORY[realEstateType].title || "-";
|
||||
};
|
||||
|
||||
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