From 7b97835e8b1d4435c9db8f4ce9c030ba83001ef5 Mon Sep 17 00:00:00 2001 From: Naida Vatric Date: Mon, 3 Feb 2020 14:57:36 +0100 Subject: [PATCH] WiP Started input form. --- app/controllers/publishRealEstate.js | 34 +++++++++++++++++++++++ app/controllers/publishRealEstateTypes.js | 8 ++---- app/routes/index.js | 7 +++++ app/views/publishRealEstate.ejs | 4 +++ 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 app/controllers/publishRealEstate.js create mode 100644 app/views/publishRealEstate.ejs diff --git a/app/controllers/publishRealEstate.js b/app/controllers/publishRealEstate.js new file mode 100644 index 0000000..90cf359 --- /dev/null +++ b/app/controllers/publishRealEstate.js @@ -0,0 +1,34 @@ +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 getPublishInputs = async (req, res) => { + const realEstate = await currentRealEstate(req); + + if (!realEstate || !realEstate.dataValues) { + res.render("notFound", { title: " " }); + return; + } + + const title = "Podaci o nekretnini"; + + res.render("publishRealEstate", { + title + }); +}; + +const postPublishInputs = async (req, res) => { + const realEstate = await currentRealEstate(req); + + if (!realEstate || !realEstate.dataValues) { + res.render("notFound", { title: " " }); + return; + } +}; + +module.exports = { + getPublishInputs, + postPublishInputs +}; diff --git a/app/controllers/publishRealEstateTypes.js b/app/controllers/publishRealEstateTypes.js index 7965add..d38c3a3 100644 --- a/app/controllers/publishRealEstateTypes.js +++ b/app/controllers/publishRealEstateTypes.js @@ -53,10 +53,8 @@ const postPublishTypes = async (req, res) => { res.render("notFound", { title: " " }); return; } - // Sta je nextStepPage - treba napraviti !!!! - ///// - ///// - const nextStepPage = req.query.nextStep || "/lokacija"; + + const nextStepPage = req.query.nextStep || "podacionekretnini"; let nextStepUrl = ""; if (realEstate && realEstate.id) { @@ -79,7 +77,7 @@ const postPublishTypes = async (req, res) => { agencyObjectId: newKiviOriginal.kiviAdId }); - //Da li ovaj id ili kivioriginal id + //Da li ovaj id ili kivioriginal id ??? nextStepUrl = `/${nextStepPage}/${newRealEstate.id}`; } catch (error) { console.log(error); diff --git a/app/routes/index.js b/app/routes/index.js index 65b67a2..b068e32 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -11,6 +11,10 @@ const { getPublishTypes, postPublishTypes } = require("../controllers/publishRealEstateTypes"); +const { + getPublishInputs, + postPublishInputs +} = require("../controllers/publishRealEstate"); const { getQueryReview, postQueryReview @@ -37,6 +41,9 @@ router.get("/objavinekretninu", getPublishTypes); router.post("/objavinekretninu/:realEstateId", postPublishTypes); router.post("/objavinekretninu", postPublishTypes); +router.get("/podacionekretnini/:realEstateId", getPublishInputs); +router.post("/podacionekretnini/:realEstateId", postPublishInputs); + router.get("/lokacija/:searchRequestId", getLocation); router.post("/lokacija/:searchRequestId", postLocation); diff --git a/app/views/publishRealEstate.ejs b/app/views/publishRealEstate.ejs new file mode 100644 index 0000000..c47862c --- /dev/null +++ b/app/views/publishRealEstate.ejs @@ -0,0 +1,4 @@ +
+
+ Work in progres... +
\ No newline at end of file