🛡️ Safety: Prevent self-deactivation and fix staff UI
This commit is contained in:
@@ -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<any[]>([]);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [isAddModalOpen, setIsAddModalOpen] = useState(false);
|
||||
@@ -98,13 +100,15 @@ export const StaffPage = () => {
|
||||
<Users className="w-7 h-7" />
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={() => toggleStatus(member.id)}
|
||||
className={`p-2 rounded-xl transition-all ${member.is_active ? 'text-emerald-500 bg-emerald-50' : 'text-slate-400 bg-slate-50'}`}
|
||||
title={member.is_active ? 'تعطيل الحساب' : 'تفعيل الحساب'}
|
||||
>
|
||||
<Power className="w-4 h-4" />
|
||||
</button>
|
||||
{member.id !== currentUser?.id && (
|
||||
<button
|
||||
onClick={() => toggleStatus(member.id)}
|
||||
className={`p-2 rounded-xl transition-all ${member.is_active ? 'text-emerald-500 bg-emerald-50' : 'text-slate-400 bg-slate-50'}`}
|
||||
title={member.is_active ? 'تعطيل الحساب' : 'تفعيل الحساب'}
|
||||
>
|
||||
<Power className="w-4 h-4" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user