diff --git a/app/controllers/publishRealEstate.js b/app/controllers/publishRealEstate.js index 9f0742f..308d819 100644 --- a/app/controllers/publishRealEstate.js +++ b/app/controllers/publishRealEstate.js @@ -2,7 +2,12 @@ const { currentRealEstate } = require("../helpers/url"); const { createRealEstate } = require("../helpers/db/realEstate"); const { createKiviOriginal } = require("../helpers/db/kiviOriginal"); -const { AD_CATEGORY, AD_TYPE, AD_AGENCY } = require("../common/enums"); +const { + AD_CATEGORY, + FURNISHING_TYPE, + ACCESS_ROAD_TYPE, + HEATING_TYPE +} = require("../common/enums"); const { BASIC_BOOLEAN_PUBLISH, BASIC_SEGMENT_PUBLISH, @@ -169,6 +174,10 @@ const postPublishInputs = async (req, res) => { return; } + //const nextStepPage = req.query.nextStep || "pregled"; + // const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; + const nextStepUrl = "/unsubscribe/"; + const balcony = req.body.balcony === "on"; const elevator = req.body.elevator === "on"; const newBuilding = req.body.newBuilding === "on"; @@ -198,31 +207,32 @@ const postPublishInputs = async (req, res) => { const buildingPermit = req.body.buildingPermit === "on"; const furnishingType = req.body.furnishingType; - if (!FURNISHING_TYPE[furnishingType]) { + //VALIDACIJA TAKO POTVRDITI DA JE ISPRAVNA VRIJEDNOST + /* if (!FURNISHING_TYPE[furnishingType]) { res.render("notFound", { title: " Greška !" }); return; - } + } */ const accessRoadType = req.body.accessRoadType; - if (!ACCESS_ROAD_TYPE[accessRoadType]) { + /*if (!ACCESS_ROAD_TYPE[accessRoadType]) { res.render("notFound", { title: " Greška !" }); return; - } + } */ const heatingType = req.body.heatingType; - if (!HEATING_TYPE[heatingType]) { + /*if (!HEATING_TYPE[heatingType]) { res.render("notFound", { title: " Greška !" }); return; - } + }*/ - const price = parseFloat(req.body.price); - const area = parseFloat(req.body.area); - const gardenSize = parseFloat(req.body.gardenSize); - const numberOfRooms = parseInt(req.body.numberOfRooms); - const numberOfFloors = parseInt(req.body.numberOfFloors); - const floor = parseInt(req.body.floor); - const title = req.body.title; - const shortDescription = req.body.shortDescription; - const streetName = req.body.streetName; - const longDescription = req.body.longDescription; + const price = parseFloat(req.body.price) || null; + const area = parseFloat(req.body.area) || null; + const gardenSize = parseFloat(req.body.gardenSize) || null; + const numberOfRooms = parseInt(req.body.numberOfRooms) || null; + const numberOfFloors = parseInt(req.body.numberOfFloors) || null; + const floor = parseInt(req.body.floor) || null; + const title = req.body.title || ""; + const shortDescription = req.body.shortDescription || ""; + const streetName = req.body.streetName || ""; + const longDescription = req.body.longDescription || ""; realEstate.balcony = balcony; realEstate.elevator = elevator; @@ -267,9 +277,10 @@ const postPublishInputs = async (req, res) => { realEstate.streetName = streetName; realEstate.longDescription = longDescription; - // - console.log("postPublishInputs"); + await realEstate.save(); + + res.redirect(nextStepUrl); }; module.exports = { diff --git a/app/controllers/realEstateFilters.js b/app/controllers/realEstateFilters.js index 252ac46..cff099f 100644 --- a/app/controllers/realEstateFilters.js +++ b/app/controllers/realEstateFilters.js @@ -122,6 +122,8 @@ const getFilters = async (req, res) => { }; const postFilters = async (req, res) => { + // + console.log("postFilters"); const searchRequest = await currentSearchRequest(req); if (!searchRequest || !searchRequest.dataValues) { diff --git a/app/helpers/url.js b/app/helpers/url.js index 7dc0108..b0669ca 100644 --- a/app/helpers/url.js +++ b/app/helpers/url.js @@ -13,7 +13,7 @@ const currentRealEstate = async req => { const realEstateId = req && req.params ? req.params["realEstateId"] : null; if (!realEstateId) return null; - return await getRealEstateById(realEstateId); + return await getRealEstateById(parseInt(realEstateId)); }; module.exports = { currentSearchRequest, diff --git a/app/views/publishEnd.ejs b/app/views/publishEnd.ejs index d751b37..1378dc8 100644 --- a/app/views/publishEnd.ejs +++ b/app/views/publishEnd.ejs @@ -1,5 +1,13 @@
Vaš oglas je spreman za objavu. +
+ +
+
+ Objavi oglas +
+
+
\ No newline at end of file diff --git a/app/views/publishRealEstate.ejs b/app/views/publishRealEstate.ejs index 587e88d..7b5093c 100644 --- a/app/views/publishRealEstate.ejs +++ b/app/views/publishRealEstate.ejs @@ -21,11 +21,6 @@
<%- include("./publishEnd.ejs") %> -
- -
@@ -35,5 +30,10 @@ \ No newline at end of file