Added email input for KiviOriginals table.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const { currentRealEstate } = require("../helpers/url");
|
const { currentRealEstate } = require("../helpers/url");
|
||||||
const { createRealEstate } = require("../helpers/db/realEstate");
|
const { createRealEstate } = require("../helpers/db/realEstate");
|
||||||
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
|
const { getKiviOriginalById } = require("../helpers/db/kiviOriginal");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
AD_CATEGORY,
|
AD_CATEGORY,
|
||||||
@@ -174,9 +174,11 @@ const postPublishInputs = async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//const nextStepPage = req.query.nextStep || "pregled";
|
const kiviOriginal = await getKiviOriginalById(
|
||||||
// const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`;
|
parseInt(realEstate.dataValues.agencyObjectId)
|
||||||
const nextStepUrl = "/unsubscribe/";
|
);
|
||||||
|
|
||||||
|
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
|
||||||
|
|
||||||
const balcony = req.body.balcony === "on";
|
const balcony = req.body.balcony === "on";
|
||||||
const elevator = req.body.elevator === "on";
|
const elevator = req.body.elevator === "on";
|
||||||
@@ -236,6 +238,8 @@ const postPublishInputs = async (req, res) => {
|
|||||||
|
|
||||||
const locationLat = req.body.lat || null;
|
const locationLat = req.body.lat || null;
|
||||||
const locationLong = req.body.lng || null;
|
const locationLong = req.body.lng || null;
|
||||||
|
//Contact email saved in other table
|
||||||
|
const contactEmail = req.body.email || "";
|
||||||
|
|
||||||
realEstate.balcony = balcony;
|
realEstate.balcony = balcony;
|
||||||
realEstate.elevator = elevator;
|
realEstate.elevator = elevator;
|
||||||
@@ -284,9 +288,13 @@ const postPublishInputs = async (req, res) => {
|
|||||||
realEstate.locationLat = locationLat;
|
realEstate.locationLat = locationLat;
|
||||||
realEstate.locationLong = locationLong;
|
realEstate.locationLong = locationLong;
|
||||||
|
|
||||||
|
kiviOriginal.email = contactEmail;
|
||||||
|
|
||||||
await realEstate.save();
|
await realEstate.save();
|
||||||
|
|
||||||
res.redirect(nextStepUrl);
|
await kiviOriginal.save();
|
||||||
|
|
||||||
|
res.redirect(nextStepPage);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
8
app/controllers/publishSuccess.js
Normal file
8
app/controllers/publishSuccess.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const publishSuccess = async (req, res) => {
|
||||||
|
const title = "Uspjeh!";
|
||||||
|
res.render("publishSuccess", { title });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
publishSuccess
|
||||||
|
};
|
||||||
@@ -6,6 +6,15 @@ const createKiviOriginal = async (kiviAdFields = {}) => {
|
|||||||
return await db.KiviOriginal.create(kiviAdFields);
|
return await db.KiviOriginal.create(kiviAdFields);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
const getKiviOriginalById = async id => {
|
||||||
createKiviOriginal
|
try {
|
||||||
|
return db.KiviOriginal.findByPk(id);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("kiviOriginal.js", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = {
|
||||||
|
createKiviOriginal,
|
||||||
|
getKiviOriginalById
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const {
|
|||||||
postQueryReview
|
postQueryReview
|
||||||
} = require("../controllers/queryReview");
|
} = require("../controllers/queryReview");
|
||||||
const { getGoAgain } = require("../controllers/goAgain");
|
const { getGoAgain } = require("../controllers/goAgain");
|
||||||
|
const { publishSuccess } = require("../controllers/publishSuccess");
|
||||||
const { getLocation, postLocation } = require("../controllers/location");
|
const { getLocation, postLocation } = require("../controllers/location");
|
||||||
const { getUnsubscribe } = require("../controllers/unsubscribe");
|
const { getUnsubscribe } = require("../controllers/unsubscribe");
|
||||||
const { getRealEstates } = require("../controllers/realEstates");
|
const { getRealEstates } = require("../controllers/realEstates");
|
||||||
@@ -57,6 +58,8 @@ router.get("/odjava/:searchRequestId", getUnsubscribe);
|
|||||||
|
|
||||||
router.get("/ponovo", getGoAgain);
|
router.get("/ponovo", getGoAgain);
|
||||||
|
|
||||||
|
router.get("/uspjesnaobjava", publishSuccess);
|
||||||
|
|
||||||
router.get("/nekretnine/:searchRequestId", getRealEstates);
|
router.get("/nekretnine/:searchRequestId", getRealEstates);
|
||||||
|
|
||||||
router.get("/redirect/:id", getRedirect);
|
router.get("/redirect/:id", getRedirect);
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
<br>
|
<br>
|
||||||
<div class="row center-align">
|
<div class="row center-align">
|
||||||
Vaš oglas je spreman za objavu.
|
<h3>Vaš oglas je spreman!</h3>
|
||||||
|
Unesite kontakt email i objavite oglas.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="row center-align input-field col s3 m4 l5">
|
||||||
|
<input
|
||||||
|
id="email"
|
||||||
|
name="email"
|
||||||
|
type="email"
|
||||||
|
>
|
||||||
|
<label for="email">Email</label>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<br>
|
||||||
|
<div class="row center-align">
|
||||||
<div class="col s6 push-s3">
|
<div class="col s6 push-s3">
|
||||||
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">Objavi oglas</a>
|
<a id="submit" href="#" form="publishForm" class="welcome-center-button waves-effect waves-light btn">Objavi oglas</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
11
app/views/publishSuccess.ejs
Normal file
11
app/views/publishSuccess.ejs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<br>
|
||||||
|
<div class="row center-align">
|
||||||
|
<p>Vaš oglas je spašen u Kivi bazu.</p>
|
||||||
|
<br>
|
||||||
|
<div class="row center-align">
|
||||||
|
<img src="../assets/images/logo.svg" alt="kivi logo" width="160">
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<p>Poslali smo potvrdni email sa detaljima oglasa na Vašu email adresu.</p>
|
||||||
|
<a href="/" class="">Nova pretraga</a>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user