This commit is contained in:
Eden Kirin
2024-01-16 08:22:28 +01:00
parent cd5a93351b
commit 423b853b82
4 changed files with 49 additions and 2 deletions

View File

@ -34,6 +34,7 @@ function Machines({ machines, onSelect }) {
<Typography variant="h4" gutterBottom> <Typography variant="h4" gutterBottom>
Machines Machines
</Typography> </Typography>
<List> <List>
<Paper>{machineItems}</Paper> <Paper>{machineItems}</Paper>
</List> </List>

View File

@ -0,0 +1,31 @@
import * as React from "react";
import Card from "@mui/material/Card";
import CardContent from "@mui/material/CardContent";
import CardMedia from "@mui/material/CardMedia";
import Typography from "@mui/material/Typography";
import { CardActionArea } from "@mui/material";
function ProductCard({ product }) {
return (
<Card>
<CardActionArea>
<CardMedia
component="img"
height="140"
image="/static/images/cards/contemplative-reptile.jpg"
alt="green iguana"
/>
<CardContent>
<Typography gutterBottom variant="h5" component="div">
{product.name}
</Typography>
<Typography variant="body2" color="text.secondary">
{product.description}
</Typography>
</CardContent>
</CardActionArea>
</Card>
);
}
export { ProductCard };

View File

@ -1,11 +1,26 @@
import * as React from "react";
import Grid from "@mui/material/Unstable_Grid2";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import { ProductCard } from "./ProductCard";
function Products({ machineName, products, onSelect }) { function Products({ machineName, products, onSelect }) {
const productItems = products.map((product) => {
return (
<Grid md={6} key={product.id}>
<ProductCard product={product} />
</Grid>
);
});
return ( return (
<> <>
<Typography variant="h4" gutterBottom> <Typography variant="h4" gutterBottom>
Products - {machineName} Products - {machineName}
</Typography> </Typography>
<Grid container spacing={2}>
{productItems}
</Grid>
</> </>
); );
} }

View File

@ -30,10 +30,10 @@ function Home() {
return ( return (
<Grid container spacing={2}> <Grid container spacing={2}>
<Grid md={4}> <Grid md={3}>
<Machines machines={machines} onSelect={onMachineSelect} /> <Machines machines={machines} onSelect={onMachineSelect} />
</Grid> </Grid>
<Grid md={8}> <Grid md={9}>
{productsData && <Products machineName={productsData.machineName} products={productsData.products} />} {productsData && <Products machineName={productsData.machineName} products={productsData.products} />}
</Grid> </Grid>
</Grid> </Grid>