import React, { useState } from "react";
import { useNavigate } from "react-router-dom";
import "./AdminPanel.scss";
import {
FaTh,
FaUser,
FaUsers,
FaCalendarAlt,
FaBullseye,
FaVideo,
FaChevronRight,
FaPlus,
FaList,
FaSortDown,
FaArrowLeft,
FaRedo,
FaSignOutAlt,
FaCog,
FaGift,
FaGlobe,
FaImage,
FaMobile,
FaQuestionCircle,
FaBullhorn,
FaFootballBall,
FaBars,
FaTimes,
} from "react-icons/fa";
import { BsPostcardFill } from "react-icons/bs";
import { HiOutlineHome } from "react-icons/hi2";
import { useAdminPanel } from "./AdminPanelContext";
import BannerSectionForm from "./AdminPanelForms/BannerSectionForm";
import CTASectionForm from "./AdminPanelForms/CTASectionForm";
import EcosystemForm from "./AdminPanelForms/EcosystemForm";
import FaqSectionForm from "./AdminPanelForms/FaqSectionForm";
import FooterForm from "./AdminPanelForms/FooterForm";
import HeroSectionForm from "./AdminPanelForms/HeroSectionForm";
import OfferingsForm from "./AdminPanelForms/OfferingsForm";
import TrendingAppsForm from "./AdminPanelForms/TrendingAppsForm";
import AppDemo from "./AdminPanelForms/AppDemo";
import BlogForm from "./AdminPanelForms/BlogForm";
import SeoForm from "./AdminPanelForms/SeoForm";
import SEO from "../Components/SEO/SEO";
import { clearSession, getSession } from "../Services/others";
import { GenerateLogout } from "../features/signInPage/signInPage";
import { useDispatch } from "react-redux";
const subDirectory = import.meta.env.BASE_URL;
const AdminPanel = () => {
// Default to first option (HeroSectionForm)
const [selectedId, setSelectedId] = useState(0);
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const navigate = useNavigate();
const dispatch = useDispatch();
const UserType = getSession("UserType");
console.log(UserType, "UserTypeUserType")
const sidebarOptions = [
// { id: 1, title: "Dashboard", subtitle: "Overview", icon: },
{
id: 0,
title: "Blog",
subtitle: "Post Content Control",
icon: ,
component: BlogForm,
key: "BlogSection",
},
{
id: 10,
title: "SEO",
subtitle: "Content Management",
icon: ,
component: SeoForm,
key: "SEOForm",
},
// {
// id: 1,
// title: "HeroSection",
// subtitle: "Hero Section Management",
// icon: ,
// component: HeroSectionForm,
// key: "HeroSection",
// },
// {
// id: 2,
// title: "Offerings",
// subtitle: "Offering Section Management",
// icon: ,
// component: OfferingsForm,
// key: "OfferingSection",
// },
// {
// id: 3,
// title: "Industries",
// subtitle: "Ecosystem Management",
// icon: ,
// component: EcosystemForm,
// key: "Industries",
// },
// {
// id: 4,
// title: "AppDemo",
// subtitle: "Video Section Management",
// icon: ,
// component: AppDemo,
// key: "VideoDemo",
// },
// {
// id: 5,
// title: "BannerSection",
// subtitle: "Banner Section Management",
// icon: ,
// component: BannerSectionForm,
// key: "BannerSection",
// },
// {
// id: 6,
// title: "TrendingApps",
// subtitle: "Trending Apps Management",
// icon: ,
// component: TrendingAppsForm,
// key: "TrendingApps",
// },
// {
// id: 7,
// title: "FaqSection",
// subtitle: "FAQ Management",
// icon: ,
// component: FaqSectionForm,
// key: "FAQSection",
// },
// {
// id: 8,
// title: "CTASection",
// subtitle: "Call-to-Action Management",
// icon: ,
// component: CTASectionForm,
// key: "CTASection",
// },
// {
// id: 9,
// title: "Footer",
// subtitle: "Footer Management",
// icon: ,
// component: FooterForm,
// key: "FooterSection",
// },
];
const currentSection = sidebarOptions.find(
(option) => option.id === selectedId
);
const handleSideBarSelect = (option) => {
setSelectedId(option?.id);
setIsMobileMenuOpen(false); // Close mobile menu on selection
};
const handleSignOut = async () => {
const UserId = getSession("UserId");
const status = "N";
const res = await dispatch(GenerateLogout({ UserId, status })).unwrap();
if (res?.data?.statusCode === 1) {
clearSession();
navigate(`${subDirectory}`);
}
}
return (
<>
{/* Mobile Menu Toggle */}
Admin Panel
{/* Sidebar Navigation */}
SA
Marketing Administrator
Super Admin
{/* Mobile Overlay */}
{isMobileMenuOpen && (
setIsMobileMenuOpen(false)}
>
)}
{/* Main Content */}
{/* Top Header with Breadcrumbs */}
Dashboard
{currentSection && (
<>
{currentSection.title} Management
>
)}
UserType === "Super Admin" ? navigate(`${subDirectory}landing-page/home`) : navigate(`${subDirectory}`)}
>
Back to Home
{/* Content Area */}
{currentSection?.component ? (
) : (
Welcome to Admin Panel
Select a section from the sidebar to get started
)}
>
);
};
export default AdminPanel;