31 lines
814 B
TypeScript
31 lines
814 B
TypeScript
import type { Request, Response } from 'express'
|
|
|
|
import { moveRecordUp, moveRecordUpToTop } from '../../database/moveRecord.js'
|
|
import {
|
|
getAllContractTypeFields,
|
|
getContractTypes
|
|
} from '../../helpers/functions.cache.js'
|
|
|
|
export default async function handler(
|
|
request: Request<
|
|
unknown,
|
|
unknown,
|
|
{ contractTypeId: string; moveToEnd: '0' | '1' }
|
|
>,
|
|
response: Response
|
|
): Promise<void> {
|
|
const success =
|
|
request.body.moveToEnd === '1'
|
|
? await moveRecordUpToTop('ContractTypes', request.body.contractTypeId)
|
|
: await moveRecordUp('ContractTypes', request.body.contractTypeId)
|
|
|
|
const contractTypes = await getContractTypes()
|
|
const allContractTypeFields = await getAllContractTypeFields()
|
|
|
|
response.json({
|
|
success,
|
|
contractTypes,
|
|
allContractTypeFields
|
|
})
|
|
}
|