Files
old-web/app/controllers/regions.js

28 lines
690 B
JavaScript
Raw Normal View History

const { currentRERequest } = require('../helpers/url');
const { getRegions } = require('../helpers/codes');
2019-04-27 07:08:36 +02:00
const regions = getRegions();
2019-04-27 07:08:36 +02:00
const getRegion = (req,res) => {
res.render('region', { regions });
};
2019-04-27 07:08:36 +02:00
const postRegion = async (req, res) => {
2019-04-30 06:48:41 +02:00
const request = await currentRERequest(req);
const nextStepQueryParam = req.query.nextStep ? '?nextStep=pregled' : '';
const nextStepPage = req.query.nextStep || 'mjesto';
const nextStepUrl = `/${nextStepPage}/${request.uniqueId}${nextStepQueryParam}`;
request.region = req.body.region;
request.municipality = null;
2019-04-27 07:08:36 +02:00
await request.save();
res.redirect(nextStepUrl)
};
2019-04-27 07:08:36 +02:00
2019-05-16 19:42:15 +02:00
module.exports = {
getRegion,
postRegion
2019-04-27 07:08:36 +02:00
};