Changed editing redirection.
This commit is contained in:
8
app/controllers/editSuccess.js
Normal file
8
app/controllers/editSuccess.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const editSuccess = async (req, res) => {
|
||||
const title = "Uspjeh!";
|
||||
res.render("editSuccess", { title });
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
editSuccess
|
||||
};
|
||||
@@ -203,8 +203,11 @@ const postPublishInputs = async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
|
||||
const editingRealEstate = req.body.editingRealEstate;
|
||||
|
||||
const nextStepPage = editingRealEstate
|
||||
? req.query.nextStep || "/uspjesnaizmjena"
|
||||
: req.query.nextStep || "/uspjesnaobjava";
|
||||
//Request body
|
||||
//console.log("Body:", req.body);
|
||||
|
||||
@@ -334,9 +337,15 @@ const postPublishInputs = async (req, res) => {
|
||||
|
||||
await kiviOriginal.save();
|
||||
|
||||
//Calling function to notify real estate owner that ads is published on Kivi page after 1 sec
|
||||
setTimeout(notifyForNewAdPublish, 1000, realEstate, kiviOriginal);
|
||||
//Calling function to notify users of new real estate after 2 min
|
||||
//Calling function to notify real estate owner that ads is published or edited on Kivi page after 1 sec
|
||||
setTimeout(
|
||||
notifyForNewAdPublish,
|
||||
1000,
|
||||
realEstate,
|
||||
kiviOriginal,
|
||||
editingRealEstate
|
||||
);
|
||||
//Calling function to notify users of new real estate (or edited realestate) after 2 min
|
||||
setTimeout(notifyForNewRealEstates, 1000 * 60 * 2, [realEstate]);
|
||||
|
||||
res.redirect(nextStepPage);
|
||||
|
||||
@@ -205,6 +205,7 @@ const generateCheckUpEmail = searchRequest => {
|
||||
const generateNewAdPublishEmail = (
|
||||
realEstate,
|
||||
kiviOriginal,
|
||||
editingRealEstate,
|
||||
numberOfMatchingRequests
|
||||
) => {
|
||||
let countingPrefix;
|
||||
@@ -224,8 +225,12 @@ const generateNewAdPublishEmail = (
|
||||
countingSufix = "zahtjeva";
|
||||
}
|
||||
|
||||
const successIntro = editingRealEstate
|
||||
? `<div>Uspješno ste izmijenili oglas za Vašu nekretninu na <strong>Kivi.ba.</strong><div>`
|
||||
: `<div>Uspješno ste objavili oglas za Vašu nekretninu na <strong>Kivi.ba.</strong><div>`;
|
||||
|
||||
return `<h3>${stagingTag}Zdravo</h3>
|
||||
<div>Uspješno ste objavili oglas za Vašu nekretninu na <strong>Kivi.ba.</strong><div>
|
||||
${successIntro}
|
||||
<br/>
|
||||
<div>U Kivi bazi trenutno ${countingPrefix} ${numberOfMatchingRequests} ${countingSufix} za nekretninom kao sto je Vaša.</div>
|
||||
<br />
|
||||
|
||||
@@ -22,6 +22,7 @@ const {
|
||||
} = require("../controllers/queryReview");
|
||||
const { getGoAgain } = require("../controllers/goAgain");
|
||||
const { publishSuccess } = require("../controllers/publishSuccess");
|
||||
const { editSuccess } = require("../controllers/editSuccess");
|
||||
const { getLocation, postLocation } = require("../controllers/location");
|
||||
const { getUnsubscribe } = require("../controllers/unsubscribe");
|
||||
const { getDeletePublishedAd } = require("../controllers/deleteRealEstate");
|
||||
@@ -66,6 +67,8 @@ router.get("/ponovo", getGoAgain);
|
||||
|
||||
router.get("/uspjesnaobjava", publishSuccess);
|
||||
|
||||
router.get("/uspjesnaizmjena", editSuccess);
|
||||
|
||||
router.get("/nekretnine/:searchRequestId", getRealEstates);
|
||||
|
||||
router.get("/redirect/:id", getRedirect);
|
||||
|
||||
@@ -148,11 +148,17 @@ const checkUpNotify = async () => {
|
||||
await Promise.all(asyncSendEmailActions);
|
||||
};
|
||||
|
||||
const notifyForNewAdPublish = async (realEstate, kiviOriginal) => {
|
||||
const notifyForNewAdPublish = async (
|
||||
realEstate,
|
||||
kiviOriginal,
|
||||
editingRealEstate
|
||||
) => {
|
||||
// console.log("Real estate:", realEstate);
|
||||
// console.log("Kivi original:", kiviOriginal);
|
||||
const email = kiviOriginal.dataValues.email;
|
||||
const emailSubject = `${stagingTag}Kivi - Uspješno ste objavili oglas!`;
|
||||
const emailSubject = editingRealEstate
|
||||
? `${stagingTag}Kivi - Uspješno ste izmijenili oglas!`
|
||||
: `${stagingTag}Kivi - Uspješno ste objavili oglas!`;
|
||||
const matches = await matchRealEstates([realEstate]);
|
||||
//Counting number of matching req
|
||||
let numberOfMatchingRequests = 0;
|
||||
@@ -163,6 +169,7 @@ const notifyForNewAdPublish = async (realEstate, kiviOriginal) => {
|
||||
const emailContent = generateNewAdPublishEmail(
|
||||
realEstate,
|
||||
kiviOriginal,
|
||||
editingRealEstate,
|
||||
numberOfMatchingRequests
|
||||
);
|
||||
|
||||
|
||||
11
app/views/editSuccess.ejs
Normal file
11
app/views/editSuccess.ejs
Normal file
@@ -0,0 +1,11 @@
|
||||
<br>
|
||||
<div class="row center-align">
|
||||
<p>Vaš oglas je izmijenjen u Kivi bazi.</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 izmijenjenim detaljima oglasa na Vašu email adresu.</p>
|
||||
<a href="/" class="">Nova pretraga</a>
|
||||
</div>
|
||||
@@ -31,6 +31,7 @@
|
||||
<%- include("./publishEnd.ejs") %>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="editingRealEstate" id="editingRealEstate" value="">
|
||||
|
||||
|
||||
</form>
|
||||
@@ -89,6 +90,9 @@
|
||||
$(document).ready(function(){
|
||||
$('.tabs').tabs();
|
||||
|
||||
const editingRealEstate = <%- editingRealEstate %>;
|
||||
$("#editingRealEstate").val(editingRealEstate);
|
||||
|
||||
// Manual dropzone init
|
||||
const dropzoneOptions = {
|
||||
url: "/photos-upload", //can be a function that returns url ?
|
||||
|
||||
Reference in New Issue
Block a user