feat: implement admin authentication, role-based permissions, and backoffice layout components
This commit is contained in:
@@ -45,8 +45,25 @@ interface DashboardData {
|
||||
}>;
|
||||
}
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import toast from 'react-hot-toast';
|
||||
|
||||
export default function DashboardClient({ initialData }: { initialData: DashboardData }) {
|
||||
const { stats, latestBusinesses, activities } = initialData;
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const unauthorized = searchParams.get('unauthorized');
|
||||
if (unauthorized) {
|
||||
toast.error(`Accès restreint : vous n'avez pas les autorisations pour accéder à ce module (${unauthorized}).`, {
|
||||
duration: 5000,
|
||||
});
|
||||
// Clean query param
|
||||
router.replace('/dashboard');
|
||||
}
|
||||
}, [searchParams, router]);
|
||||
|
||||
const statCards = [
|
||||
{ label: 'Utilisateurs', value: stats.usersCount, icon: Users, color: 'text-blue-400' },
|
||||
@@ -117,9 +134,9 @@ export default function DashboardClient({ initialData }: { initialData: Dashboar
|
||||
{b.plan}
|
||||
</span>
|
||||
{b.verified ? (
|
||||
<CheckCircle2 className="w-4 h-4 text-emerald-500" title="Vérifié" />
|
||||
<span title="Vérifié"><CheckCircle2 className="w-4 h-4 text-emerald-500" /></span>
|
||||
) : (
|
||||
<Clock className="w-4 h-4 text-amber-500" title="En attente" />
|
||||
<span title="En attente"><Clock className="w-4 h-4 text-amber-500" /></span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user