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

13 lines
604 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) {
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
"/lots/?error=noPreviousLotIdFound");
}
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") + "/lots/" + previousLotId);
};
export default handler;