Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new products #96

Merged
merged 4 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added webapp/public/cars/2000gt/2000gt (1).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/2000gt/2000gt (2).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/2000gt/2000gt (3).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/2000gt/2000gt (4).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/2000gt/2000gt (5).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/300zx/300zx (1).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/300zx/300zx (2).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/300zx/300zx (3).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/300zx/300zx (4).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/300zx/300zx (5).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/barracuda/barracuda (1).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/barracuda/barracuda (2).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/barracuda/barracuda (3).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/barracuda/barracuda (4).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/barracuda/barracuda (5).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (1).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (2).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (3).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (4).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (5).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (6).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (7).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm2/bmwm2 (8).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm4/bmwm4 (1).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm4/bmwm4 (2).jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/public/cars/bmwm4/bmwm4 (3).jpg
Binary file added webapp/public/cars/brz/brz (1).jpg
Binary file added webapp/public/cars/brz/brz (2).jpg
Binary file added webapp/public/cars/brz/brz (3).jpg
Binary file added webapp/public/cars/brz/brz (4).jpg
Binary file added webapp/public/cars/brz/brz (5).jpg
Binary file added webapp/public/cars/civic/civic (1).jpg
Binary file added webapp/public/cars/civic/civic (2).jpg
Binary file added webapp/public/cars/civic/civic (3).jpg
Binary file added webapp/public/cars/civic/civic (4).jpg
Binary file added webapp/public/cars/civic/civic (5).jpg
Binary file added webapp/public/cars/countach/countach (1).jpg
Binary file added webapp/public/cars/countach/countach (2).jpg
Binary file added webapp/public/cars/countach/countach (3).jpg
Binary file added webapp/public/cars/countach/countach (4).jpg
Binary file added webapp/public/cars/countach/countach (5).jpg
Binary file added webapp/public/cars/countach/countach (6).jpg
Binary file added webapp/public/cars/countach/countach (7).jpg
Binary file added webapp/public/cars/countach/countach (8).jpg
Binary file added webapp/public/cars/golf8/golf8 (1).jpg
Binary file added webapp/public/cars/golf8/golf8 (2).jpg
Binary file added webapp/public/cars/golf8/golf8 (3).jpg
Binary file added webapp/public/cars/golf8/golf8 (4).jpg
Binary file added webapp/public/cars/golf8/golf8 (5).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (1).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (10).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (2).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (3).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (4).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (5).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (6).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (7).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (8).jpg
Binary file added webapp/public/cars/gtr50/gtr50 (9).jpg
Binary file added webapp/public/cars/hondachr/hondachr (1).jpg
Binary file added webapp/public/cars/hondachr/hondachr (2).jpg
Binary file added webapp/public/cars/hondachr/hondachr (3).jpg
Binary file added webapp/public/cars/hondachr/hondachr (4).jpg
Binary file added webapp/public/cars/hondachr/hondachr (5).jpg
Binary file added webapp/public/cars/hondachr/hondachr (6).jpg
Binary file added webapp/public/cars/hondachr/hondachr (7).jpg
Binary file added webapp/public/cars/hondachr/hondachr (8).jpg
Binary file added webapp/public/cars/id3/id3 (1).jpg
Binary file added webapp/public/cars/id3/id3 (2).jpg
Binary file added webapp/public/cars/id3/id3 (3).jpg
Binary file added webapp/public/cars/id3/id3 (4).jpg
Binary file added webapp/public/cars/id3/id3 (5).jpg
Binary file added webapp/public/cars/montecarlo/montecarlo (1).jpg
Binary file added webapp/public/cars/montecarlo/montecarlo (2).jpg
Binary file added webapp/public/cars/montecarlo/montecarlo (3).jpg
Binary file added webapp/public/cars/nsx/nsx (1).jpg
Binary file added webapp/public/cars/nsx/nsx (2).jpg
Binary file added webapp/public/cars/nsx/nsx (3).jpg
Binary file added webapp/public/cars/polestar2/polestar2 (1).jpg
Binary file added webapp/public/cars/polestar2/polestar2 (2).jpg
Binary file added webapp/public/cars/polestar2/polestar2 (3).jpg
Binary file added webapp/public/cars/supra/supra (1).jpg
Binary file added webapp/public/cars/supra/supra (2).jpg
Binary file added webapp/public/cars/supra/supra (3).jpg
Binary file added webapp/public/cars/supra/supra (4).jpg
Binary file added webapp/public/cars/supra/supra (5).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (1).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (2).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (3).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (4).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (5).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (6).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (7).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (8).jpg
Binary file added webapp/public/cars/volvoxc40/volvoxc40 (9).jpg
7 changes: 5 additions & 2 deletions webapp/src/components/cart/CartItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ function CartItem(props: CartItemProps) {
setQuantity(props.item.quantity);
}, [props.item.quantity]);

const imgPath = "cars/" + props.item.product.image + "/" + props.item.product.image + " (1).jpg"

return (

<Card variant="elevation" sx={{ display: 'flex', marginBottom: 5 }}>
<CardMedia
component="img"

//set max image to fill the card
//sx={{ maxWidth: '100', maxHeight: '110', width: '100', height: '110' }}
image={props.item.product.image}
image={imgPath}
//image={require("path/to/image.jpg")} FOR TESTING
//set max height to 100px
sx={{ height: 110, width: 100, margin: 3 }}
sx={{ height: 200, width: 100, margin: 3 }}
style={{ flex: 2 }} />
<Box style={{ flex: 3, display: 'flex', flexDirection: 'column' }}
justifyContent='space-between'>
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/components/checkout-shipping/CheckoutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ type CheckoutItemProps = {

function CheckoutItem(props: CheckoutItemProps) {

const imgPath = "cars/" + props.item.product.image + "/" + props.item.product.image + " (1).jpg"

return (
<Card variant="elevation" sx={{ display: 'flex', marginBottom: 5 }}>
<CardMedia
component="img"

image={props.item.product.image}
image={imgPath}
sx={{ height: 260, width: 100, margin: 3 }}
style={{ flex: 2 }} />
<Box style={{ flex: 3, display: 'flex', flexDirection: 'column' }}
Expand Down
9 changes: 5 additions & 4 deletions webapp/src/components/products/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CardMedia from '@mui/material/CardMedia';
import Typography from '@mui/material/Typography';
import { Button, CardActionArea, CardActions } from '@mui/material';
import AddShoppingCartIcon from '@mui/icons-material/AddShoppingCart';
import { styled } from '@mui/system';
import { padding, styled, width } from '@mui/system';

import { useNavigate } from "react-router-dom";
const DivBtonStyle = styled('div')({
Expand Down Expand Up @@ -43,19 +43,20 @@ function addProduct(product: Product): void {
const ProductCard = ( prod: ProductCardProps): JSX.Element => {



const imgPath = "/cars/" + prod.product.image + "/" + prod.product.image + " (1).jpg"

const navigate = useNavigate();

return (

<Card >
<Card
>

<CardActionArea onClick={()=>navigate("products/"+prod.product.id)}>

<CardMedia
component="img"
image={prod.product.image}
image={imgPath}
alt={prod.product.name}
/>
<CardContent>
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/products/ProductPage.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.image-gallery-slide img {
width: 30px;
height:50px;
.MuiButtonBase-root img {
max-width: 60%;
height:100%;
margin:auto;
}
148 changes: 76 additions & 72 deletions webapp/src/components/products/ProductPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useEffect, useState} from "react";
import { useEffect, useState } from "react";
import { Product } from '../../shared/shareddtypes';
import {getProductById} from '../../api/api';
import { getProductById } from '../../api/api';
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 { useParams } from "react-router-dom";
import './ProductPage.css';
import Grid from "@mui/material/Grid";
import {Button} from '@mui/material';
import Grid from "@mui/material/Grid";
import { Button } from '@mui/material';
import AddShoppingCartIcon from '@mui/icons-material/AddShoppingCart';
import { styled } from '@mui/system';

Expand All @@ -19,97 +19,101 @@ type ProductPageProps = {
}

const DivBtonStyle = styled('div')({
backgroundColor: '#7c4dff',
color: '#ffff',
padding: 8,
borderRadius: 4,
position: 'relative',
width:'100%',

});

const BuyBtton = styled(Button)({
size:'large',
position: 'relative',
width:'100%',

});


function addProduct(product: Product): void {
addToCart({ product: product, quantity: 1 });
backgroundColor: '#7c4dff',
color: '#ffff',
padding: 8,
borderRadius: 4,
position: 'relative',
width: '100%',

});

const BuyBtton = styled(Button)({
size: 'large',
position: 'relative',
width: '100%',

});


function addProduct(product: Product): void {
addToCart({ product: product, quantity: 1 });

}

function ProductPage(prop: ProductPageProps): JSX.Element {
const { id } = useParams();
const [product, setProduct] = useState<Product>(); //default empty product
const getProduct = async () => {
await setProduct(await getProductById(id));
};
useEffect(() => {
getProduct();
}, []);

}

function ProductPage(prop : ProductPageProps) : JSX.Element {
const {id} = useParams();
const [product, setProduct] = useState<Product>(); //default empty product
const getProduct = async () => {
await setProduct(await getProductById(id));
};
useEffect(()=>{
getProduct();
}, []);


if(product){
if (product) {

const imgPath = "/cars/" + product?.image + "/" + product?.image + " (1).jpg"

return (
<Grid container
direction="row"
justifyContent="left"
alignItems="center"
spacing={{ xs: 2, md: 3 }} columns={{ xs: 6, sm: 12, md: 15 }}
rowSpacing={5}
>
<Grid item xs={2} sm={5} md={6} >
<Card sx={{ maxWidth: 345 }} style={{height:"100%"}}>
<CardMedia

>

<Grid item xs={2} sm={5} md={6} >
<Card sx={{ maxWidth: 345 }} style={{ height: "100%" }}>

<CardMedia
component="img"
image={product?.image}
image={imgPath}
alt={product.name}

/>
<CardContent>
/>
<CardContent>
<Typography gutterBottom variant="h3" component="div">
{product?.name}
{product?.name}
</Typography>
<Typography gutterBottom variant="h5" component="div">
{product?.price}€
{product?.price}€
</Typography>
<Typography gutterBottom variant="body1" component="div">
{product?.description}
{product?.description}
</Typography>
</CardContent>
</Card>
</Grid>
<Grid item xs={2} sm={5} md={6} >
</CardContent>


</Card>
</Grid>
<Grid item xs={2} sm={5} md={6} >
<DivBtonStyle>
<BuyBtton startIcon={<AddShoppingCartIcon />} onClick={()=>{addProduct(product);
prop.refreshCartList();}} >
<BuyBtton startIcon={<AddShoppingCartIcon />} onClick={() => {
addProduct(product);
prop.refreshCartList();
}} >
Add to Cart
</BuyBtton>
</BuyBtton>
</DivBtonStyle>
</Grid>
</Grid>
// the button is contained because it has actions that are primary to our app( add an Item to the cart)
</Grid>

</Grid>


// the button is contained because it has actions that are primary to our app( add an Item to the cart)


);
}else{
} else {
return (<Typography gutterBottom variant="body1" component="div">
No product found
</Typography>);
No product found
</Typography>);
}
}
}



export default ProductPage;