select ad type on welcome page; update css

This commit is contained in:
Bilal Catic
2019-11-18 10:48:41 +01:00
parent 860014662a
commit 44565d2f89
4 changed files with 70 additions and 9 deletions

View File

@@ -1,7 +1,42 @@
const { createSearchRequest } = require("../helpers/db/searchRequest");
const { AD_TYPE, AD_CATEGORY } = require("../common/enums");
const getWelcome = (req, res) => { const getWelcome = (req, res) => {
res.render("welcome", { nextStep: "/vrstanekretnine", title: false }); res.render("welcome", {
title: false,
AD_TYPE
});
};
const postWelcome = async (req, res) => {
const adType = parseInt(req.body.adType);
const adTypeStringIds = {
[AD_TYPE.AD_TYPE_SALE.id]: AD_TYPE.AD_TYPE_SALE.stringId,
[AD_TYPE.AD_TYPE_RENT.id]: AD_TYPE.AD_TYPE_RENT.stringId
};
const adTypeStringId =
adTypeStringIds[adType] || AD_TYPE.AD_TYPE_SALE.stringId;
let nextStepUrl = "";
try {
const newSearchRequest = await createSearchRequest({
adType: adTypeStringId,
realEstateType: AD_CATEGORY.FLAT.id
});
nextStepUrl = `/vrstanekretnine/${newSearchRequest.id}`;
} catch (error) {
console.log(error);
nextStepUrl = `/`;
}
res.redirect(nextStepUrl);
}; };
module.exports = { module.exports = {
getWelcome getWelcome,
postWelcome
}; };

View File

@@ -102,3 +102,11 @@ h3 {
border-radius: 4px !important; border-radius: 4px !important;
text-align: center; text-align: center;
} }
.collection a.collection-item {
color: #02adba;
}
.collection a.collection-item:not(.active):hover {
background-color: rgba(2, 173, 186, 0.2);
}

View File

@@ -2,7 +2,7 @@
const express = require("express"); const express = require("express");
const welcome = require("../controllers/welcome").getWelcome; const { getWelcome, postWelcome } = require("../controllers/welcome");
const { const {
getRealEstateTypes, getRealEstateTypes,
postRealEstateTypes postRealEstateTypes
@@ -20,7 +20,8 @@ const { getFilters, postFilters } = require("../controllers/realEstateFilters");
const router = express.Router(); const router = express.Router();
router.get("/", welcome); router.get("/", getWelcome);
router.post("/", postWelcome);
router.get("/vrstanekretnine/:searchRequestId", getRealEstateTypes); router.get("/vrstanekretnine/:searchRequestId", getRealEstateTypes);
router.get("/vrstanekretnine", getRealEstateTypes); router.get("/vrstanekretnine", getRealEstateTypes);

View File

@@ -1,4 +1,3 @@
<!-- -->
<br><br> <br><br>
<div class="row center-align"> <div class="row center-align">
<img src="assets/images/logo.svg" alt="kivi logo" width="160"> <img src="assets/images/logo.svg" alt="kivi logo" width="160">
@@ -8,8 +7,26 @@
<div> Na vaš email. </div> <div> Na vaš email. </div>
<div> BESPLATNO </div> <div> BESPLATNO </div>
</div> </div>
<div class="row center-align"> <form method="POST" name="welcomeForm">
<div class="col s6 push-s3"> <div class="row center-align">
<a href="<%= nextStep %>" class="welcome-center-button btn">Javi mi</a> <div class="col s5 m4 l3 push-s1 push-m2 push-l3">
<a href="#" onclick="saleClick()" class="welcome-center-button btn">Prodaja</a>
</div>
<div class="col s5 m4 l3 push-s1 push-m2 push-l3">
<a href="#" onclick="rentClick()" class="welcome-center-button btn">Najam</a>
</div>
</div> </div>
</div> <input type="hidden" id="adType" name="adType">
</form>
<script>
function saleClick(){
$("#adType").val("<%= AD_TYPE.AD_TYPE_SALE.id %>");
document.welcomeForm.submit();
}
function rentClick(){
$("#adType").val("<%= AD_TYPE.AD_TYPE_RENT.id %>");
document.welcomeForm.submit();
}
</script>