diff --git a/src/features/network/api.js b/src/features/machines/api.js similarity index 100% rename from src/features/network/api.js rename to src/features/machines/api.js diff --git a/src/features/network/components/MachineItem.js b/src/features/machines/components/MachineItem.js similarity index 100% rename from src/features/network/components/MachineItem.js rename to src/features/machines/components/MachineItem.js diff --git a/src/features/network/components/MachineLog.js b/src/features/machines/components/MachineLog.js similarity index 100% rename from src/features/network/components/MachineLog.js rename to src/features/machines/components/MachineLog.js diff --git a/src/features/machines/components/MachinesComponent.js b/src/features/machines/components/MachinesComponent.js new file mode 100644 index 0000000..34b1344 --- /dev/null +++ b/src/features/machines/components/MachinesComponent.js @@ -0,0 +1,13 @@ +import React from "react"; +import PropTypes from "prop-types"; +import MachinesList from "./MachinesList"; + +const MachinesComponent = ({ network }) => { + return ; +}; + +MachinesComponent.propTypes = { + network: PropTypes.object.isRequired +}; + +export default MachinesComponent; diff --git a/src/features/machines/components/MachinesContainer.js b/src/features/machines/components/MachinesContainer.js new file mode 100644 index 0000000..64afb0d --- /dev/null +++ b/src/features/machines/components/MachinesContainer.js @@ -0,0 +1,37 @@ +import React, { useContext, useEffect, useCallback } from "react"; +import { + ApplicationStateContext, + ApplicationDispatchContext +} from "../../../state/ApplicationContexts"; +import { readMachines } from "../api"; +import MachinesComponent from "./MachinesComponent"; + +const MachinesContainer = () => { + const state = useContext(ApplicationStateContext); + const dispatchActions = useContext(ApplicationDispatchContext); + + const handleChange = prop => event => { + dispatchActions.onNetworkChange(prop, event.target.value); + }; + + const handleReadMachines = useCallback(async () => { + const machines = await readMachines(); + const data = Object.assign(machines, { loaded: true }); + dispatchActions.onNetworkChange("machines", data); + }, [dispatchActions]); + + useEffect(() => { + if (!state.network.machines.loaded) { + handleReadMachines(); + } + }, [handleReadMachines, state.network.machines.loaded]); + + return ( + + ); +}; + +export default MachinesContainer; diff --git a/src/features/network/components/MachinesList.js b/src/features/machines/components/MachinesList.js similarity index 100% rename from src/features/network/components/MachinesList.js rename to src/features/machines/components/MachinesList.js diff --git a/src/features/network/components/NetworkComponent.js b/src/features/network/components/NetworkComponent.js deleted file mode 100644 index dcdbdc1..0000000 --- a/src/features/network/components/NetworkComponent.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { TextField, Button } from "@material-ui/core"; -import MachinesList from "./MachinesList"; -import { makeStyles } from "@material-ui/core/styles"; -import styles from "../styles"; - -const useStyles = makeStyles(styles); - -const NetworkComponent = ({ network, onPropertyChange }) => { - const classes = useStyles(); - - return ( -
- -
- -
-
- -
- ); -}; - -NetworkComponent.propTypes = { - network: PropTypes.object.isRequired, - onPropertyChange: PropTypes.func.isRequired -}; - -export default NetworkComponent; diff --git a/src/features/network/components/NetworkContainer.js b/src/features/network/components/NetworkContainer.js index 1e6cfb7..b0fc2c6 100644 --- a/src/features/network/components/NetworkContainer.js +++ b/src/features/network/components/NetworkContainer.js @@ -1,33 +1,19 @@ -import React, { useContext, useEffect, useCallback } from "react"; -import { - ApplicationStateContext, - ApplicationDispatchContext -} from "../../../state/ApplicationContexts"; -import { readMachines } from "../api"; -import NetworkComponent from "./NetworkComponent"; +import React from "react"; +import MachinesContainer from "../../machines/components/MachinesContainer"; +import NotesContainer from "../../notes/components/NotesContainer"; +import { makeStyles } from "@material-ui/core/styles"; +import styles from "../styles"; + +const useStyles = makeStyles(styles); const NetworkContainer = () => { - const state = useContext(ApplicationStateContext); - const dispatchActions = useContext(ApplicationDispatchContext); - - const handleChange = prop => event => { - dispatchActions.onNetworkChange(prop, event.target.value); - }; - - const handleReadMachines = useCallback(async () => { - const machines = await readMachines(); - const data = Object.assign(machines, { loaded: true }); - dispatchActions.onNetworkChange("machines", data); - }, [dispatchActions]); - - useEffect(() => { - if (!state.network.machines.loaded) { - handleReadMachines(); - } - }, [handleReadMachines, state.network.machines.loaded]); + const classes = useStyles(); return ( - +
+ + +
); }; diff --git a/src/features/notes/components/NotesContainer.js b/src/features/notes/components/NotesContainer.js new file mode 100644 index 0000000..6efc323 --- /dev/null +++ b/src/features/notes/components/NotesContainer.js @@ -0,0 +1,33 @@ +import React, { useContext } from "react"; +import { TextField, Button } from "@material-ui/core"; +import { + ApplicationStateContext, + ApplicationDispatchContext +} from "../../../state/ApplicationContexts"; + +const NotesContainer = () => { + const state = useContext(ApplicationStateContext); + const dispatchActions = useContext(ApplicationDispatchContext); + + const handleChange = prop => event => { + dispatchActions.onNetworkChange(prop, event.target.value); + }; + + return ( + <> + +
+
+ + + ); +}; + +export default NotesContainer;