Fix Admin panel categories modal, add error handling, enforce cursor-pointer globally
This commit is contained in:
1 parent
69502fc380
commit
82ab454647
47 files changed
+2968
-653
No files matched your search
@@ -44,12 +44,19 @@ export class AdminController {
|
||||
@Query('page') page?: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Query('search') search?: string,
|
||||
@Query('category') category?: string
|
||||
@Query('categoryId') categoryId?: string
|
||||
) {
|
||||
const data = await this.adminService.getProducts({ page, limit, search, category });
|
||||
const data = await this.adminService.getProducts({ page, limit, search, categoryId });
|
||||
return { success: true, ...data };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('products')
|
||||
async createProduct(@Body() data: any) {
|
||||
const product = await this.adminService.createProduct(data);
|
||||
return { success: true, data: product };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('products/:id')
|
||||
async updateProduct(@Param('id') id: string, @Body() data: any) {
|
||||
@@ -61,7 +68,7 @@ export class AdminController {
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('products/:id/delete')
|
||||
@Delete('products/:id')
|
||||
async deleteProduct(@Param('id') id: string) {
|
||||
await this.adminService.deleteProduct(id);
|
||||
return {
|
||||
@@ -95,18 +102,25 @@ export class AdminController {
|
||||
// --- Coupons ---
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('coupons')
|
||||
async getCoupons() {
|
||||
const coupons = await this.adminService.getCoupons();
|
||||
return { success: true, data: coupons };
|
||||
async getCoupons(@Query() query: any) {
|
||||
const coupons = await this.adminService.getCoupons(query);
|
||||
return { success: true, ...coupons };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('coupons')
|
||||
async createCoupon(@Body() data: { code: string; discountValue: number }) {
|
||||
async createCoupon(@Body() data: any) {
|
||||
const coupon = await this.adminService.createCoupon(data);
|
||||
return { success: true, data: coupon };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('coupons/:id')
|
||||
async updateCoupon(@Param('id') id: string, @Body() data: any) {
|
||||
const coupon = await this.adminService.updateCoupon(id, data);
|
||||
return { success: true, data: coupon };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put('coupons/:id/toggle')
|
||||
async toggleCoupon(@Param('id') id: string, @Body('isActive') isActive: boolean) {
|
||||
|
||||
Reference in new issue
Block a user