diff --git a/backend/src/modules/users/user.controller.ts b/backend/src/modules/users/user.controller.ts index a557539..e569853 100644 --- a/backend/src/modules/users/user.controller.ts +++ b/backend/src/modules/users/user.controller.ts @@ -44,6 +44,6 @@ export class UsersController { @Delete(':id') @Roles(UserRole.ADMIN) async remove(@CurrentUser() user: any, @Param('id') id: string) { - return this.usersService.remove(user.tenantId, id); + return this.usersService.remove(user.tenantId, id, user.id); } } diff --git a/backend/src/modules/users/user.service.ts b/backend/src/modules/users/user.service.ts index 2a53235..24e0ccc 100644 --- a/backend/src/modules/users/user.service.ts +++ b/backend/src/modules/users/user.service.ts @@ -64,7 +64,10 @@ export class UsersService { /** * تعطيل مستخدم */ - async remove(tenantId: string, id: string): Promise { + async remove(tenantId: string, id: string, currentUserId: string): Promise { + if (id === currentUserId) { + throw new ConflictException('لا يمكنك تعطيل حسابك الشخصي'); + } const user = await this.findOne(tenantId, id); await this.userRepository.update(id, { is_active: false }); } diff --git a/frontend/src/pages/staff/StaffPage.tsx b/frontend/src/pages/staff/StaffPage.tsx index 60b30a6..c204192 100644 --- a/frontend/src/pages/staff/StaffPage.tsx +++ b/frontend/src/pages/staff/StaffPage.tsx @@ -8,8 +8,10 @@ import { useState, useEffect } from 'react'; import { Users, UserPlus, Mail, Power } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import apiClient from '../../api/client'; +import { useAuthStore } from '../../store/authStore'; export const StaffPage = () => { + const currentUser = useAuthStore((state) => state.user); const [staff, setStaff] = useState([]); const [isLoading, setIsLoading] = useState(true); const [isAddModalOpen, setIsAddModalOpen] = useState(false); @@ -98,13 +100,15 @@ export const StaffPage = () => {
- + {member.id !== currentUser?.id && ( + + )}