Merged finished kivi-input in view

This commit is contained in:
Naida Vatric
2020-03-14 14:09:36 +01:00
17 changed files with 415 additions and 261 deletions

View File

@@ -1,4 +1,5 @@
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
const { bulkUpsertKiviPhotos } = require("../helpers/db/kiviOriginalAdsPhotos");
const { currentKiviRealEstate } = require("../helpers/url");
const validate = require("validate.js");
@@ -188,6 +189,9 @@ const postPublishInputs = async (req, res) => {
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
//Request body
//console.log("Body:", req.body);
const balcony = req.body.balcony === "on";
const elevator = req.body.elevator === "on";
const newBuilding = req.body.newBuilding === "on";
@@ -248,6 +252,16 @@ const postPublishInputs = async (req, res) => {
const locationLong = req.body.lng || null;
//Contact email saved in other table
const contactEmail = req.body.email || "";
//Image urls are stored in new table
const imageUrls =
req.body.imageUrls.split("|").filter(url => url !== "") || [];
const imageUrlsData = imageUrls.map(url => {
return {
kiviAdId: kiviOriginal.kiviAdId,
photoUrl: url
};
});
const savedImageUrls = await bulkUpsertKiviPhotos(imageUrlsData);
realEstate.balcony = balcony;
realEstate.elevator = elevator;