CRM/src/core/common/sidebar/index.tsx

1035 lines
39 KiB
TypeScript

import React, { useEffect, useMemo, useRef, useState, useCallback } from "react";
import { Link, useLocation, useNavigate } from "react-router-dom";
import Scrollbars from "react-custom-scrollbars-2";
import { SidebarData } from "../../data/json/sidebarData";
import { useDispatch, useSelector } from "react-redux";
import { setExpandMenu, setMobileSidebar } from "../../data/redux/commonSlice";
import { all_routes } from "../../../feature-module/router/all_routes";
import { RootState } from "../../data/redux/store";
import { highlightMatch } from "../highlightmatch";
import { Modal } from "react-bootstrap";
import { logout } from "../../data/redux/authSlice";
import { logoutUser } from "../../../api/authService";
import { toast } from "react-toastify";
import { stopAutoLockWatcher } from "../../../api/autolock";
import ModalDeleteEffect from "../ModalDeleteEffect";
// Define types for sidebar items
interface SidebarItem {
label: string;
icon?: string;
submenu?: boolean;
showSubRoute?: boolean;
roles?: string[];
link?: string;
subLink1?: string;
subLink2?: string;
subLink3?: string;
subLink4?: string;
submenuItems?: SidebarItem[];
}
const Sidebar = () => {
const Location = useLocation();
const dispatch = useDispatch();
const navigate = useNavigate();
const searchValue = useSelector(
(state: RootState) => state.common.sidebarSearch
);
const mobileSidebar = useSelector(
(state: RootState) => state.common.mobileSidebar
);
const [subOpen, setSubopen] = useState<string>("");
const [subsidebar, setSubsidebar] = useState<string>("");
const [showLogoutModal, setShowLogoutModal] = useState(false);
const firstMatchRef = useRef<HTMLLIElement | null>(null);
const sidebarRef = useRef<HTMLDivElement | null>(null);
let matchedOnce = false;
const toggleSidebar = (title: string) => {
setSubopen((prev) => (prev === title ? "" : title));
};
const toggleSubsidebar = (subitem: string) => {
setSubsidebar((prev) => (prev === subitem ? "" : subitem));
};
const toggle = () => dispatch(setExpandMenu(true));
const toggle2 = () => dispatch(setExpandMenu(false));
const miniSidebar = useSelector(
(state: RootState) => state.common.miniSidebar
);
const expandMenu = useSelector(
(state: RootState) => state.common.expandMenu
);
useEffect(() => {
if (miniSidebar) {
document.body.classList.add("mini-sidebar");
} else {
document.body.classList.remove("mini-sidebar");
}
}, [miniSidebar]);
useEffect(() => {
if (expandMenu) {
document.body.classList.add("expand-menu");
} else {
document.body.classList.remove("expand-menu");
}
}, [expandMenu]);
useEffect(() => {
if (mobileSidebar) {
document.body.classList.add("slide-nav");
} else {
document.body.classList.remove("slide-nav");
}
}, [mobileSidebar]);
const handleLinkClick = () => {
if (window.innerWidth <= 991.98) {
dispatch(setMobileSidebar(false));
}
};
const userName = useSelector((state: RootState) => state.auth.username);
const userRole = useSelector((state: RootState) => state.auth.role);
const getAvatarColor = (name: string | undefined) => {
if (!name) return "#E41F07"; // default gray
const colors = [
"#0d6efd",
"#198754",
"#E41F07",
"#fd7e14",
"#20c997",
"#6f42c1",
];
let charCodeSum = 0;
for (let i = 0; i < name.length; i++) {
charCodeSum += name.charCodeAt(i);
}
return colors[charCodeSum % colors.length];
};
const avatarColor = getAvatarColor(userName || "Unknown");
const isMenuActive = (item: SidebarItem, pathname: string): boolean => {
if (!pathname) return false;
// Direct link
if (item.link === pathname) return true;
// Sub routes
if (
item.subLink1 === pathname ||
item.subLink2 === pathname ||
item.subLink3 === pathname ||
item.subLink4 === pathname
) {
return true;
}
// Nested submenu
return (
item.submenuItems?.some((sub) => isMenuActive(sub, pathname)) ?? false
);
};
const findActiveMenu = () => {
for (const main of SidebarData) {
for (const item of main.submenuItems || []) {
if (isMenuActive(item, Location.pathname)) {
return item.label;
}
}
}
return "";
};
const findActiveSubmenu = () => {
for (const main of SidebarData) {
for (const item of main.submenuItems || []) {
for (const sub of item.submenuItems || []) {
if (sub.link === Location.pathname) {
return sub.label;
}
}
}
}
return "";
};
useEffect(() => {
const normalizePath = (path: string) => path.replace(/\/+$/, "");
const currentPath = normalizePath(Location.pathname);
const dashboardRoutes = [
normalizePath(all_routes.leadsDashboard),
normalizePath(all_routes.dealsDashboard),
normalizePath(all_routes.superadminDashboard),
];
if (dashboardRoutes.includes(currentPath)) {
setSubopen("Dashboard");
setSubsidebar("");
return;
}
const activeMenu = findActiveMenu();
const activeSubmenu = findActiveSubmenu(); // ✅ ADD THIS
setSubopen(activeMenu);
setSubsidebar(activeSubmenu); // ✅ KEEP submenu active
}, [Location.pathname]);
useEffect(() => {
if (searchValue && firstMatchRef.current) {
firstMatchRef.current.scrollIntoView({
behavior: "smooth",
block: "center",
});
}
}, [searchValue]);
// Make logout modal draggable
useEffect(() => {
const setupModalDraggable = (modalElement: HTMLElement) => {
if (modalElement.hasAttribute('data-draggable-setup')) return;
modalElement.setAttribute('data-draggable-setup', 'true');
const modalDialog = modalElement.querySelector('.modal-dialog') as HTMLElement;
const modalHeader = modalElement.querySelector('.modal-header') as HTMLElement;
if (!modalDialog || !modalHeader) return;
let isDragging = false;
let initialX = 0;
let initialY = 0;
let startX = 0;
let startY = 0;
const resetPosition = () => {
isDragging = false;
modalDialog.style.position = '';
modalDialog.style.top = '';
modalDialog.style.left = '';
modalDialog.style.transform = '';
modalDialog.style.margin = '';
modalDialog.style.transition = '';
modalDialog.style.width = '';
modalDialog.style.maxWidth = '';
if (!modalDialog.classList.contains('modal-dialog-centered')) {
modalDialog.classList.add('modal-dialog-centered');
}
};
const dragStart = (e: MouseEvent) => {
const target = e.target as HTMLElement;
if (target.closest('.btn-close') || target.closest('button') || target.closest('input') || target.closest('select')) {
return;
}
if (e.target === modalHeader || modalHeader.contains(e.target as Node)) {
isDragging = true;
modalHeader.style.cursor = 'move';
const rect = modalDialog.getBoundingClientRect();
startX = rect.left;
startY = rect.top;
const computedStyle = getComputedStyle(modalDialog);
const currentWidth = computedStyle.width;
const currentMaxWidth = computedStyle.maxWidth;
const currentMinWidth = computedStyle.minWidth;
modalDialog.classList.remove('modal-dialog-centered');
modalDialog.style.position = 'fixed';
modalDialog.style.top = `${startY}px`;
modalDialog.style.left = `${startX}px`;
modalDialog.style.margin = '0';
modalDialog.style.transform = 'none';
modalDialog.style.transition = 'none';
if (currentWidth && currentWidth !== 'auto' && currentWidth !== '0px') {
modalDialog.style.width = currentWidth;
}
if (currentMaxWidth && currentMaxWidth !== 'none' && currentMaxWidth !== '0px') {
modalDialog.style.maxWidth = currentMaxWidth;
}
if (currentMinWidth && currentMinWidth !== '0px' && currentMinWidth !== 'auto') {
modalDialog.style.minWidth = currentMinWidth;
}
initialX = e.clientX - startX;
initialY = e.clientY - startY;
}
};
const drag = (e: MouseEvent) => {
if (!isDragging) return;
e.preventDefault();
const newX = e.clientX - initialX;
const newY = e.clientY - initialY;
const rect = modalDialog.getBoundingClientRect();
const maxX = window.innerWidth - rect.width;
const maxY = window.innerHeight - rect.height;
const constrainedX = Math.max(0, Math.min(newX, maxX));
const constrainedY = Math.max(0, Math.min(newY, maxY));
modalDialog.style.left = `${constrainedX}px`;
modalDialog.style.top = `${constrainedY}px`;
};
const dragEnd = () => {
if (isDragging) {
isDragging = false;
modalHeader.style.cursor = 'move';
modalDialog.style.transition = '';
}
};
modalHeader.style.cursor = 'move';
modalHeader.style.userSelect = 'none';
modalHeader.addEventListener('mousedown', dragStart);
document.addEventListener('mousemove', drag);
document.addEventListener('mouseup', dragEnd);
const handleHidden = () => {
resetPosition();
modalElement.removeAttribute('data-draggable-setup');
};
modalElement.addEventListener('hidden.bs.modal', handleHidden);
};
const checkAndSetup = () => {
const modals = document.querySelectorAll('.modal.show');
modals.forEach((modal) => {
const modalEl = modal as HTMLElement;
const title = modalEl.querySelector('.modal-title')?.textContent || '';
if (title.includes('Logout') && !modalEl.hasAttribute('data-draggable-setup')) {
setTimeout(() => setupModalDraggable(modalEl), 50);
}
});
};
const interval = setInterval(checkAndSetup, 100);
return () => {
clearInterval(interval);
};
}, [showLogoutModal]);
// Close sidebar when clicking outside on small screens
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
// Check if we're on a small screen (mobile/tablet)
const isSmallScreen = window.innerWidth <= 991.98;
if (
isSmallScreen &&
mobileSidebar &&
sidebarRef.current &&
!sidebarRef.current.contains(event.target as Node) &&
!(event.target as HTMLElement).closest('.sidebar-overlay') &&
!(event.target as HTMLElement).closest('.mobile_btn') &&
!(event.target as HTMLElement).closest('#toggle_btn')
) {
dispatch(setMobileSidebar(false));
}
};
// Handle overlay click
const handleOverlayClick = () => {
const isSmallScreen = window.innerWidth <= 991.98;
if (isSmallScreen && mobileSidebar) {
dispatch(setMobileSidebar(false));
}
};
if (mobileSidebar) {
document.addEventListener("mousedown", handleClickOutside);
const overlay = document.querySelector(".sidebar-overlay");
if (overlay) {
overlay.addEventListener("click", handleOverlayClick);
overlay.classList.add("opened");
}
}
return () => {
document.removeEventListener("mousedown", handleClickOutside);
const overlay = document.querySelector(".sidebar-overlay");
if (overlay) {
overlay.removeEventListener("click", handleOverlayClick);
overlay.classList.remove("opened");
}
};
}, [mobileSidebar, dispatch]);
const hasAccess = (roles?: string[]) =>
roles ? roles.includes(userRole || "user") : true;
const hasSearchResults = useMemo(() => {
if (!searchValue) return true;
return SidebarData.some((mainLabel) =>
mainLabel.submenuItems?.some((item) => {
if (!hasAccess(item.roles)) return false;
if (item.label.toLowerCase().includes(searchValue)) return true;
return item.submenuItems?.some(
(sub) =>
hasAccess(sub.roles) &&
sub.label.toLowerCase().includes(searchValue)
);
})
);
}, [searchValue, SidebarData, userRole]);
const handleLogout = useCallback(() => {
setShowLogoutModal(true);
}, []);
const confirmLogout = useCallback(async () => {
try {
// 🔐 Call backend logout API
await logoutUser();
stopAutoLockWatcher();
} catch (err) {
console.error("Logout API failed — proceeding with local logout.");
}
// 🧹 Clear Redux
dispatch(logout());
// 🚫 REMOVE history + go fresh to login
navigate(all_routes.login, { replace: true });
toast.success("Logged out successfully");
setShowLogoutModal(false);
}, [dispatch, navigate]);
return (
<div
ref={sidebarRef}
className="sidebar"
id="sidebar"
onMouseEnter={toggle}
onMouseLeave={toggle2}
style={{ display: "flex", flexDirection: "column", height: "100%" }}
>
<Scrollbars style={{ flex: 1, overflow: "hidden" }}>
<div className="sidebar-inner slimscroll">
<div className="modern-profile p-3 pb-0">
<div className="sidebar-nav mb-3">
<ul
className="nav nav-tabs nav-tabs-solid nav-tabs-rounded nav-justified bg-transparent"
role="tablist"
>
<li className="nav-item">
<Link className="nav-link active border-0" to="#">
Menu
</Link>
</li>
<li className="nav-item">
<Link className="nav-link border-0" to={all_routes.activities} onClick={handleLinkClick}>
Notification
</Link>
</li>
{/* <li className="nav-item">
<Link className="nav-link border-0" to={all_routes.email}>
Inbox
</Link>
</li> */}
</ul>
</div>
</div>
<div id="sidebar-menu" className="sidebar-menu pb-4">
<ul className="mb-0 ps-0">
<li className="clinicdropdown theme list-unstyled">
<Link
to={all_routes.profile}
onClick={handleLinkClick}
className={`d-flex align-items-center px-2 py-2 text-decoration-none transition-all ${
Location.pathname === all_routes.profile
? "bg-primary-subtle bg-opacity-25 text-primary fw-semibold"
: "text-dark"
}`}
style={{
border: "none",
outline: "none",
boxShadow: "none",
transition: "all 0.25s ease",
borderRadius: "8px",
}}
onMouseEnter={(e) => {
e.currentTarget.classList.add(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
}}
onMouseLeave={(e) => {
if (Location.pathname !== all_routes.profile) {
e.currentTarget.classList.remove(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
}
}}
>
<div
className={`avatar avatar-sm text-white rounded-circle d-flex align-items-center justify-content-center me-2 ${
Location.pathname === all_routes.profile
? "bg-primary text-white"
: ""
}`}
style={{
width: "40px",
height: "40px",
fontSize: "16px",
backgroundColor:
Location.pathname === all_routes.profile
? ""
: avatarColor,
flexShrink: 0,
transition: "all 0.3s ease",
}}
>
{userName?.charAt(0).toUpperCase() || "U"}
</div>
<div className="user-names">
<h5 className="mb-0">
{userName
? userName
.toLowerCase()
.replace(/\b\w/g, (char) => char.toUpperCase())
: "User Name"}
</h5>
<h6 className="text-muted mb-0">
{userRole
? userRole
.toLowerCase()
.replace(/\b\w/g, (char) => char.toUpperCase())
: "Role"}
</h6>
</div>
</Link>
</li>
</ul>
{/* <ul
className={`d-flex align-items-center px-1 py-1 mb-2 rounded transition-all`}
style={{
backgroundColor: "transparent",
border: "none",
outline: "none",
boxShadow: "none",
transition: "all 0.25s ease",
}}
onMouseEnter={(e) => {
e.currentTarget.classList.add(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon = e.currentTarget.querySelector("i");
if (icon) icon.classList.add("bg-primary", "text-white");
}}
onMouseLeave={(e) => {
if (!e.currentTarget.contains(document.activeElement)) {
e.currentTarget.classList.remove(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon = e.currentTarget.querySelector("i");
if (icon) icon.classList.remove("bg-primary", "text-white");
}
}}
>
<i
className={`bi bi-search ms-1 me-2 p-1 bg-light text-dark`}
style={{
borderRadius: "6px",
transition: "all 0.3s ease",
}}
></i>
<input
type="text"
placeholder="Search menu..."
className="flex-grow-1 border-0 bg-transparent shadow-none text-dark"
value={searchValue || ""}
onChange={(e) =>
dispatch(setSidebarSearch(e.target.value.toLowerCase()))
}
onFocus={(e) => {
const parent = e.currentTarget.parentElement!;
parent.classList.add(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon = parent.querySelector("i");
if (icon) icon.classList.add("bg-primary", "text-white");
}}
onBlur={(e) => {
const parent = e.currentTarget.parentElement!;
if (!e.currentTarget.value) {
parent.classList.remove(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon = parent.querySelector("i");
if (icon) icon.classList.remove("bg-primary", "text-white");
}
}}
style={{
fontSize: "14px",
transition: "all 0.25s ease",
paddingLeft: "4px",
}}
/>
</ul> */}
{searchValue && !hasSearchResults && (
<div className="text-center text-muted py-4 px-3">
<i className="ti ti-search-off fs-3 mb-2 d-block" />
<div className="fw-semibold">No results found</div>
<small>
No menu matches "<strong>{searchValue}</strong>"
</small>
</div>
)}
<ul>
{SidebarData?.filter((mainLabel) =>
mainLabel.submenuItems?.some((item) => hasAccess(item.roles))
).map((mainLabel, index) => (
<li className="clinicdropdown" key={index}>
<h6 className="submenu-hdr">{mainLabel?.label}</h6>
<ul>
{mainLabel?.submenuItems
?.filter(
(title: SidebarItem) =>
hasAccess(title.roles) &&
(!searchValue ||
title.label.toLowerCase().includes(searchValue) ||
title.submenuItems?.some((s) =>
s.label.toLowerCase().includes(searchValue)
))
)
.map((title: SidebarItem) => {
const isMatch = title.label
.toLowerCase()
.includes(searchValue);
const matchRef =
isMatch && !matchedOnce
? (el: any) => {
firstMatchRef.current = el;
matchedOnce = true;
}
: undefined;
// Special handling for Logout
const isLogout = title?.label === "Logout";
return (
<li
className={`submenu ${isLogout ? "mb-5" : ""}`}
key={title.label}
ref={matchRef}
>
<Link
to={isLogout ? "#" : (title?.submenu ? "#" : title?.link || "#")}
onClick={(e) => {
if (isLogout) {
e.preventDefault();
handleLogout();
} else {
toggleSidebar(title?.label);
if (!title?.submenu) {
handleLinkClick();
}
}
}}
onMouseEnter={(e) => {
e.currentTarget.classList.add(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon = e.currentTarget.querySelector("i");
if (icon)
icon.classList.add(
"bg-primary",
"text-white"
);
}}
onMouseLeave={(e) => {
const isActive =
subOpen === title?.label ||
isMenuActive(title, Location.pathname) ||
title?.submenuItems?.some(
(link) => link?.link === Location.pathname
);
if (!isActive) {
e.currentTarget.classList.remove(
"bg-primary-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon =
e.currentTarget.querySelector("i");
if (icon)
icon.classList.remove(
"bg-primary",
"text-white"
);
}
}}
className={`sidebar-jump d-flex align-items-center px-2 py-2 w-100 text-decoration-none transition-all ${
subOpen === title?.label ||
isMenuActive(title, Location.pathname) ||
title?.submenuItems?.some(
(link) => link?.link === Location.pathname
)
? "bg-primary-subtle bg-opacity-25 text-primary fw-semibold"
: "text-dark"
}`}
style={{
border: "none",
outline: "none",
boxShadow: "none",
transition: "all 0.25s ease",
}}
>
<i
className={`${title.icon} ms-2 me-2 p-2 ${
subOpen === title?.label ||
isMenuActive(title, Location.pathname) ||
title?.submenuItems?.some(
(link) => link?.link === Location.pathname
)
? "bg-primary text-white"
: "bg-light text-dark"
}`}
style={{
transition: "all 0.3s ease",
}}
></i>
<span
className={`ms-2 ${
subOpen === title?.label ||
isMenuActive(title, Location.pathname) ||
title?.submenuItems?.some(
(link) => link?.link === Location.pathname
)
? "text-primary fw-semibold"
: "text-dark"
}`}
>
{highlightMatch(title.label, searchValue)}
</span>
{title?.submenu && !isLogout && (
<span
className={`ms-auto bi ${
subOpen === title?.label
? "bi-chevron-down"
: "bi-chevron-right"
} text-muted`}
/>
)}
</Link>
{!isLogout && (
<ul
style={{
display:
subOpen === title?.label ? "block" : "none",
listStyle: "none",
paddingLeft: "0",
marginLeft: "0",
}}
>
{title?.submenuItems
?.filter((item: SidebarItem) =>
hasAccess(item.roles)
)
.map((item: SidebarItem) => {
const isItemMatch = item.label
.toLowerCase()
.includes(searchValue);
return (
<li
className="submenu submenu-two"
key={item.label}
>
<Link
to={
item?.submenu
? "#"
: item?.link || "#"
}
onClick={() => {
if (item?.submenu) {
toggleSubsidebar(item?.label);
} else {
handleLinkClick();
}
}}
onMouseEnter={(e) => {
e.currentTarget.classList.add(
"bg-danger-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon =
e.currentTarget.querySelector("i");
if (icon)
icon.classList.add(
"bg-primary",
"text-white"
);
}}
onMouseLeave={(e) => {
const isActive =
subsidebar === item?.label ||
item?.submenuItems?.some(
(link) =>
link?.link === Location.pathname
);
if (!isActive) {
e.currentTarget.classList.remove(
"bg-danger-subtle",
"bg-opacity-25",
"text-primary",
"fw-semibold"
);
const icon =
e.currentTarget.querySelector(
"i"
);
if (icon)
icon.classList.remove(
"bg-primary",
"text-white"
);
}
}}
className={`sidebar-jump d-flex align-items-center px-2 py-2 w-100 text-decoration-none transition-all ${
isMenuActive(item, Location.pathname)
? "bg-danger-subtle bg-opacity-25 text-primary fw-semibold"
: "text-dark"
}`}
style={{
border: "none",
outline: "none",
boxShadow: "none",
transition: "all 0.25s ease",
}}
>
<i
className={`${
item.icon
} ms-3 p-2 rounded ${
subsidebar === item?.label ||
item?.submenuItems?.some(
(link) =>
link?.link === Location.pathname
)
? "bg-primary text-white"
: "bg-light text-dark"
}`}
style={{
transition: "all 0.3s ease",
minWidth: "32px",
paddingLeft: "25px",
}}
></i>
<span
className={`ms-2 ${
isMenuActive(item, Location.pathname)
? "text-primary fw-semibold"
: "text-dark"
}`}
>
{highlightMatch(
item.label,
searchValue
)}
</span>
{item?.submenu && (
<span
className={`ms-auto bi ${
subsidebar === item?.label
? "bi-chevron-down"
: "bi-chevron-right"
} text-muted`}
/>
)}
</Link>
<ul
style={{
display:
subsidebar === item?.label
? "block"
: "none",
listStyle: "none",
paddingLeft: "15px", // controlled indentation
marginLeft: "0",
}}
>
{item?.submenuItems
?.filter((items: SidebarItem) =>
hasAccess(items.roles)
)
.map((items: SidebarItem) => {
const isSubItemMatch = items.label
.toLowerCase()
.includes(searchValue);
return (
<li key={items.label}>
<Link
to={items?.link || "#"}
className={`${
subsidebar === items?.label
? "submenu-two subdrop"
: "submenu-two"
}
${
items?.submenuItems?.some(
(link) =>
link?.link ===
Location.pathname
)
? "active"
: ""
}`}
>
<i className={items.icon}></i>
<span
className={
searchValue &&
item.label
.toLowerCase()
.includes(searchValue)
? "search-highlight"
: ""
}
>
{highlightMatch(
items?.label,
searchValue
)}
</span>
</Link>
</li>
);
})}
</ul>
</li>
);
})}
</ul>
)}
</li>
);
})}
</ul>
</li>
))}
</ul>
</div>
</div>
</Scrollbars>
<ModalDeleteEffect />
{/* Logout Confirmation Modal */}
<Modal
show={showLogoutModal}
onHide={() => setShowLogoutModal(false)}
centered
className="effect-modal-show"
>
<div className="modal-header">
<h5 className="modal-title"> <i className="ti ti-lock me-2" /> Logout</h5>
<button
className="btn-close custom-btn-close border p-1 me-0 d-flex align-items-center justify-content-center rounded-circle"
aria-label="Close"
onClick={() => setShowLogoutModal(false)}
>
<i className="ti ti-x" />
</button>
</div>
<div className="modal-body text-center p-4">
<div className="success-popup-icon bg-light-warning mb-3 effect-avatar-pulse">
<i className="ti ti-logout fs-36 text-warning" />
</div>
<h4 className="mb-2">Are you sure you want to logout?</h4>
<p className="mb-0 text-muted">
You will be logged out of your account.
</p>
<div className="d-flex justify-content-center gap-3 mt-4">
<button
className="btn btn-secondary"
onClick={() => setShowLogoutModal(false)}
>
No
</button>
<button
className="btn btn-primary"
onClick={confirmLogout}
>
Yes
</button>
</div>
</div>
</Modal>
</div>
);
};
export default Sidebar;