all requested changs done
Some checks failed
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled

This commit is contained in:
ROSHAN GARG 2024-11-22 10:59:02 +05:30
parent 983186c56d
commit 279e8842e9
8 changed files with 76 additions and 47 deletions

View File

@ -177,7 +177,7 @@ const OrderDetails = () => {
<TableRow>
<TableCell colSpan={7} />
<TableCell>
Total GST:<strong> {gstTotal} </strong>
Total GST:<strong> {gstTotal.toFixed(2)} </strong>
</TableCell>
</TableRow>
<TableRow>

View File

@ -163,7 +163,7 @@ const ReviewOrder = ({
<TableRow>
<TableCell colSpan={7} />
<TableCell>
Total GST:<strong> {totalGST} </strong>
Total GST:<strong> {totalGST.toFixed(2)} </strong>
</TableCell>
</TableRow>

View File

@ -137,8 +137,8 @@ const ShoppingCart = ({ handleTabChange }) => {
</Box>
</TableCell>
<TableCell>{row.price}</TableCell>
<TableCell>{gstAmount}</TableCell>
<TableCell>{row.price * row.count}</TableCell>
<TableCell>{gstAmount.toFixed(2)}</TableCell>
<TableCell>{(row.price * row.count).toFixed(2)}</TableCell>
</TableRow>
)
})}
@ -151,7 +151,7 @@ const ShoppingCart = ({ handleTabChange }) => {
<TableRow>
<TableCell colSpan={5} />
<TableCell>
Total GST:<strong> {totalGST} </strong>
Total GST:<strong> {totalGST.toFixed(2)} </strong>
</TableCell>
</TableRow>

View File

@ -47,7 +47,7 @@ const InvoiceTable = ({ invoices }) => {
))}
</TableCell>
<TableCell>{invoice.subtotal}</TableCell>
<TableCell>{invoice.gstTotal}</TableCell>
<TableCell>{invoice.gstTotal.toFixed(2)}</TableCell>
<TableCell>{invoice.invoiceAmount}</TableCell>
<TableCell>
<Chip

View File

@ -72,11 +72,11 @@ const OrderDetailsDialog = ({ open, onClose, order, onSubmit }) => {
<TableRow key={index}>
<TableCell>
<img
src={item.productId.image}
alt={item.productId.name}
src={item?.image[0]?.url}
alt={item.name}
style={{ width: 50, height: 50, marginRight: 10 }}
/>
<Typography variant="subtitle1">{item.productId.name}</Typography>
<Typography variant="subtitle1">{item.name}</Typography>
</TableCell>
<TableCell align="right">{item.price}</TableCell>
<TableCell align="right">{item.remainingQuantity}</TableCell>

View File

@ -304,13 +304,13 @@ const ViewOrders = () => {
marginRight: 10,
}}
/>
<Typography variant="subtitle1">{item.productId.name}</Typography>
<Typography variant="subtitle1">{item.name} </Typography>
</TableCell>
<TableCell align="right">{item.price}</TableCell>
<TableCell align="right">{item.quantity}</TableCell>
<TableCell align="right">{subtotal}</TableCell>
<TableCell align="right">{item.GST}%</TableCell>
<TableCell align="right">{gstAmount}</TableCell>
<TableCell align="right">{gstAmount.toFixed(2)}</TableCell>
<TableCell align="right">{totalWithGST}</TableCell>
</TableRow>
)
@ -347,7 +347,7 @@ const ViewOrders = () => {
<Typography>Total Items: {order?.orderItem.length}</Typography>
<Typography>Total Subtotal: {order?.subtotal}</Typography>
<Typography>Total GST: {order?.gstTotal}</Typography>
<Typography>Total GST: {order?.gstTotal.toFixed(2)}</Typography>
<Typography variant="h5" sx={{ marginTop: 2 }}>
Grand Total: {order?.grandTotal}
</Typography>
@ -355,7 +355,7 @@ const ViewOrders = () => {
</Grid>
{/* <Grid item sm={6} md={6} xl={6}>
<TableContainer
component={Paper}
component={Paper}ss
sx={{ maxWidth: 600, margin: "auto", mt: 4 }}
>
<Table

View File

@ -13,6 +13,13 @@ import {
Pagination,
Select,
Typography,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Paper,
} from '@mui/material'
import ShopCard from './shopCard'
@ -23,7 +30,7 @@ const Shop = () => {
const [loading, setLoading] = useState(true)
const [currentPage, setCurrentPage] = useState(1)
const [totalData, setTotalData] = useState(0)
const itemsPerPage = 10 // Adjust this according to your requirements
const itemsPerPage = 10
const nameRef = useRef('')
const categoryRef = useRef('')
@ -33,14 +40,14 @@ const Shop = () => {
const handleChange = (event) => {
const selectedValue = event.target.value
setOption(selectedValue)
categoryRef.current = selectedValue === 'all' ? '' : selectedValue // Set to an empty string if "All" is selected
setCurrentPage(1) // Reset to first page when filter changes
categoryRef.current = selectedValue === 'all' ? '' : selectedValue
setCurrentPage(1)
}
const getCategories = async () => {
try {
const response = await Axios.get('/api/category/getCategories')
setCategories(response.data?.categories || []) // Assuming the response has a categories property
setCategories(response.data?.categories || [])
} catch (err) {
Swal.fire({
title: 'Error',
@ -60,7 +67,7 @@ const Shop = () => {
page: currentPage,
show: itemsPerPage,
name: nameRef.current || '',
category: categoryRef.current || '', // Send category only if it's not empty
category: categoryRef.current || '',
},
})
setProducts(response.data?.products || [])
@ -80,13 +87,14 @@ const Shop = () => {
}
useEffect(() => {
getCategories() // Fetch categories on component mount
getCategories()
getProductsData()
}, [currentPage, option])
const handlePageChange = (event, value) => {
setCurrentPage(value)
}
console.log(products)
return (
<Container>
@ -114,13 +122,45 @@ const Shop = () => {
<CircularProgress />
) : (
<>
<Grid container spacing={2}>
{products.map((item, i) => (
<Grid key={i} item xs={12} sm={6} md={4} lg={4}>
<ShopCard item={item} />
</Grid>
))}
</Grid>
<TableContainer component={Paper} sx={{ mt: 3 }}>
<Table>
<TableHead>
<TableRow>
<TableCell sx={{ fontWeight: 'bold' }} align="center">
Product Name
</TableCell>
<TableCell sx={{ fontWeight: 'bold' }} align="center">
Category
</TableCell>
<TableCell sx={{ fontWeight: 'bold' }} align="center">
Price
</TableCell>
<TableCell sx={{ fontWeight: 'bold' }} align="center">
Action
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{products?.map((product) => (
<TableRow key={product._id}>
<TableCell size="small" align="center">
{product?.name}
</TableCell>
<TableCell size="small" align="center">
{product.category.categoryName}
</TableCell>
<TableCell size="small" align="center">
{product.price}
</TableCell>
<TableCell size="small" align="center">
<ShopCard item={product} />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
<Box mt={3} display="flex" justifyContent="center">
<Pagination
count={Math.ceil(totalData / itemsPerPage)}

View File

@ -18,27 +18,16 @@ const ShopCard = ({ item }) => {
}
return (
<div>
<Card>
<CardMedia component="img" height="150" image={item?.image} alt={item?.name} />
<CardContent>
<Typography gutterBottom variant="h5" component="div">
{item?.name}
</Typography>
<Typography variant="body2" color="text.secondary">
${item?.price}
</Typography>
<Button
variant="contained"
color="primary"
fullWidth
disabled={isProductInCart}
onClick={handleAddToCart}
sx={{ marginTop: '10px' }}
>
{isProductInCart ? 'Already in Cart' : 'Add to Cart'}
</Button>
</CardContent>
</Card>
<Button
variant="contained"
color="primary"
// fullWidth
disabled={isProductInCart}
onClick={handleAddToCart}
sx={{ marginTop: '10px' }}
>
{isProductInCart ? 'Already in Cart' : 'Add to Cart'}
</Button>
</div>
)
}