Skip and prevent saving garden size if not needed

This commit is contained in:
Bilal Catic
2019-05-22 11:36:01 +02:00
parent aa3c965d5c
commit c64ee42914
5 changed files with 33 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
const realEstateTypes = [
{ title: "Kuća", id: "kuca" },
{ title: "Stan", id: "stan" },
{ title: "Vikendica", id: "vikendica" }
{ title: "Kuća", id: "kuca", hasGardenSize: true },
{ title: "Stan", id: "stan", hasGardenSize: false },
{ title: "Vikendica", id: "vikendica", hasGardenSize: true }
];
const sizes = [
@@ -31,8 +31,16 @@ const prices = [
{ 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 = enumType.find(enumValue => enumValue.id === enumId);
const enumObject = getEnumObject(enumType, enumId);
if (!enumObject){
return null;
}
@@ -44,5 +52,6 @@ module.exports = {
sizes,
gardenSizes,
prices,
getRealEstateTypeEnum,
getEnumTypeTitle,
};