//Eknoor singh and jaanvi
//date:- 12-Feb-2025
//seperate route for super admin implemented

import React from "react";
import { useSelector } from "react-redux";
import { Navigate } from "react-router-dom";
import { RootState } from "./redux/store/store";

 
interface SuperAdminRouteProps {
  children: React.ReactNode;
}
 
const SuperAdminRouter: React.FC<SuperAdminRouteProps> = ({ children }) => {
  const userRole = useSelector((state: RootState) => state.auth.user?.role);
 
  if (userRole !== 'superadmin') {
    // Redirect to dashboard if user is not a superadmin
    return <Navigate to="/panel/dashboard" replace />;
  }
 
  return <>{children}</>;
};
 
export default SuperAdminRouter;
