28 lines
676 B
TypeScript
28 lines
676 B
TypeScript
import type { RequestHandler } from 'express'
|
|
|
|
import * as configFunctions from '../../helpers/functions.config.js'
|
|
|
|
import { getPreviousLotId } from '../../helpers/lotOccupancyDB/getPreviousLotId.js'
|
|
|
|
export const handler: RequestHandler = (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
|