import React, { useEffect } from "react"; import { useAtom } from "../../libraries/jotai"; import { Close } from "../../libraries/mui/icons"; import { Skeleton } from "../../libraries/mui/components"; import { sidebarDrawerAtom } from "../../states/SidebarDrawerContext"; import { SidebarDrawerContainer, SidebarDrawerContent, SidebarDrawerHeader, SidebarDrawerBody, SidebarDrawerFooter, SidebarDrawerProductIcon } from "./styles"; interface SidebarDrawerProps { anchor?: "left" | "top" | "right" | "bottom", bodyChildren: JSX.Element; footerChildren: JSX.Element; primarycolor: string; productIconClass?: string; productIconPath: string; productIconFallbackPath?: string; open: boolean; onClose: () => void; } const SidebarDrawer: React.FC = ({ anchor, open, onClose, bodyChildren, footerChildren, primarycolor, productIconPath, productIconFallbackPath, productIconClass }) => { const [sidebarDrawer, setSidebarDrawer] = useAtom(sidebarDrawerAtom); const getFallbackProductIcon = () => { if (productIconFallbackPath) return ; return null; }; useEffect(() => { setSidebarDrawer({ onClose }); }, [onClose]); return ( } fallback={getFallbackProductIcon} /> { bodyChildren } { footerChildren } ); }; SidebarDrawer.defaultProps = { anchor: "left", productIconFallbackPath: "", productIconClass: "" }; export default SidebarDrawer;