sunrise-cms/handlers/lots-get/previous.js

16 lines
622 B
JavaScript

import * as configFunctions from '../../helpers/functions.config.js';
import { getPreviousLotId } from '../../helpers/lotOccupancyDB/getPreviousLotId.js';
export const handler = (request, response) => {
const lotId = request.params.lotId;
const previousLotId = getPreviousLotId(lotId);
if (!previousLotId) {
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
'/lots/?error=noPreviousLotIdFound');
return;
}
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
'/lots/' +
previousLotId);
};
export default handler;