update status
This commit is contained in:
@@ -7,20 +7,14 @@ import { RestId } from 'src/common/decorators/rest-id.decorator';
|
||||
import { AdminAuthGuard } from '../../auth/guards/adminAuth.guard';
|
||||
import { FindOrdersDto } from '../dto/find-orders.dto';
|
||||
import { OrderStatus } from '../interface/order.interface';
|
||||
import { API_HEADER_SLUG } from 'src/common/constants/index';
|
||||
|
||||
@ApiTags('orders')
|
||||
@ApiBearerAuth()
|
||||
@ApiHeader({
|
||||
name: 'X-Slug',
|
||||
required: true,
|
||||
schema: {
|
||||
type: 'string',
|
||||
default: 'zhivan',
|
||||
},
|
||||
})
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@Controller()
|
||||
export class OrdersController {
|
||||
constructor(private readonly ordersService: OrdersService) { }
|
||||
constructor(private readonly ordersService: OrdersService) {}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Post('public/checkout')
|
||||
@@ -45,11 +39,16 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Patch('public/orders/:id/cancel')
|
||||
@ApiOperation({ summary: 'Cancel an order By User' })
|
||||
@Patch('public/orders/:id/:status')
|
||||
@ApiParam({
|
||||
name: 'status',
|
||||
description: 'Order status',
|
||||
enum: OrderStatus,
|
||||
})
|
||||
@ApiOperation({ summary: 'Update status of an order By User' })
|
||||
@ApiParam({ name: 'id', description: 'Order ID' })
|
||||
cancelOrder(@Param('id') id: string, @RestId() restId: string) {
|
||||
return this.ordersService.cancelOrderAsUser(id, restId);
|
||||
cancelOrder(@Param('id') id: string, @Param('status') status: OrderStatus, @RestId() restId: string) {
|
||||
return this.ordersService.changeOrderStatus(id, restId, status, 'user');
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@@ -68,28 +67,41 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Patch('admin/orders/:orderId/confirm')
|
||||
@ApiOperation({ summary: 'Accept an order' })
|
||||
@Patch('admin/orders/:orderId/:status')
|
||||
@ApiOperation({ summary: 'Update an order status' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
acceptOrder(@Param('orderId') orderId: string, @RestId() restId: string) {
|
||||
return this.ordersService.confirmOrder(orderId, restId);
|
||||
@ApiParam({
|
||||
name: 'status',
|
||||
description: 'Order status',
|
||||
enum: OrderStatus,
|
||||
})
|
||||
updateStatus(@Param('orderId') orderId: string, @Param('status') status: OrderStatus, @RestId() restId: string) {
|
||||
return this.ordersService.changeOrderStatus(orderId, restId, status, 'admin');
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Patch('admin/orders/:id/prepare')
|
||||
@ApiOperation({ summary: 'Prepare an order By Admin' })
|
||||
@ApiParam({ name: 'id', description: 'Order ID' })
|
||||
prepareOrder(@Param('id') id: string, @RestId() restId: string) {
|
||||
return this.ordersService.prepareOrder(id, restId);
|
||||
}
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
// @Patch('admin/orders/:orderId/confirm')
|
||||
// @ApiOperation({ summary: 'Accept an order' })
|
||||
// @ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
// acceptOrder(@Param('orderId') orderId: string, @RestId() restId: string) {
|
||||
// return this.ordersService.confirmOrder(orderId, restId);
|
||||
// }
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Patch('admin/orders/:orderId/reject')
|
||||
@ApiOperation({ summary: 'Reject an order' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
rejectOrder(@Param('orderId') orderId: string, @RestId() restId: string) {
|
||||
return this.ordersService.rejectOrder(orderId, restId);
|
||||
}
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
// @Patch('admin/orders/:id/prepare')
|
||||
// @ApiOperation({ summary: 'Prepare an order By Admin' })
|
||||
// @ApiParam({ name: 'id', description: 'Order ID' })
|
||||
// prepareOrder(@Param('id') id: string, @RestId() restId: string) {
|
||||
// return this.ordersService.prepareOrder(id, restId);
|
||||
// }
|
||||
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
// @Patch('admin/orders/:orderId/reject')
|
||||
// @ApiOperation({ summary: 'Reject an order' })
|
||||
// @ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
// rejectOrder(@Param('orderId') orderId: string, @RestId() restId: string) {
|
||||
// return this.ordersService.rejectOrder(orderId, restId);
|
||||
// }
|
||||
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
// @ApiBearerAuth()
|
||||
@@ -108,17 +120,4 @@ export class OrdersController {
|
||||
// markAsDelivered(@Param('orderId') orderId: string, @RestId() restId: string) {
|
||||
// return this.ordersService.markAsDelivered(orderId, restId);
|
||||
// }
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Patch('admin/orders/:orderId/:status')
|
||||
@ApiOperation({ summary: 'Update an order status' })
|
||||
@ApiParam({ name: 'orderId', description: 'Order ID' })
|
||||
@ApiParam({
|
||||
name: 'status',
|
||||
description: 'Order status',
|
||||
enum: OrderStatus,
|
||||
})
|
||||
updateStatus(@Param('orderId') orderId: string, @Param('status') status: OrderStatus, @RestId() restId: string) {
|
||||
return this.ordersService.updateStatus(orderId, status, restId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user