Added real estate ad edit ability
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
|
||||
const {
|
||||
bulkUpsertKiviPhotos,
|
||||
findPhotosForKiviAd
|
||||
findPhotosForKiviAd,
|
||||
deleteUrlPhotosAfterUpdate
|
||||
} = require("../helpers/db/kiviOriginalAdsPhotos");
|
||||
const { currentKiviRealEstate } = require("../helpers/url");
|
||||
const {
|
||||
@@ -202,8 +203,8 @@ const getPublishInputs = async (req, res) => {
|
||||
additionalInputValues,
|
||||
validate: validate,
|
||||
email,
|
||||
locationLat, //: locationLat || 0,
|
||||
locationLong, //: locationLong || 0,
|
||||
locationLat: locationLat || 0,
|
||||
locationLong: locationLong || 0,
|
||||
editingRealEstate,
|
||||
realEstatePhotosUrls
|
||||
});
|
||||
@@ -225,7 +226,7 @@ const postPublishInputs = async (req, res) => {
|
||||
|
||||
const editingRealEstate = req.body.editingRealEstate === "true";
|
||||
|
||||
console.log("Editing real estate:", editingRealEstate);
|
||||
// console.log("Editing real estate:", editingRealEstate);
|
||||
|
||||
const nextStepPage = editingRealEstate
|
||||
? req.query.nextStep || "/uspjesnaizmjena"
|
||||
@@ -296,6 +297,10 @@ const postPublishInputs = async (req, res) => {
|
||||
//Image urls are stored in new table
|
||||
const imageUrls =
|
||||
req.body.imageUrls.split("|").filter(url => url !== "") || [];
|
||||
//If we are in editing mode we need to "delete" photos that are not longer associated with real estate ad
|
||||
if (editingRealEstate) {
|
||||
await deleteUrlPhotosAfterUpdate(imageUrls);
|
||||
}
|
||||
|
||||
const imageUrlsData = imageUrls.map(url => {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user