cityssm/parking-ticket-system

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

Summary

Maintainability
A
2 hrs
Test Coverage
import type { Request, Response } from 'express'

import deleteParkingLocation from '../../database/parkingDB/deleteParkingLocation.js'
import { getParkingLocations } from '../../helpers/functions.cache.js'

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

  if (results.success) {
    results.locations = getParkingLocations()
  }

  response.json(results)
}