sunrise-cms/handlers/admin-post/doMoveLotOccupantTypeUp.ts

27 lines
652 B
TypeScript

import type { Request, Response } from 'express'
import {
moveRecordUp,
moveRecordUpToTop
} from '../../database/moveRecord.js'
import { getLotOccupantTypes } from '../../helpers/functions.cache.js'
export async function handler(
request: Request,
response: Response
): Promise<void> {
const success =
request.body.moveToEnd === '1'
? await moveRecordUpToTop('LotOccupantTypes', request.body.lotOccupantTypeId)
: await moveRecordUp('LotOccupantTypes', request.body.lotOccupantTypeId)
const lotOccupantTypes = await getLotOccupantTypes()
response.json({
success,
lotOccupantTypes
})
}
export default handler