Skip to content

Commit c92a78a

Browse files
Merge pull request #25 from bhagirathpaliyal/Order
added order detail popup
2 parents f761007 + 8c88b1a commit c92a78a

File tree

8 files changed

+377
-91
lines changed

8 files changed

+377
-91
lines changed

package-lock.json

Lines changed: 289 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@emotion/react": "^11.13.0",
13+
"@emotion/react": "^11.13.3",
1414
"@emotion/styled": "^11.13.0",
1515
"@fortawesome/fontawesome-free": "^6.5.1",
16+
"@mui/icons-material": "^6.0.1",
1617
"@mui/lab": "^5.0.0-alpha.173",
17-
"@mui/material": "^5.16.6",
18+
"@mui/material": "^6.0.1",
1819
"@reduxjs/toolkit": "^2.2.7",
1920
"firebase": "^10.10.0",
2021
"react": "^18.2.0",

src/App.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { UserTypeSelector } from './components/UserTypeSelecctor';
1818
import { UserTypeSelectorLogin } from './components/UserTypeSelecctorLogin';
1919
import AddProducts from './components/AddProducts';
2020
import Order from './components/Order/Order';
21+
import OrderDetails from './components/Order/OrderDetails';
2122

2223

2324
function App() {
@@ -50,6 +51,7 @@ useEffect(()=>{
5051

5152
<Route path="/AddProducts" element={<AddProducts />} />
5253
<Route path="/Order" element={<Order />} />
54+
<Route path="/OrderDetails" element={<OrderDetails />} />
5355
</Routes>
5456
</div>
5557
</BrowserRouter>

src/components/AddProducts.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const AddProducts = () => {
134134
<div className='text-lg font-bold'>Your Products</div>
135135
<ul className='flex flex-wrap gap-[20px] justify-center'>
136136
{products.map((item, index) =>
137-
item.merchant.email === user.email ? (
137+
item.merchant?.email === user.email ? (
138138
<Item key={index} index={index + 20} data={item} name={item.merchant.name} />
139139
) : null
140140
)}

src/components/Order/Order.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const skeleton=[1,2,3,4,5,6,7,8,9,10,11,12];
1919
.finally(() => setLoading(false));
2020
}
2121
}, [user, dispatch]);
22+
23+
2224
console.log(orderItems)
2325
return (
2426
<div className='mt-[66px] flex flex-col gap-4 items-center'>

src/components/Order/OrderCard.jsx

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
import React from 'react';
2-
import { Card, CardContent, Typography } from '@mui/material';
3-
import { styled } from '@mui/material/styles';
1+
import React, { useState } from 'react';
2+
import { Card, CardContent, Typography, Button } from '@mui/material';
3+
import { Link } from 'react-router-dom';
4+
import OrderDetails from './OrderDetails';
45

5-
const StyledCard = styled(Card)(({ theme }) => ({
6-
borderRadius: '10px',
7-
padding: theme.spacing(2),
8-
boxShadow: theme.shadows[3],
9-
}));
106

117
const OrderCard = ({ data }) => {
8+
const handleDetailsClick = () => {
9+
// Handle button click here
10+
console.log('Order Details clicked');
11+
};
12+
const [isPopupOpen, setIsPopupOpen] = useState(false);
13+
14+
15+
1216
return (
13-
<StyledCard className="border p-5 rounded-[10px] flex items-center">
17+
<Card className="flex flex-col sm:flex-row items-center p-5 rounded-lg shadow-lg">
1418
<img
1519
src={data.orderedProducts.image}
1620
alt="Product"
17-
className="h-[300px] w-auto mb-4"
21+
className="h-auto w-[250px] sm:w-[200px] mb-4 sm:mb-0 sm:mr-4 rounded-lg object-cover"
1822
/>
19-
<CardContent>
23+
<CardContent className="flex flex-col">
2024
<Typography variant="h6" gutterBottom>
2125
OrderId: <span className="font-bold">{data.orderId}</span>
2226
</Typography>
@@ -29,8 +33,20 @@ const OrderCard = ({ data }) => {
2933
<Typography variant="body1">
3034
Merchant Name: <span className="font-bold">{data.merchant?.name}</span>
3135
</Typography>
36+
37+
38+
<Button variant="contained" color="primary" className="p-4" onClick={() => setIsPopupOpen(true)}>
39+
Show Order Details
40+
</Button>
41+
<OrderDetails
42+
open={isPopupOpen}
43+
onClose={() => setIsPopupOpen(false)}
44+
order={data.orderId}
45+
orderStatus={data.orderStatus}
46+
/>
47+
3248
</CardContent>
33-
</StyledCard>
49+
</Card>
3450
);
3551
};
3652

src/components/Order/OrderDetails.jsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react';
2+
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography } from '@mui/material';
3+
import { CheckCircle, LocalShipping, Cancel } from '@mui/icons-material';
4+
5+
const OrderDetails = ({ open, onClose, order,orderStatus }) => {
6+
// Status icons
7+
const getStatusIcon = (status) => {
8+
switch (status) {
9+
case 'Ordered':
10+
return <CheckCircle color="primary" />;
11+
case 'Shipped':
12+
return <LocalShipping color="action" />;
13+
case 'Delivered':
14+
return <CheckCircle color="success" />;
15+
default:
16+
return <Cancel color="error" />;
17+
}
18+
};
19+
20+
return (
21+
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
22+
<DialogTitle className="bg-blue-500 text-white">Order Details</DialogTitle>
23+
<DialogContent>
24+
<div className="space-y-4">
25+
<Typography variant="h6" className="font-bold">
26+
Order ID: <span className="font-normal">{order}</span>
27+
</Typography>
28+
<Typography variant="body1">
29+
Status: <span className="font-bold">{orderStatus}</span>
30+
</Typography>
31+
<div className="flex items-center space-x-2">
32+
{['Ordered', 'Shipped', 'Delivered'].map((stage) => (
33+
<div key={stage} className="flex items-center space-x-1">
34+
{getStatusIcon(stage)}
35+
<Typography variant="body2">{stage}</Typography>
36+
</div>
37+
))}
38+
</div>
39+
</div>
40+
</DialogContent>
41+
<DialogActions>
42+
<Button onClick={onClose} color="primary">
43+
Close
44+
</Button>
45+
</DialogActions>
46+
</Dialog>
47+
);
48+
};
49+
50+
export default OrderDetails;

src/components/store/feature/orderSlice.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export const fetchOrder = createAsyncThunk(
2121
orders.push({orderedProducts: await orderProduct.data(),
2222
merchant: await merchantData.data(),
2323
user: await userData.data(),
24-
orderId: item.ref.id
24+
orderId: item.ref.id,
25+
orderStatus:'Ordered'
2526

2627
})
2728
}

0 commit comments

Comments
 (0)