diff --git a/frontend/src/components/layout/Sidebar.tsx b/frontend/src/components/layout/Sidebar.tsx index a0fe7a0..b150ef8 100644 --- a/frontend/src/components/layout/Sidebar.tsx +++ b/frontend/src/components/layout/Sidebar.tsx @@ -17,19 +17,26 @@ import { } from 'lucide-react'; import { useAuthStore } from '../../store/authStore'; -const menuItems = [ +const getMenuItems = (role: string | undefined) => [ { icon: LayoutDashboard, label: 'الرئيسية', path: '/dashboard' }, - { icon: Crown, label: 'المركز الضريبي الموحد', path: '/elite-dashboard' }, - { icon: AlertTriangle, label: 'مراقبة المخاطر', path: '/risk-monitor' }, + ...(role === 'admin' ? [ + { icon: Crown, label: 'المركز الضريبي الموحد', path: '/elite-dashboard' }, + { icon: AlertTriangle, label: 'مراقبة المخاطر', path: '/risk-monitor' } + ] : []), { icon: FileText, label: 'الفواتير', path: '/invoices' }, { icon: Building2, label: 'الشركات', path: '/companies' }, - { icon: Users, label: 'الموظفون', path: '/staff' }, + ...(role === 'admin' ? [ + { icon: Users, label: 'الموظفون', path: '/staff' } + ] : []), { icon: Settings, label: 'الإعدادات', path: '/settings' }, ]; export const Sidebar = () => { const navigate = useNavigate(); + const user = useAuthStore((state) => state.user); const clearAuth = useAuthStore((state) => state.clearAuth); + + const menuItems = getMenuItems(user?.role); const handleLogout = () => { clearAuth(); diff --git a/frontend/src/pages/dashboard/DashboardPage.tsx b/frontend/src/pages/dashboard/DashboardPage.tsx index c1d237e..3cedb7c 100644 --- a/frontend/src/pages/dashboard/DashboardPage.tsx +++ b/frontend/src/pages/dashboard/DashboardPage.tsx @@ -22,6 +22,7 @@ import { useNavigate } from 'react-router-dom'; export const DashboardPage = () => { const navigate = useNavigate(); + const user = useAuthStore((state) => state.user); const [stats, setStats] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -210,18 +211,20 @@ export const DashboardPage = () => { - + {user?.role === 'admin' && ( + + )} diff --git a/frontend/src/pages/dashboard/MultiEntityDashboard.tsx b/frontend/src/pages/dashboard/MultiEntityDashboard.tsx index ce190e8..d659296 100644 --- a/frontend/src/pages/dashboard/MultiEntityDashboard.tsx +++ b/frontend/src/pages/dashboard/MultiEntityDashboard.tsx @@ -1,6 +1,7 @@ import { useState, useEffect } from 'react'; import { Building2, TrendingUp, AlertTriangle, ChevronDown, Loader2, RefreshCw, Crown } from 'lucide-react'; import { motion } from 'framer-motion'; +import { useAuthStore } from '../../store/authStore'; import apiClient from '../../api/client'; interface CompanyStats { @@ -92,6 +93,7 @@ const Cpu = ({ className }: { className?: string }) => ( ); export const MultiEntityDashboard = () => { + const user = useAuthStore((state) => state.user); const [companies, setCompanies] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); @@ -188,12 +190,14 @@ export const MultiEntityDashboard = () => { className="card-premium p-6 relative overflow-hidden group" > {/* AI Usage Badge */} -
-
- - {company.aiStats?.totalTokens > 1000 ? `${(company.aiStats.totalTokens / 1000).toFixed(1)}k` : company.aiStats?.totalTokens || 0} tokens + {user?.role === 'admin' && ( +
+
+ + {company.aiStats?.totalTokens > 1000 ? `${(company.aiStats.totalTokens / 1000).toFixed(1)}k` : company.aiStats?.totalTokens || 0} Tokens
+ )} {/* Ambient glow */}
{

{company.totalInvoices} فاتورة

- {company.aiStats?.totalCost > 0 && ( - + {user?.role === 'admin' && company.aiStats?.totalCost > 0 && ( + ${company.aiStats.totalCost.toFixed(3)} )} diff --git a/frontend/src/pages/settings/SettingsPage.tsx b/frontend/src/pages/settings/SettingsPage.tsx index 4510478..49e27dc 100644 --- a/frontend/src/pages/settings/SettingsPage.tsx +++ b/frontend/src/pages/settings/SettingsPage.tsx @@ -64,7 +64,8 @@ export const SettingsPage = () => { const handleSave = async () => { setIsSaving(true); try { - await apiClient.post('/users/profile', formData); + const { email, ...updateData } = formData; + await apiClient.post('/users/profile', updateData); updateUser({ name: formData.name }); setShowSuccess(true); setTimeout(() => setShowSuccess(false), 3000); diff --git a/frontend/src/pages/staff/StaffPage.tsx b/frontend/src/pages/staff/StaffPage.tsx index 18735ce..d59ac52 100644 --- a/frontend/src/pages/staff/StaffPage.tsx +++ b/frontend/src/pages/staff/StaffPage.tsx @@ -7,9 +7,11 @@ import { useState, useEffect } from 'react'; import { Users, UserPlus, Search, Shield, Mail, MoreVertical, Trash2, Loader2, X } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; +import { useAuthStore } from '../../store/authStore'; import apiClient from '../../api/client'; export const StaffPage = () => { + const user = useAuthStore((state) => state.user); const [staff, setStaff] = useState([]); const [isLoading, setIsLoading] = useState(true); const [searchTerm, setSearchTerm] = useState(''); @@ -77,6 +79,7 @@ export const StaffPage = () => {

إدارة الموظفين

إدارة فريق العمل المالي لمكتب المحاسبة الخاص بك.

+ {user?.role === 'admin' && ( + )} {/* ── Search Bar ──────────────────────────────── */} @@ -112,9 +116,13 @@ export const StaffPage = () => {

لا يوجد موظفون مضافون

يمكنك إضافة موظفين لمساعدتك في إدارة ومعالجة فواتير الشركات.

- + {user?.role === 'admin' ? ( + + ) : ( +

ليس لديك صلاحية إضافة موظفين.

+ )}
) : (
@@ -124,7 +132,7 @@ export const StaffPage = () => { الاسم الكامل البريد الإلكتروني الدور الوظيفي - إجراءات + {user?.role === 'admin' && إجراءات} @@ -160,6 +168,7 @@ export const StaffPage = () => { {s.role === 'admin' ? 'مدير نظام' : 'محاسب'} + {user?.role === 'admin' && (
+ )} ))}