-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b710871
commit ff4f9c1
Showing
8 changed files
with
259 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
client/ecommerce/src/components/SpecificProduct/ProductMainContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Box, Typography } from "@mui/material"; | ||
import { ProductWithImageAndUser } from "../../types/types"; | ||
import { DisplayUserProducts } from "../DisplayUserProducts"; | ||
import { useMediaQuery } from "../../hooks/useMediaQuery"; | ||
|
||
type ProductMainContentProps = { | ||
product: ProductWithImageAndUser; | ||
userProducts: ProductWithImageAndUser[] | undefined; | ||
}; | ||
|
||
export const ProductMainContent = (props: ProductMainContentProps) => { | ||
const below960 = useMediaQuery(960); | ||
const below800 = useMediaQuery(800); | ||
|
||
const productsWithoutMainOne = props.userProducts?.filter( | ||
(p) => p.id != props.product.id | ||
); | ||
return ( | ||
<Box | ||
sx={{ | ||
width: below960 ? "100%" : "77%", | ||
display: "flex", | ||
padding: "0px 10px", | ||
justifyContent: "center", | ||
flexDirection: "column", | ||
alignItems: "flex-start", | ||
gap: "20px", | ||
height: | ||
props.userProducts?.length == 1 ? (below800 ? "auto" : "auto") : "", | ||
}} | ||
> | ||
<Box | ||
component="img" | ||
src={props.product?.images[0].imageUrl} | ||
sx={{ height: "100%", alignSelf: "center" }} | ||
></Box> | ||
<Box | ||
sx={{ | ||
display: below960 ? "none" : "inline", | ||
marginTop: "40px", | ||
padding: "20px 16px", | ||
backgroundColor: "white", | ||
width: "96%", | ||
}} | ||
> | ||
<Typography | ||
sx={{ | ||
color: "#757575", | ||
fontSize: "14px", | ||
borderBottom: "1px solid rgba(23, 23, 23, 0.15)", | ||
paddingBottom: "5px", | ||
}} | ||
> | ||
Member's items ({props.userProducts?.length}) | ||
</Typography> | ||
</Box> | ||
<Box sx={{ display: below960 ? "none" : "inline" }}> | ||
<DisplayUserProducts | ||
products={productsWithoutMainOne as ProductWithImageAndUser[]} | ||
/> | ||
</Box> | ||
</Box> | ||
); | ||
}; |
156 changes: 156 additions & 0 deletions
156
client/ecommerce/src/components/SpecificProduct/ProductSidebar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import { Box, Button, Typography } from "@mui/material"; | ||
import { DisplayUserInfo } from "../ProductPage/DisplayUserInfo"; | ||
import { ProductWithImageAndUser } from "../../types/types"; | ||
|
||
type ProductProps = { | ||
product: ProductWithImageAndUser; | ||
below960: boolean; | ||
productAuthorId: number; | ||
userId: number; | ||
handleCheckout: ( | ||
e: React.MouseEvent<HTMLButtonElement, MouseEvent> | ||
) => Promise<void>; | ||
handleDeleteProduct: ( | ||
e: React.MouseEvent<HTMLButtonElement, MouseEvent> | ||
) => Promise<void>; | ||
}; | ||
|
||
export const ProductSidebar = (props: ProductProps ) => { | ||
return ( | ||
<Box | ||
sx={{ | ||
width: props.below960 ? "100%" : "23%", | ||
display: "flex", | ||
padding: "0px 10px", | ||
flexDirection: "column", | ||
paddingTop: props.below960 ? "20px" : 0, | ||
gap: "15px", | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
width: "100%", | ||
flexDirection: "column", | ||
display: "flex", | ||
backgroundColor: "white", | ||
padding: "16px", | ||
maxHeight: "50%", | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
width: "auto", | ||
display: "flex", | ||
borderBottom: "1px solid rgba(23, 23, 23, 0.15)", | ||
paddingBottom: "5px", | ||
marginBottom: "8px", | ||
}} | ||
> | ||
<Typography sx={{ fontSize: "22px" }}> | ||
USD {props.product.price}.00 | ||
</Typography> | ||
</Box> | ||
<Box | ||
sx={{ | ||
paddingBottom: "5px", | ||
borderBottom: "1px solid rgba(23, 23, 23, 0.15)", | ||
}} | ||
> | ||
<Box sx={{ display: "flex", padding: "2px" }}> | ||
<Typography | ||
sx={{ fontSize: "13px", color: "#757575", width: "50%" }} | ||
> | ||
BRAND | ||
</Typography> | ||
<Typography sx={{ fontSize: "13px", color: "#757575" }}> | ||
{props.product.brand} | ||
</Typography> | ||
</Box> | ||
<Box sx={{ display: "flex", padding: "2px" }}> | ||
<Typography | ||
sx={{ fontSize: "13px", color: "#757575", width: "50%" }} | ||
> | ||
CATEGORY | ||
</Typography> | ||
<Typography sx={{ fontSize: "13px", color: "#757575" }}> | ||
{props.product.category.toUpperCase()} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
<Box | ||
component="div" | ||
sx={{ | ||
marginTop: "20px", | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "flex-start", | ||
justifyContent: "flex-start", | ||
width: props.below960 ? "50%" : "100%", | ||
whiteSpace: "normal !important", | ||
wordBreak: "break-word", | ||
}} | ||
> | ||
<Typography sx={{ fontSize: "18px" }}>{props.product?.title}</Typography> | ||
<Typography | ||
sx={{ | ||
color: "#4D4D4D", | ||
paddingTop: "8px", | ||
}} | ||
> | ||
{props.product?.description} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
width: "100%", | ||
padding: "0px 16px", | ||
}} | ||
> | ||
{props.productAuthorId === props.userId ? ( | ||
<Button | ||
variant="outlined" | ||
onClick={(e) => props.handleDeleteProduct(e)} | ||
sx={{ | ||
display: "flex", | ||
width: "100%", | ||
textTransform: "none", | ||
border: "1px solid red", | ||
color: "red", | ||
backgroundColor: "white", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
"&:hover": { | ||
border: "1px solid red", | ||
backgroundColor: "white", | ||
}, | ||
}} | ||
> | ||
Delete | ||
</Button> | ||
) : ( | ||
<Button | ||
onClick={(e) => props.handleCheckout(e)} | ||
sx={{ | ||
display: "flex", | ||
width: "100%", | ||
textTransform: "none", | ||
color: "white", | ||
backgroundColor: "#007782", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
"&:hover": { | ||
backgroundColor: "#007782", | ||
}, | ||
}} | ||
> | ||
Buy now | ||
</Button> | ||
)} | ||
</Box> | ||
|
||
<DisplayUserInfo userId={props.productAuthorId} product={props.product} /> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.