RBAC: Phase 1-3, Total Salary fix, employee creation fix, permission groups, backup script
Made-with: Cursor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import ProtectedRoute from '@/components/ProtectedRoute'
|
||||
import { useAuth } from '@/contexts/AuthContext'
|
||||
import { useLanguage } from '@/contexts/LanguageContext'
|
||||
@@ -18,10 +19,20 @@ import {
|
||||
Bell,
|
||||
Shield
|
||||
} from 'lucide-react'
|
||||
import { dashboardAPI } from '@/lib/api'
|
||||
|
||||
function DashboardContent() {
|
||||
const { user, logout, hasPermission } = useAuth()
|
||||
const { t, language, dir } = useLanguage()
|
||||
const [stats, setStats] = useState({ contacts: 0, activeTasks: 0, notifications: 0 })
|
||||
|
||||
useEffect(() => {
|
||||
dashboardAPI.getStats()
|
||||
.then((res) => {
|
||||
if (res.data?.data) setStats(res.data.data)
|
||||
})
|
||||
.catch(() => {})
|
||||
}, [])
|
||||
|
||||
const allModules = [
|
||||
{
|
||||
@@ -128,7 +139,7 @@ function DashboardContent() {
|
||||
</div>
|
||||
|
||||
{/* Admin Panel Link - Only for admins */}
|
||||
{(hasPermission('admin', 'view') || user?.role?.name === 'المدير العام' || user?.role?.nameEn === 'General Manager') && (
|
||||
{hasPermission('admin', 'view') && (
|
||||
<Link
|
||||
href="/admin"
|
||||
className="p-2 hover:bg-red-50 rounded-lg transition-colors relative group"
|
||||
@@ -144,7 +155,9 @@ function DashboardContent() {
|
||||
{/* Notifications */}
|
||||
<button className="p-2 hover:bg-gray-100 rounded-lg transition-colors relative">
|
||||
<Bell className="h-5 w-5 text-gray-600" />
|
||||
<span className="absolute top-1 right-1 h-2 w-2 bg-red-500 rounded-full"></span>
|
||||
{stats.notifications > 0 && (
|
||||
<span className="absolute top-1 right-1 h-2 w-2 bg-red-500 rounded-full"></span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{/* Settings */}
|
||||
@@ -193,7 +206,7 @@ function DashboardContent() {
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-sm text-gray-600">المهام النشطة</p>
|
||||
<p className="text-3xl font-bold text-gray-900 mt-1">12</p>
|
||||
<p className="text-3xl font-bold text-gray-900 mt-1">{stats.activeTasks}</p>
|
||||
</div>
|
||||
<div className="bg-green-100 p-3 rounded-lg">
|
||||
<CheckSquare className="h-8 w-8 text-green-600" />
|
||||
@@ -205,7 +218,7 @@ function DashboardContent() {
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-sm text-gray-600">الإشعارات</p>
|
||||
<p className="text-3xl font-bold text-gray-900 mt-1">5</p>
|
||||
<p className="text-3xl font-bold text-gray-900 mt-1">{stats.notifications}</p>
|
||||
</div>
|
||||
<div className="bg-orange-100 p-3 rounded-lg">
|
||||
<Bell className="h-8 w-8 text-orange-600" />
|
||||
@@ -217,7 +230,7 @@ function DashboardContent() {
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="text-sm text-gray-600">جهات الاتصال</p>
|
||||
<p className="text-3xl font-bold text-gray-900 mt-1">248</p>
|
||||
<p className="text-3xl font-bold text-gray-900 mt-1">{stats.contacts}</p>
|
||||
</div>
|
||||
<div className="bg-purple-100 p-3 rounded-lg">
|
||||
<Users className="h-8 w-8 text-purple-600" />
|
||||
@@ -268,37 +281,7 @@ function DashboardContent() {
|
||||
{/* Recent Activity */}
|
||||
<div className="bg-white rounded-xl shadow-md p-6 border border-gray-100">
|
||||
<h3 className="text-xl font-bold text-gray-900 mb-4">النشاط الأخير</h3>
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-start gap-3 p-3 hover:bg-gray-50 rounded-lg transition-colors">
|
||||
<div className="bg-blue-100 p-2 rounded-lg">
|
||||
<Users className="h-5 w-5 text-blue-600" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-semibold text-gray-900">تم إضافة عميل جديد</p>
|
||||
<p className="text-xs text-gray-600">منذ ساعتين</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-3 p-3 hover:bg-gray-50 rounded-lg transition-colors">
|
||||
<div className="bg-green-100 p-2 rounded-lg">
|
||||
<TrendingUp className="h-5 w-5 text-green-600" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-semibold text-gray-900">تم إغلاق صفقة جديدة</p>
|
||||
<p className="text-xs text-gray-600">منذ 4 ساعات</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-3 p-3 hover:bg-gray-50 rounded-lg transition-colors">
|
||||
<div className="bg-orange-100 p-2 rounded-lg">
|
||||
<CheckSquare className="h-5 w-5 text-orange-600" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-semibold text-gray-900">تم إكمال مهمة</p>
|
||||
<p className="text-xs text-gray-600">منذ يوم واحد</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-gray-500 text-center py-6">لا يوجد نشاط حديث</p>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user