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

27 lines
602 B
TypeScript

import type { Request, Response } from 'express'
import {
moveRecordDown,
moveRecordDownToBottom
} from '../../database/moveRecord.js'
import { getLotTypes } from '../../helpers/functions.cache.js'
export async function handler(
request: Request,
response: Response
): Promise<void> {
const success =
request.body.moveToEnd === '1'
? await moveRecordDownToBottom('LotTypes', request.body.lotTypeId)
: await moveRecordDown('LotTypes', request.body.lotTypeId)
const lotTypes = await getLotTypes()
response.json({
success,
lotTypes
})
}
export default handler