skip to query review directly when editing data

This commit is contained in:
Bilal Catic
2019-05-21 15:25:28 +02:00
parent 126da48852
commit aa3c965d5c
7 changed files with 74 additions and 57 deletions

View File

@@ -1,22 +1,24 @@
const { currentRERequest } = require('../helpers/url');
const { currentRERequest } = require('../helpers/url');
const { getRegions } = require('../helpers/codes');
const regions = getRegions();
const getRegion = (req,res) => {
const nextStep = req.query.nextStep || '/';
res.render('region', {
nextStep,
regions
});
res.render('region', { regions });
};
const postRegion = async (req, res) => {
const request = await currentRERequest(req);
const nextStep = req.query.nextStep || `/mjesto/${request.uniqueId}`;
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;
await request.save();
res.redirect(nextStep)
res.redirect(nextStepUrl)
};
module.exports = {