Changed id type to uuid.
This commit is contained in:
@@ -165,7 +165,7 @@ const BASIC_INPUT_PUBLISH = [
|
|||||||
const BASIC_SEGMENT_PUBLISH = [
|
const BASIC_SEGMENT_PUBLISH = [
|
||||||
{
|
{
|
||||||
dbField: "furnishingType",
|
dbField: "furnishingType",
|
||||||
title: "Namješten?",
|
title: "Namještaj",
|
||||||
values: Object.keys(FURNISHING_TYPE).map(key => FURNISHING_TYPE[key]),
|
values: Object.keys(FURNISHING_TYPE).map(key => FURNISHING_TYPE[key]),
|
||||||
categoriesToShow: [
|
categoriesToShow: [
|
||||||
AD_CATEGORY.FLAT,
|
AD_CATEGORY.FLAT,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const { currentRealEstate } = require("../helpers/url");
|
const { findRealEstateByAgencyId } = require("../helpers/db/realEstate");
|
||||||
const { createRealEstate } = require("../helpers/db/realEstate");
|
const { currentKiviRealEstate } = require("../helpers/url");
|
||||||
const { getKiviOriginalById } = require("../helpers/db/kiviOriginal");
|
|
||||||
|
|
||||||
const validate = require("validate.js");
|
const validate = require("validate.js");
|
||||||
|
|
||||||
@@ -20,7 +19,9 @@ const {
|
|||||||
} = require("../common/publishEnums");
|
} = require("../common/publishEnums");
|
||||||
|
|
||||||
const getPublishInputs = async (req, res) => {
|
const getPublishInputs = async (req, res) => {
|
||||||
const realEstate = await currentRealEstate(req);
|
const kiviOriginal = await currentKiviRealEstate(req);
|
||||||
|
|
||||||
|
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
||||||
|
|
||||||
if (!realEstate || !realEstate.dataValues) {
|
if (!realEstate || !realEstate.dataValues) {
|
||||||
res.render("notFound", { title: " " });
|
res.render("notFound", { title: " " });
|
||||||
@@ -170,17 +171,15 @@ const getPublishInputs = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const postPublishInputs = async (req, res) => {
|
const postPublishInputs = async (req, res) => {
|
||||||
const realEstate = await currentRealEstate(req);
|
const kiviOriginal = await currentKiviRealEstate(req);
|
||||||
|
|
||||||
|
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
||||||
|
|
||||||
if (!realEstate || !realEstate.dataValues) {
|
if (!realEstate || !realEstate.dataValues) {
|
||||||
res.render("notFound", { title: " " });
|
res.render("notFound", { title: " " });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const kiviOriginal = await getKiviOriginalById(
|
|
||||||
parseInt(realEstate.dataValues.agencyObjectId)
|
|
||||||
);
|
|
||||||
|
|
||||||
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
|
const nextStepPage = req.query.nextStep || "/uspjesnaobjava";
|
||||||
|
|
||||||
const balcony = req.body.balcony === "on";
|
const balcony = req.body.balcony === "on";
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
const { currentRealEstate } = require("../helpers/url");
|
const { currentKiviRealEstate } = require("../helpers/url");
|
||||||
const { createRealEstate } = require("../helpers/db/realEstate");
|
const {
|
||||||
|
createRealEstate,
|
||||||
|
findRealEstateByAgencyId
|
||||||
|
} = require("../helpers/db/realEstate");
|
||||||
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
|
const { createKiviOriginal } = require("../helpers/db/kiviOriginal");
|
||||||
|
|
||||||
const { AD_CATEGORY, AD_TYPE, AD_AGENCY } = require("../common/enums");
|
const { AD_CATEGORY, AD_TYPE, AD_AGENCY } = require("../common/enums");
|
||||||
|
|
||||||
const getPublishTypes = async (req, res) => {
|
const getPublishTypes = async (req, res) => {
|
||||||
const realEstate = await currentRealEstate(req);
|
const kiviOriginal = await currentKiviRealEstate(req);
|
||||||
|
|
||||||
|
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
||||||
|
|
||||||
const title = "Koju nekretninu nudite?";
|
const title = "Koju nekretninu nudite?";
|
||||||
let selectedAdType = AD_TYPE.AD_TYPE_SALE.id;
|
let selectedAdType = AD_TYPE.AD_TYPE_SALE.id;
|
||||||
@@ -32,7 +37,9 @@ const getPublishTypes = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const postPublishTypes = async (req, res) => {
|
const postPublishTypes = async (req, res) => {
|
||||||
const realEstate = await currentRealEstate(req);
|
const kiviOriginal = await currentKiviRealEstate(req);
|
||||||
|
|
||||||
|
const realEstate = await findRealEstateByAgencyId(kiviOriginal.kiviAdId);
|
||||||
|
|
||||||
const adType = parseInt(req.body.adType);
|
const adType = parseInt(req.body.adType);
|
||||||
|
|
||||||
@@ -57,8 +64,10 @@ const postPublishTypes = async (req, res) => {
|
|||||||
const nextStepPage = req.query.nextStep || "podacionekretnini";
|
const nextStepPage = req.query.nextStep || "podacionekretnini";
|
||||||
|
|
||||||
let nextStepUrl = "";
|
let nextStepUrl = "";
|
||||||
if (realEstate && realEstate.id) {
|
if (kiviOriginal && kiviOriginal.kiviAdId && realEstate && realEstate.id) {
|
||||||
nextStepUrl = `/${nextStepPage}/${realEstate.id}`;
|
//
|
||||||
|
nextStepUrl = `/${nextStepPage}/${kiviOriginal.kiviAdId}`;
|
||||||
|
|
||||||
realEstate.adType = adTypeStringId;
|
realEstate.adType = adTypeStringId;
|
||||||
realEstate.realEstateType = selectedRealEstateType;
|
realEstate.realEstateType = selectedRealEstateType;
|
||||||
|
|
||||||
@@ -77,8 +86,7 @@ const postPublishTypes = async (req, res) => {
|
|||||||
agencyObjectId: newKiviOriginal.kiviAdId
|
agencyObjectId: newKiviOriginal.kiviAdId
|
||||||
});
|
});
|
||||||
|
|
||||||
//Da li ovaj id ili kivioriginal id ???
|
nextStepUrl = `/${nextStepPage}/${newKiviOriginal.kiviAdId}`;
|
||||||
nextStepUrl = `/${nextStepPage}/${newRealEstate.id}`;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
nextStepUrl = `/`;
|
nextStepUrl = `/`;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const postWelcome = async (req, res) => {
|
|||||||
const adTypeStringId = getAdTypeString(publishAdType);
|
const adTypeStringId = getAdTypeString(publishAdType);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Firt we create new Kivi Ad Original object in db then new Real Estate
|
//First we create new Kivi Ad Original object in db then new Real Estate
|
||||||
//Problem with id-s
|
//Problem with id-s
|
||||||
const newKiviOriginal = await createKiviOriginal({
|
const newKiviOriginal = await createKiviOriginal({
|
||||||
email: ""
|
email: ""
|
||||||
@@ -42,13 +42,13 @@ const postWelcome = async (req, res) => {
|
|||||||
const newRealEstate = await createRealEstate({
|
const newRealEstate = await createRealEstate({
|
||||||
adType: adTypeStringId,
|
adType: adTypeStringId,
|
||||||
realEstateType: AD_CATEGORY.FLAT.id,
|
realEstateType: AD_CATEGORY.FLAT.id,
|
||||||
//Temp variables because of the not null constraints
|
//Temp variable because of the not null constraints
|
||||||
url: "http://localhost:5000/",
|
url: "http://localhost:5000/",
|
||||||
originAgencyName: AD_AGENCY.KIVI,
|
originAgencyName: AD_AGENCY.KIVI,
|
||||||
agencyObjectId: newKiviOriginal.kiviAdId
|
agencyObjectId: newKiviOriginal.kiviAdId
|
||||||
});
|
});
|
||||||
|
|
||||||
nextStepUrl = `/objavinekretninu/${newRealEstate.id}`;
|
nextStepUrl = `/objavinekretninu/${newKiviOriginal.kiviAdId}`;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
nextStepUrl = `/`;
|
nextStepUrl = `/`;
|
||||||
|
|||||||
@@ -89,6 +89,16 @@ const createRealEstate = async (realEstateFields = {}) => {
|
|||||||
return await db.RealEstate.create(realEstateFields);
|
return await db.RealEstate.create(realEstateFields);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const findRealEstateByAgencyId = async kiviId => {
|
||||||
|
try {
|
||||||
|
return db.RealEstate.findOne({
|
||||||
|
where: { agencyObjectId: kiviId }
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("realEstate.js", error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
const findRealEstatesForSearchRequest = async (searchRequest, maxResults) => {
|
||||||
const {
|
const {
|
||||||
priceMin,
|
priceMin,
|
||||||
@@ -354,5 +364,6 @@ module.exports = {
|
|||||||
bulkUpsertRealEstates,
|
bulkUpsertRealEstates,
|
||||||
getRealEstateById,
|
getRealEstateById,
|
||||||
createRealEstate,
|
createRealEstate,
|
||||||
findRealEstatesForSearchRequest
|
findRealEstatesForSearchRequest,
|
||||||
|
findRealEstateByAgencyId
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const { getSearchRequest } = require("./db/searchRequest");
|
const { getSearchRequest } = require("./db/searchRequest");
|
||||||
const { getRealEstateById } = require("./db/realEstate");
|
const { getRealEstateById } = require("./db/realEstate");
|
||||||
|
const { getKiviOriginalById } = require("./db/kiviOriginal");
|
||||||
|
|
||||||
const currentSearchRequest = async req => {
|
const currentSearchRequest = async req => {
|
||||||
const searchRequestId =
|
const searchRequestId =
|
||||||
@@ -15,7 +16,16 @@ const currentRealEstate = async req => {
|
|||||||
|
|
||||||
return await getRealEstateById(parseInt(realEstateId));
|
return await getRealEstateById(parseInt(realEstateId));
|
||||||
};
|
};
|
||||||
|
const currentKiviRealEstate = async req => {
|
||||||
|
const kiviRealEstateId =
|
||||||
|
req && req.params ? req.params["kiviRealEstateId"] : null;
|
||||||
|
if (!kiviRealEstateId) return null;
|
||||||
|
|
||||||
|
return await getKiviOriginalById(kiviRealEstateId);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
currentSearchRequest,
|
currentSearchRequest,
|
||||||
currentRealEstate
|
currentRealEstate,
|
||||||
|
currentKiviRealEstate
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ module.exports = {
|
|||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
const tableFields = {
|
const tableFields = {
|
||||||
kiviAdId: {
|
kiviAdId: {
|
||||||
type: Sequelize.BIGINT,
|
type: Sequelize.UUID,
|
||||||
autoIncrement: true,
|
defaultValue: Sequelize.UUIDV4,
|
||||||
|
allowNull: false,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
email: Sequelize.TEXT,
|
email: Sequelize.TEXT,
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ module.exports = (sequalize, DataTypes) => {
|
|||||||
"KiviOriginal",
|
"KiviOriginal",
|
||||||
{
|
{
|
||||||
kiviAdId: {
|
kiviAdId: {
|
||||||
type: DataTypes.BIGINT,
|
type: DataTypes.UUID,
|
||||||
autoIncrement: true,
|
defaultValue: DataTypes.UUIDV4,
|
||||||
|
allowNull: false,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
email: DataTypes.TEXT
|
email: DataTypes.TEXT
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ router.get("/vrstanekretnine", getRealEstateTypes);
|
|||||||
router.post("/vrstanekretnine/:searchRequestId", postRealEstateTypes);
|
router.post("/vrstanekretnine/:searchRequestId", postRealEstateTypes);
|
||||||
router.post("/vrstanekretnine", postRealEstateTypes);
|
router.post("/vrstanekretnine", postRealEstateTypes);
|
||||||
|
|
||||||
router.get("/objavinekretninu/:realEstateId", getPublishTypes);
|
router.get("/objavinekretninu/:kiviRealEstateId", getPublishTypes);
|
||||||
router.get("/objavinekretninu", getPublishTypes);
|
router.get("/objavinekretninu", getPublishTypes);
|
||||||
router.post("/objavinekretninu/:realEstateId", postPublishTypes);
|
router.post("/objavinekretninu/:kiviRealEstateId", postPublishTypes);
|
||||||
router.post("/objavinekretninu", postPublishTypes);
|
router.post("/objavinekretninu", postPublishTypes);
|
||||||
|
|
||||||
router.get("/podacionekretnini/:realEstateId", getPublishInputs);
|
router.get("/podacionekretnini/:kiviRealEstateId", getPublishInputs);
|
||||||
router.post("/podacionekretnini/:realEstateId", postPublishInputs);
|
router.post("/podacionekretnini/:kiviRealEstateId", postPublishInputs);
|
||||||
|
|
||||||
router.get("/lokacija/:searchRequestId", getLocation);
|
router.get("/lokacija/:searchRequestId", getLocation);
|
||||||
router.post("/lokacija/:searchRequestId", postLocation);
|
router.post("/lokacija/:searchRequestId", postLocation);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
<label class="checkbox-label"><%= input.title %>: </label><br><br>
|
<label class="checkbox-label"><%= input.title %>: </label><br><br>
|
||||||
<span class="segmented small">
|
<span class="segmented small">
|
||||||
<% for (const segmentObject of input.values) { %>
|
<% for (const segmentObject of input.values) { %>
|
||||||
|
<% if (segmentObject.id!=="ANY") { %>
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="<%= input.dbField %>" value="<%= segmentObject.id %>"
|
<input type="radio" name="<%= input.dbField %>" value="<%= segmentObject.id %>"
|
||||||
<% if (additionalSegmentSelectValues[input.dbField] === segmentObject.id) { %>
|
<% if (additionalSegmentSelectValues[input.dbField] === segmentObject.id) { %>
|
||||||
@@ -41,6 +42,7 @@
|
|||||||
<% } %>>
|
<% } %>>
|
||||||
<span class="label"><%= segmentObject.title %></span>
|
<span class="label"><%= segmentObject.title %></span>
|
||||||
</label>
|
</label>
|
||||||
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -149,14 +149,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$("#submit").click( function () {
|
$("#submit").click( function () {
|
||||||
const mapBounds = map.getBounds();
|
|
||||||
const currentLocation = marker.getPosition();
|
|
||||||
|
|
||||||
|
if (marker) {
|
||||||
$("#north").val(mapBounds.getNorthEast().lat());
|
const currentLocation = marker.getPosition();
|
||||||
$("#south").val(mapBounds.getSouthWest().lat());
|
|
||||||
$("#east").val(mapBounds.getNorthEast().lng());
|
|
||||||
$("#west").val(mapBounds.getSouthWest().lng());
|
|
||||||
|
|
||||||
$("#lat").val(currentLocation.lat());
|
$("#lat").val(currentLocation.lat());
|
||||||
|
|
||||||
@@ -164,7 +159,13 @@
|
|||||||
|
|
||||||
$("#locationInput").val(
|
$("#locationInput").val(
|
||||||
document.getElementById("autocompleteInput").value
|
document.getElementById("autocompleteInput").value
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$("#lat").val(0);
|
||||||
|
|
||||||
|
$("#lng").val(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Tag for checking of error presence
|
//Tag for checking of error presence
|
||||||
let hasErrors = false;
|
let hasErrors = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user