Initial
This commit is contained in:
35
frontend/src/pages/Home.js
Normal file
35
frontend/src/pages/Home.js
Normal file
@ -0,0 +1,35 @@
|
||||
import * as React from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import Grid from "@mui/material/Unstable_Grid2";
|
||||
|
||||
import { machinesApi } from "../api";
|
||||
import { Machines } from "../components/Machines";
|
||||
|
||||
function Home() {
|
||||
const [machines, setMachines] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
machinesApi.list().then((response) => {
|
||||
setMachines(response.data.machines);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const onMachineSelect = (machineName, machineId) => {
|
||||
console.log("selected:", machineName);
|
||||
machinesApi.listProducts(machineId).then((response) => {
|
||||
console.log(response.data.products);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Grid container spacing={2}>
|
||||
<Grid md={4}>
|
||||
<Machines machines={machines} onSelect={onMachineSelect} />
|
||||
</Grid>
|
||||
<Grid md={8}>...</Grid>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
|
||||
export { Home };
|
||||
Reference in New Issue
Block a user