Skip to content

Commit

Permalink
Add jsdoc to carController.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Sep 24, 2023
1 parent c511837 commit c6e06d6
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 1 deletion.
108 changes: 108 additions & 0 deletions api/src/controllers/carController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import * as env from '../config/env.config'
import * as Helper from '../common/Helper'
import * as bookcarsTypes from 'bookcars-types'

/**
* Create a Car.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function create(req: Request, res: Response) {
const body: bookcarsTypes.CreateCarPayload = req.body

Expand Down Expand Up @@ -51,6 +60,15 @@ export async function create(req: Request, res: Response) {
}
}

/**
* Update a Car.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function update(req: Request, res: Response) {
const body: bookcarsTypes.UpdateCarPayload = req.body
const { _id } = body
Expand Down Expand Up @@ -115,6 +133,15 @@ export async function update(req: Request, res: Response) {
}
}

/**
* Check if a Car is related to bookings.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function checkCar(req: Request, res: Response) {
const { id } = req.params

Expand All @@ -133,6 +160,15 @@ export async function checkCar(req: Request, res: Response) {
}
}

/**
* Delete a Car by ID.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function deleteCar(req: Request, res: Response) {
const { id } = req.params

Expand All @@ -156,6 +192,15 @@ export async function deleteCar(req: Request, res: Response) {
}
}

/**
* Upload a Car image to temp folder.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function createImage(req: Request, res: Response) {
try {
if (!req.file) {
Expand All @@ -179,6 +224,15 @@ export async function createImage(req: Request, res: Response) {
}
}

/**
* Update a Car image.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function updateImage(req: Request, res: Response) {
const { id } = req.params

Expand Down Expand Up @@ -223,6 +277,15 @@ export async function updateImage(req: Request, res: Response) {
}
}

/**
* Delete a Car image.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function deleteImage(req: Request, res: Response) {
const { id } = req.params

Expand Down Expand Up @@ -250,6 +313,15 @@ export async function deleteImage(req: Request, res: Response) {
}
}

/**
* Delete a temp Car image.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {*}
*/
export async function deleteTempImage(req: Request, res: Response) {
const { image } = req.params

Expand All @@ -266,6 +338,15 @@ export async function deleteTempImage(req: Request, res: Response) {
}
}

/**
* Get a Car by ID.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function getCar(req: Request, res: Response) {
const { id, language } = req.params

Expand Down Expand Up @@ -303,6 +384,15 @@ export async function getCar(req: Request, res: Response) {
}
}

/**
* Get Cars.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function getCars(req: Request, res: Response) {
try {
const body: bookcarsTypes.GetCarsPayload = req.body
Expand Down Expand Up @@ -417,6 +507,15 @@ export async function getCars(req: Request, res: Response) {
}
}

/**
* Get Cars by Supplier and pick-up Location.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function getBookingCars(req: Request, res: Response) {
try {
const body: bookcarsTypes.GetBookingCarsPayload = req.body
Expand Down Expand Up @@ -452,6 +551,15 @@ export async function getBookingCars(req: Request, res: Response) {
}
}

/**
* Get Cars available for rental.
*
* @export
* @async
* @param {Request} req
* @param {Response} res
* @returns {unknown}
*/
export async function getFrontendCars(req: Request, res: Response) {
try {
const body: bookcarsTypes.GetCarsPayload = req.body
Expand Down
7 changes: 6 additions & 1 deletion backend/src/components/CarSelectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import * as Helper from '../common/Helper'
import * as bookcarsTypes from 'bookcars-types'

const CarSelectList = (
{ label,
{
label,
required,
multiple,
variant,
Expand Down Expand Up @@ -107,6 +108,10 @@ const CarSelectList = (

const _fetch = async (page: number, keyword: string, company: string, pickupLocation: string) => {
try {
if (!pickupLocation) {
return
}

const payload: bookcarsTypes.GetBookingCarsPayload = { company, pickupLocation }

if (closeDialog) {
Expand Down

0 comments on commit c6e06d6

Please sign in to comment.