cityssm/parking-ticket-system

View on GitHub
handlers/admin-post/doUpdateOffencesByBylaw.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { Request, Response } from 'express'

import { getParkingBylawsWithOffenceStats } from '../../database/parkingDB/getParkingBylaws.js'
import updateParkingOffencesByBylawNumber, {
  type UpdateParkingOffencesByBylawNumberForm
} from '../../database/parkingDB/updateParkingOffencesByBylawNumber.js'

export default function handler(request: Request, response: Response): void {
  const results = updateParkingOffencesByBylawNumber(
    request.body as UpdateParkingOffencesByBylawNumberForm
  )

  if (results.success) {
    results.bylaws = getParkingBylawsWithOffenceStats()
  }

  response.json(results)
}