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

28 lines
605 B
TypeScript

import type { Request, Response } from 'express'
import {
moveLotTypeFieldUp,
moveLotTypeFieldUpToTop
} from '../../database/moveLotTypeField.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 moveLotTypeFieldUpToTop(request.body.lotTypeFieldId)
: await moveLotTypeFieldUp(request.body.lotTypeFieldId)
const lotTypes = await getLotTypes()
response.json({
success,
lotTypes
})
}
export default handler