Compare commits
1 Commits
lat-lng-sc
...
rename
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27fa721627 |
@@ -3,8 +3,15 @@
|
||||
|
||||
The purpose of this project is to build a web application that enables subscribing to notifications when new products are published on various ad based marketplaces. The MVP will be only based on OLX.ba
|
||||
|
||||
Create postgres docker image
|
||||
docker build -t marketalerts .
|
||||
|
||||
Run postgres image with:
|
||||
docker run --name pg_test -d -p 5432:5432 marketalerts
|
||||
|
||||
Run with:
|
||||
Run migrations in app folder
|
||||
npx sequelize db:migrate
|
||||
|
||||
Run app with:
|
||||
$ npm install
|
||||
$ npm start
|
||||
|
||||
@@ -2,26 +2,26 @@ const db = require('../models/index');
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { regions } = require('../helpers/codes');
|
||||
|
||||
const gradovi = regions();
|
||||
const cities = regions();
|
||||
|
||||
|
||||
const getGrad = (req,res) => {
|
||||
const getCity = (req,res) => {
|
||||
const nextStep = req.query.nextStep || '/';
|
||||
res.render('grad', {
|
||||
res.render('city', {
|
||||
nextStep,
|
||||
gradovi
|
||||
cities
|
||||
});
|
||||
}
|
||||
|
||||
const postGrad = async (req, res) => {
|
||||
const postCity = async (req, res) => {
|
||||
const request = await currentRERequest(req);
|
||||
const nextStep = req.query.nextStep || `/mjesto/${request.uniqueId}`;
|
||||
request.city = req.body.grad;
|
||||
request.city = req.body.city;
|
||||
await request.save();
|
||||
res.redirect(nextStep)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getGrad,
|
||||
postGrad
|
||||
getCity,
|
||||
postCity
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
const getDobrodosli = (req,res) => {
|
||||
res.render('dobrodosli', { nextStep: '/vrstanekretnine' } );
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDobrodosli
|
||||
};
|
||||
@@ -2,25 +2,24 @@ const db = require('../models/index');
|
||||
const { currentRERequest } = require('../helpers/url');
|
||||
const { places } = require('../helpers/codes');
|
||||
|
||||
const getMjesto = async (req,res) => {
|
||||
const getNeighborhood = async (req,res) => {
|
||||
let request = await currentRERequest(req);
|
||||
const mjesta = places(request.city);
|
||||
const neighborhoods = places(request.city);
|
||||
const nextStep = req.query.nextStep || '/';
|
||||
res.render('mjesto', {
|
||||
res.render('neighborhood', {
|
||||
nextStep,
|
||||
mjesta
|
||||
neighborhoods
|
||||
});
|
||||
}
|
||||
|
||||
const postMjesto = async (req, res) => {
|
||||
const postgNeighborhood = async (req, res) => {
|
||||
let request = await currentRERequest(req);
|
||||
request.place = req.body.mjesto;
|
||||
console.log("AAA ", req.body);
|
||||
request.neighborhood = req.body.neighborhood;
|
||||
await request.save();
|
||||
res.send("Result is " + JSON.stringify(request));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMjesto,
|
||||
postMjesto
|
||||
getNeighborhood,
|
||||
postgNeighborhood
|
||||
};
|
||||
@@ -1,25 +1,24 @@
|
||||
const db = require('../models/index');
|
||||
|
||||
const vrsteNekretnina = [
|
||||
const realEstateTypes = [
|
||||
{ ime: "Kuća", id: "kuca" },
|
||||
{ ime: "Stan", id: "stan" },
|
||||
{ ime: "Vikendica", id: "vikendica" }
|
||||
];
|
||||
|
||||
|
||||
const getVrstaNekretnine = (req,res) => {
|
||||
const getRealEstateTypes = (req,res) => {
|
||||
const nextStep = req.query.nextStep;
|
||||
res.render('vrsta_nekretnine', {
|
||||
res.render('real_estate_type', {
|
||||
nextStep,
|
||||
vrste: vrsteNekretnina
|
||||
realEstateTypes: realEstateTypes
|
||||
});
|
||||
}
|
||||
|
||||
const postVrstaNekretnine = (req, res) => {
|
||||
const postRealEstateTypes = (req, res) => {
|
||||
let nextStep = req.query.nextStep;
|
||||
|
||||
db.RealEstateRequest.create({
|
||||
realEstateType: req.body.vrsta
|
||||
realEstateType: req.body.realestatetype
|
||||
}).then( (result) => {
|
||||
nextStep = nextStep || `/grad/${result.uniqueId}`;
|
||||
res.redirect(nextStep);
|
||||
@@ -30,6 +29,6 @@ const postVrstaNekretnine = (req, res) => {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getVrstaNekretnine,
|
||||
postVrstaNekretnine
|
||||
getRealEstateTypes,
|
||||
postRealEstateTypes
|
||||
};
|
||||
7
app/controllers/welcome.js
Normal file
7
app/controllers/welcome.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const getWelcome = (req,res) => {
|
||||
res.render('welcome', { nextStep: '/vrstanekretnine' } );
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getWelcome
|
||||
};
|
||||
@@ -5,7 +5,6 @@ const currentRERequest = async (req) => {
|
||||
if(!uniqueId) return null;
|
||||
|
||||
const request = await db.RealEstateRequest.findOne({ where: {uniqueId} });
|
||||
console.log("Request ", request);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
.dobrodosli-center-button {
|
||||
.welcome-center-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dobrodosli-big-logo {
|
||||
.welcome-big-logo {
|
||||
font-size: 200pt;
|
||||
background-image: url(./images/logo.png);
|
||||
background-size: contain;
|
||||
|
||||
31
app/views/city.ejs
Normal file
31
app/views/city.ejs
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="row center-align">
|
||||
<h2>U kojoj regiji tražite nekretninu?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-city">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const city of cities) { %>
|
||||
<li class="collection-item" >
|
||||
<div id="<%= city.id %>" ><%= city.ime %>
|
||||
<a href="#!" class="secondary-content">
|
||||
<i class="material-icons">send</i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="city" id="city" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#city").val(clickedId);
|
||||
$("#form-city").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<div class="row center-align">
|
||||
<h2>U kojoj regiji tražite nekretninu?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-grad">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const grad of gradovi) { %>
|
||||
<li class="collection-item" > <div id="<%= grad.id %>" ><%= grad.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="grad" id="grad" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#grad").val(clickedId);
|
||||
$("#form-grad").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<div class="row center-align">
|
||||
<h2>U kojem mjestu tražite nekretninu?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-mjesto">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const mjesto of mjesta) { %>
|
||||
<li class="collection-item" > <div id="<%= mjesto.id %>" ><%= mjesto.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="mjesto" id="mjesto" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#mjesto").val(clickedId);
|
||||
$("#form-mjesto").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
31
app/views/neighborhood.ejs
Normal file
31
app/views/neighborhood.ejs
Normal file
@@ -0,0 +1,31 @@
|
||||
<div class="row center-align">
|
||||
<h2>U kojem mjestu tražite nekretninu?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-neighborhood">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const neighborhood of neighborhoods) { %>
|
||||
<li class="collection-item" >
|
||||
<div id="<%= neighborhood.id %>" ><%= neighborhood.ime %>
|
||||
<a href="#!" class="secondary-content">
|
||||
<i class="material-icons">send</i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="neighborhood" id="neighborhoods" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#neighborhood").val(clickedId);
|
||||
$("#form-neighborhood").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
35
app/views/real_estate_type.ejs
Normal file
35
app/views/real_estate_type.ejs
Normal file
@@ -0,0 +1,35 @@
|
||||
<div class="row center-align">
|
||||
<h2>Koju nekretninu tražite?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-real-estate-type">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(const realEstatetype of realEstateTypes) { %>
|
||||
<li class="collection-item" >
|
||||
<div id="<%= realEstatetype.id %>" ><%= realEstatetype.ime %>
|
||||
<a href="#!" class="secondary-content">
|
||||
<i class="material-icons">send</i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="realestatetype" id="realestatetype" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#realestatetype").val(clickedId);
|
||||
$("#form-real-estate-type").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<div class="row center-align">
|
||||
<h2>Koju nekretninu tražite?</h2>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="form-vrsta">
|
||||
<div class="row center-align">
|
||||
<ul class="collection with-header">
|
||||
<% for(let vrsta of vrste) { %>
|
||||
<li class="collection-item" > <div id="<%= vrsta.id %>" ><%= vrsta.ime %><a href="#!" class="secondary-content"><i class="material-icons">send</i></a></div></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<input type="hidden" name="vrsta" id="vrsta" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( () => {
|
||||
$(".collection-item").click( (e) => {
|
||||
const clickedId = $(e.target).attr("id");
|
||||
$("#vrsta").val(clickedId);
|
||||
$("#form-vrsta").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
<!-- -->
|
||||
<div class="row center-align">
|
||||
<span class="dobrodosli-big-logo">🤙</span>
|
||||
<span class="welcome-big-logo">🤙</span>
|
||||
</div>
|
||||
<div class="row center-align">
|
||||
<div>Sve nekretnine dostupne u oglasima.</div>
|
||||
@@ -10,7 +10,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s6 push-s3">
|
||||
<a href="<%= nextStep %>" class="dobrodosli-center-button waves-effect waves-light btn">
|
||||
<a href="<%= nextStep %>" class="welcome-center-button waves-effect waves-light btn">
|
||||
Javi mi
|
||||
</a>
|
||||
</div>
|
||||
26
index.js
26
index.js
@@ -1,7 +1,7 @@
|
||||
const dobrodosli = require('./app/controllers/dobrodosli').getDobrodosli;
|
||||
const { getVrstaNekretnine, postVrstaNekretnine} = require('./app/controllers/vrsta_nekretnine');
|
||||
const { getGrad, postGrad } = require('./app/controllers/grad');
|
||||
const { getMjesto, postMjesto } = require('./app/controllers/mjesto');
|
||||
const welcome = require('./app/controllers/welcome').getWelcome;
|
||||
const { getRealEstateTypes, postRealEstateTypes} = require('./app/controllers/real_estate_types');
|
||||
const { getCity, postCity } = require('./app/controllers/city');
|
||||
const { getNeighborhood, postgNeighborhood } = require('./app/controllers/neighborhoods');
|
||||
|
||||
let express = require("express");
|
||||
const path = require("path");
|
||||
@@ -108,18 +108,18 @@ app.post("/api/payforalert", function(request, response) {
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/', dobrodosli);
|
||||
app.get('/vrstanekretnine/:request_id', getVrstaNekretnine);
|
||||
app.get('/vrstanekretnine', getVrstaNekretnine);
|
||||
app.get('/', welcome);
|
||||
app.get('/vrstanekretnine/:request_id', getRealEstateTypes);
|
||||
app.get('/vrstanekretnine', getRealEstateTypes);
|
||||
|
||||
app.post('/vrstanekretnine/:request_id', postVrstaNekretnine);
|
||||
app.post('/vrstanekretnine', postVrstaNekretnine);
|
||||
app.post('/vrstanekretnine/:request_id', postRealEstateTypes);
|
||||
app.post('/vrstanekretnine', postRealEstateTypes);
|
||||
|
||||
app.get('/grad/:request_id', getGrad);
|
||||
app.post('/grad/:request_id', postGrad);
|
||||
app.get('/grad/:request_id', getCity);
|
||||
app.post('/grad/:request_id', postCity);
|
||||
|
||||
app.get('/mjesto/:request_id', getMjesto);
|
||||
app.post('/mjesto/:request_id', postMjesto);
|
||||
app.get('/mjesto/:request_id', getNeighborhood);
|
||||
app.post('/mjesto/:request_id', postgNeighborhood);
|
||||
|
||||
|
||||
app.use('/assets', express.static('./app/public'))
|
||||
|
||||
Reference in New Issue
Block a user