diff --git a/src/features/network/components/MachinesList.js b/src/features/network/components/MachinesList.js index e3bc3a0..fb54574 100644 --- a/src/features/network/components/MachinesList.js +++ b/src/features/network/components/MachinesList.js @@ -1,4 +1,5 @@ import React from "react"; +import PropTypes from "prop-types"; import { makeStyles } from "@material-ui/core/styles"; import Accordion from "@material-ui/core/Accordion"; import AccordionSummary from "@material-ui/core/AccordionSummary"; @@ -7,63 +8,40 @@ import Typography from "@material-ui/core/Typography"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; const useStyles = makeStyles(theme => ({ - root: { - width: "100%" - }, heading: { fontSize: theme.typography.pxToRem(15), fontWeight: theme.typography.fontWeightRegular } })); -const MachinesList = () => { +const MachinesList = ({ machines }) => { const classes = useStyles(); return ( -
- - } - aria-controls="panel1a-content" - id="panel1a-header" - > - Accordion 1 - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse - malesuada lacus ex, sit amet blandit leo lobortis eget. - - - - - } - aria-controls="panel2a-content" - id="panel2a-header" - > - Accordion 2 - - - - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse - malesuada lacus ex, sit amet blandit leo lobortis eget. - - - - - } - aria-controls="panel3a-content" - id="panel3a-header" - > - - Disabled Accordion - - - +
+ {machines.map(m => ( + + } + id={`machine-${m.machineId}-summary`} + > + {m.machineName} + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Suspendisse malesuada lacus ex, sit amet blandit leo lobortis + eget. + + + + ))}
); }; +MachinesList.propTypes = { + machines: PropTypes.array.isRequired +}; + export default MachinesList; diff --git a/src/features/network/components/NetworkComponent.js b/src/features/network/components/NetworkComponent.js index 1c1ca56..c7c00c9 100644 --- a/src/features/network/components/NetworkComponent.js +++ b/src/features/network/components/NetworkComponent.js @@ -7,20 +7,22 @@ import styles from "../styles"; const useStyles = makeStyles(styles); -const NetworkComponent = ({ network, onPropertyChange, onReadMachines }) => { +const NetworkComponent = ({ network, onPropertyChange }) => { const classes = useStyles(); return (
-
NetworkContainer
- + +
-
diff --git a/src/features/network/components/NetworkContainer.js b/src/features/network/components/NetworkContainer.js index 277c499..31ef604 100644 --- a/src/features/network/components/NetworkContainer.js +++ b/src/features/network/components/NetworkContainer.js @@ -1,4 +1,4 @@ -import React, { useContext } from "react"; +import React, { useContext, useEffect, useCallback } from "react"; import { ApplicationStateContext, ApplicationDispatchContext @@ -14,17 +14,18 @@ const NetworkContainer = () => { dispatchActions.onNetworkChange(prop, event.target.value); }; - const handleReadMachines = async () => { + const handleReadMachines = useCallback(async () => { + alert("rad"); const machines = await readMachines(); dispatchActions.onNetworkChange("machines", machines); - }; + }, [dispatchActions]); + + useEffect(() => { + handleReadMachines(); + }, [handleReadMachines]); return ( - + ); };