Files
frontend/src/components/layouts/dashboard/headerWithSidebar/Sidebar/SidebarBadge.jsx
2025-03-09 11:41:52 +00:00

20 lines
609 B
JavaScript

import { getValueByPath } from "@/core/utils/getValueByPath";
import { useSidebarBadge } from "@/lib/hooks/useSidebarBadge";
import { Chip } from "@mui/material";
import { useEffect, useState } from "react";
const SidebarBadge = ({ badge, chipProps = {} }) => {
const { data } = useSidebarBadge();
const [value, setValue] = useState();
useEffect(() => {
setValue(getValueByPath(data, badge));
}, [data, badge]);
if (!data) return null;
if (!value) return null;
return <Chip label={value.toLocaleString()} size="small" {...chipProps} />;
};
export default SidebarBadge;