Skip to content
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
33 changes: 33 additions & 0 deletions e-commerce-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions e-commerce-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"react-redux": "^8.1.2",
"react-router-dom": "^6.14.2",
"react-scripts": "5.0.1",
"react-toastify": "^9.1.3",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
Expand Down Expand Up @@ -50,7 +51,6 @@
]
},
"devDependencies": {
"sass": "^1.66.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand All @@ -63,6 +63,7 @@
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-prettier": "^5.0.0",
"husky": "^8.0.3",
"prettier": "^3.0.0"
"prettier": "^3.0.0",
"sass": "^1.66.1"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed e-commerce-app/src/assets/images/TestImg-1.png
Binary file not shown.
Binary file removed e-commerce-app/src/assets/images/TestImg-2.jpeg
Binary file not shown.
Binary file removed e-commerce-app/src/assets/images/TestImg.jpeg
Binary file not shown.
179 changes: 176 additions & 3 deletions e-commerce-app/src/pages/BasketPage/BasketPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,178 @@
import React from 'react';
import { FC } from 'react';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import { Box } from '@mui/system';
import { useNavigate } from 'react-router-dom';
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace';
import { Button, TextField } from '@mui/material';
import Grid from '@mui/material/Grid';
import EmptyBasket from '../../assets/images/BasketPageImg.png';
import Paper from '@mui/material/Paper';
import Divider from '@mui/material/Divider';
import ButtonBase from '@mui/material/ButtonBase';
import { styled } from '@mui/material/styles';

export const BasketPage: React.FC = () => {
return <div>Basket Page</div>;
const Img = styled('img')({
margin: 'auto',
display: 'block',
maxWidth: '100%',
maxHeight: '100%',
});

export const BasketPage: FC = () => {
const navigate = useNavigate();
return (
<Container className="container" sx={{ textAlign: 'center', mt: '5%' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason of useing className? there are no styles imported
in case of styles in another scss file it's better to import styles file as module and use dynamic styles as className={styles.container}. so we can reuse the same classnames all over the application with different styles in different components. And on production components will have different classNames

<Typography variant="h3" fontWeight="500" color="green">
Shopping cart
</Typography>
(
<Box className="cart-empty">
<Typography variant="h5" mt="5%">
Your cart is empty
</Typography>
<Button
className="start-shopping"
sx={{ backgroundColor: 'yellowgreen', color: 'green', mt: '5%' }}
>
<KeyboardBackspaceIcon width="20" />
<Box component="span" onClick={() => navigate('/products')}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It.s better to use onClick action on Button component

Start shopping
</Box>
</Button>
</Box>
<img src={EmptyBasket} alt="EmptyBasket" width={300} />) : (
<Paper
sx={{
p: 2,
margin: 'auto',
maxWidth: 800,
flexGrow: 1,
}}
>
<Grid container className="titles" textAlign="start">
<Grid item xs={7}>
<Typography>Product</Typography>
</Grid>
<Grid item xs={1.8}>
<Typography>Price</Typography>
</Grid>
<Grid item xs={2.2}>
<Typography>Quantity</Typography>
</Grid>
<Grid item xs={1}>
<Typography>Total</Typography>
</Grid>
</Grid>
<Divider />
<Grid container className="cart-items" spacing={2} textAlign="start">
<Grid item>
<ButtonBase sx={{ width: 128, height: 128 }}>
<Img alt="complex" src={EmptyBasket} />
</ButtonBase>
</Grid>
<Grid item xs={12} sm container>
<Grid item xs={6} container direction="column" spacing={2} alignSelf="center">
<Grid item xs>
<Typography gutterBottom variant="subtitle1" component="div">
Product name
</Typography>
<Typography variant="body2" gutterBottom>
Short description
</Typography>
</Grid>
<Grid item>
<Typography sx={{ cursor: 'pointer' }} variant="body2" color="text.secondary">
Remove
</Typography>
</Grid>
</Grid>
<Grid item className="cart-product-price" xs={2} alignSelf="center">
<Typography variant="subtitle1" component="div">
19.00
</Typography>
</Grid>
<Grid item className="cart-product-quantity" xs={2.8} alignSelf="center" display="flex">
<Button sx={{ minWidth: 'min-content', backgroundColor: 'lightgrey' }}>-</Button>
<Typography className="count" padding="0.7rem 0">
1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use variables instead of using "magic numbers"

</Typography>
<Button sx={{ minWidth: 'min-content', backgroundColor: 'lightgrey' }}>+</Button>
</Grid>
<Grid item className="cart-product_total-price" xs={1.2} alignSelf="center">
<Typography variant="subtitle1" component="div" fontWeight="700">
19.00
</Typography>
</Grid>
</Grid>
</Grid>
<Divider />
<Box className="cart-summary" display="flex" justifyContent="space-between" mt="5%">
<Button className="clear-cart" sx={{ height: '40px', border: '1px solid grey' }}>
Clear Cart
</Button>
<Grid container xs={5} className="cart-checkout">
<Grid className="subtotal" container fontWeight={700} fontSize="large">
<Grid item xs={6} textAlign="left">
Subtotal
</Grid>
<Grid item xs={6} textAlign="right">
19.00
</Grid>
</Grid>
<Typography mt="3px" fontSize="small">
Taxes and shipping calculated at checkout
</Typography>

<Grid container mt={4} height={30}>
<Grid item xs={9}>
<TextField fullWidth size="small" label="Promo Code" />
</Grid>
<Grid item xs={3}>
<Button sx={{ backgroundColor: 'beige', color: 'green' }}>Apply</Button>
</Grid>
</Grid>

<Grid
className="subtotal"
container
fontWeight={700}
fontSize="20px"
mt={3}
color="green"
>
<Grid item xs={9} textAlign="left">
Discounted Price
</Grid>
<Grid item xs={3} textAlign="right">
19.00
</Grid>
</Grid>

<Grid container mt={2}>
<Grid item xs={12} mb={5}>
<Button
sx={{ width: '100%', backgroundColor: 'yellowgreen', color: 'green', mt: '5%' }}
>
Check out
</Button>
</Grid>
<Grid item xs={12}>
<Button
className="continue-shopping"
sx={{ border: '1px solid grey', fontSize: '10px' }}
>
<KeyboardBackspaceIcon width="20" />
<Box component="span" onClick={() => navigate('/products')}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same.
use action onClick on button, its's better way

Continue shopping
</Box>
</Button>
</Grid>
</Grid>
</Grid>
</Box>
</Paper>
)
</Container>
);
};