sunrise-cms/handlers/admin-get/occupancyTypes.ts

36 lines
1.0 KiB
TypeScript

import type { Request, Response } from 'express'
import {
getAllContractTypeFields,
getContractTypes
} from '../../helpers/functions.cache.js'
import { getConfigProperty } from '../../helpers/config.helpers.js'
import { getPrintConfig } from '../../helpers/functions.print.js'
export default async function handler(
_request: Request,
response: Response
): Promise<void> {
const occupancyTypes = await getContractTypes()
const allContractTypeFields = await getAllContractTypeFields()
const ContractTypePrints = getConfigProperty('settings.lotOccupancy.prints')
const occupancyTypePrintTitles = {}
for (const printEJS of ContractTypePrints) {
const printConfig = getPrintConfig(printEJS)
if (printConfig !== undefined) {
occupancyTypePrintTitles[printEJS] = printConfig.title
}
}
response.render('admin-occupancyTypes', {
headTitle: `${getConfigProperty('aliases.occupancy')} Type Management`,
occupancyTypes,
allContractTypeFields,
occupancyTypePrintTitles
})
}