feat(users): add block/unblock and delete from admin panel
- Migration 0004: adds is_active column to users table - Backend: DELETE /users/:id endpoint + is_active field in UpdateUserDto - Admin UI: block/unblock toggle and delete with confirmation on user detail - Users list: shows "Bloqueado" badge for inactive users Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
04f1801b89
commit
a8842a2728
@@ -1,4 +1,4 @@
|
||||
import { IsEmail, IsString, MinLength, IsOptional, IsPhoneNumber, Matches } from 'class-validator';
|
||||
import { IsEmail, IsString, MinLength, IsOptional, IsPhoneNumber, Matches, IsBoolean } from 'class-validator';
|
||||
|
||||
export class RegisterDto {
|
||||
@IsEmail()
|
||||
@@ -54,6 +54,10 @@ export class UpdateUserDto {
|
||||
@Matches(/^\d{4}-\d{2}-\d{2}$/, { message: 'birthday must be YYYY-MM-DD' })
|
||||
@IsOptional()
|
||||
birthday?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
is_active?: boolean;
|
||||
}
|
||||
|
||||
export class FcmTokenDto {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Controller, Get, Patch, Param, Body, UseGuards, Req } from '@nestjs/common';
|
||||
import { Controller, Get, Patch, Delete, Param, Body, UseGuards, Req } from '@nestjs/common';
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { UsersService } from './users.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
@@ -48,4 +48,11 @@ export class UsersController {
|
||||
findById(@Param('id') id: string) {
|
||||
return this.users.findById(id);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
deleteById(@Param('id') id: string) {
|
||||
return this.users.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@ export class UsersService {
|
||||
updateFcmToken(id: string, fcm_token: string) {
|
||||
return this.prisma.users.update({ where: { id }, data: { fcm_token } });
|
||||
}
|
||||
|
||||
deleteById(id: string) {
|
||||
return this.prisma.users.delete({ where: { id } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user