🚀 Phase 3 Complete: Fix staff list, PDF preview, and functional Settings/Profile

This commit is contained in:
Hamza-Ayed
2026-04-22 02:31:01 +03:00
parent 09cb8efa80
commit c3f3d940e5
5 changed files with 228 additions and 83 deletions

View File

@@ -46,4 +46,9 @@ export class UsersController {
async remove(@CurrentUser() user: any, @Param('id') id: string) {
return this.usersService.remove(user.tenantId, id, user.id);
}
@Post('profile')
async updateProfile(@CurrentUser() user: any, @Body() dto: any) {
return this.usersService.update(user.id, dto);
}
}

View File

@@ -71,4 +71,21 @@ export class UsersService {
const user = await this.findOne(tenantId, id);
await this.userRepository.update(id, { is_active: false });
}
/**
* تحديث بيانات مستخدم
*/
async update(id: string, dto: any): Promise<User> {
const user = await this.userRepository.findOne({ where: { id } });
if (!user) throw new NotFoundException('User not found');
// Hash password if provided
if (dto.password) {
dto.password_hash = await bcrypt.hash(dto.password, 12);
delete dto.password;
}
Object.assign(user, dto);
return this.userRepository.save(user);
}
}