Added email input for KiviOriginals table.

This commit is contained in:
Naida Vatric
2020-02-09 22:25:05 +01:00
parent 86c7d23efd
commit 22c1982ef6
6 changed files with 59 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
const { currentRealEstate } = require("../helpers/url");
const { createRealEstate } = require("../helpers/db/realEstate");
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
const { getKiviOriginalById } = require("../helpers/db/kiviOriginal");
const {
AD_CATEGORY,
@@ -174,9 +174,11 @@ const postPublishInputs = async (req, res) => {
return;
}
//const nextStepPage = req.query.nextStep || "pregled";
// const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
const nextStepUrl = "/unsubscribe/";
const kiviOriginal = await getKiviOriginalById(
parseInt(realEstate.dataValues.agencyObjectId)
);
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
const balcony = req.body.balcony === "on";
const elevator = req.body.elevator === "on";
@@ -236,6 +238,8 @@ const postPublishInputs = async (req, res) => {
const locationLat = req.body.lat || null;
const locationLong = req.body.lng || null;
//Contact email saved in other table
const contactEmail = req.body.email || "";
realEstate.balcony = balcony;
realEstate.elevator = elevator;
@@ -284,9 +288,13 @@ const postPublishInputs = async (req, res) => {
realEstate.locationLat = locationLat;
realEstate.locationLong = locationLong;
kiviOriginal.email = contactEmail;
await realEstate.save();
res.redirect(nextStepUrl);
await kiviOriginal.save();
res.redirect(nextStepPage);
};
module.exports = {

View File

@@ -0,0 +1,8 @@
const publishSuccess = async (req, res) => {
const title = "Uspjeh!";
res.render("publishSuccess", { title });
};
module.exports = {
publishSuccess
};