import React from "react"; import { Card, Collapse } from "react-bootstrap"; import { ChevronDown, ChevronRight } from "react-bootstrap-icons"; import { GenericComponent } from "./GenericComponent"; import { LevelName } from "./NotificationsComponent"; import { SerializedObject } from "../types/SerializedObject"; import useLocalStorage from "../hooks/useLocalStorage"; import useSortedEntries from "../hooks/useSortedEntries"; interface DataServiceProps { props: DataServiceJSON; isInstantUpdate: boolean; addNotification: (message: string, levelname?: LevelName) => void; displayName: string; id: string; } export type DataServiceJSON = Record; export const DataServiceComponent = React.memo( ({ props, isInstantUpdate, addNotification, displayName, id }: DataServiceProps) => { // Retrieve the initial state from localStorage, default to true if not found const [open, setOpen] = useLocalStorage(`dataServiceComponent-${id}-open`, true); const sortedEntries = useSortedEntries(props); if (displayName !== "") { return (
setOpen(!open)} style={{ cursor: "pointer" }}> {displayName} {open ? : } {sortedEntries.map((value) => ( ))}
); } else { return (
{sortedEntries.map((value) => ( ))}
); } }, ); DataServiceComponent.displayName = "DataServiceComponent";