add badge for sidebar

This commit is contained in:
Amirhossein Mahmoodi
2024-08-27 13:00:17 +03:30
parent 1bd0f7f606
commit cb2248e108
7 changed files with 80 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
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("fa-IR")} size="small" {...chipProps} />
)
}
export default SidebarBadge