la-flowerita 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -2
- package/server.js +8 -7
- package/src/Controllers/order.controller.js +68 -0
- package/src/Controllers/shoppinglist.controller.js +15 -0
- package/src/Controllers/user.controller.js +79 -22
- package/src/Models/orders.js +12 -0
- package/src/Routes/indexRouter.js +14 -1
- package/src/Services/OrderService.js +46 -0
- package/src/Services/ShoppinglistService.js +2 -2
- package/src/Services/UserService.js +11 -5
- package/src/components/ManageOrders.js +109 -0
- package/src/components/ManageUsers.js +127 -0
- package/src/components/MyOrder.js +62 -0
- package/src/components/MyOrders.js +99 -0
- package/src/components/Order.js +78 -0
- package/src/components/UpdateUserModal.js +304 -0
- package/src/components/User.js +117 -0
- package/src/css/users.css +176 -0
- package/src/index.js +37 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "la-flowerita",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.0",
|
4
4
|
"dependencies": {
|
5
5
|
"@fortawesome/fontawesome-svg-core": "^6.1.2",
|
6
6
|
"@fortawesome/free-solid-svg-icons": "^6.1.2",
|
@@ -11,6 +11,7 @@
|
|
11
11
|
"bootstrap": "^5.2.0",
|
12
12
|
"build": "^0.1.4",
|
13
13
|
"connect-mongo": "^4.6.0",
|
14
|
+
"cookie-parser": "^1.4.6",
|
14
15
|
"cors": "^2.8.5",
|
15
16
|
"dotenv": "^16.0.1",
|
16
17
|
"express": "^4.18.1",
|
@@ -51,6 +52,7 @@
|
|
51
52
|
"utf8": "^3.0.0",
|
52
53
|
"web-vitals": "^2.1.4"
|
53
54
|
},
|
55
|
+
"proxy": "http://localhost:5000/",
|
54
56
|
"scripts": {
|
55
57
|
"start": "react-scripts start",
|
56
58
|
"build": "react-scripts build",
|
@@ -75,4 +77,4 @@
|
|
75
77
|
"last 1 safari version"
|
76
78
|
]
|
77
79
|
}
|
78
|
-
}
|
80
|
+
}
|
package/server.js
CHANGED
@@ -11,6 +11,7 @@ require("./src/Models/products");
|
|
11
11
|
require("./src/Models/orderProducts");
|
12
12
|
require("./src/Models/shoppinglists");
|
13
13
|
require("./src/Models/userShoppinglists");
|
14
|
+
require("./src/Models/orders");
|
14
15
|
|
15
16
|
const dbConfig = require("./src/Config/db");
|
16
17
|
|
@@ -20,14 +21,14 @@ const MongoStore = require('connect-mongo');
|
|
20
21
|
const session = expressSession(
|
21
22
|
{ secret: 'secret',
|
22
23
|
algorithms: ['RS256'],
|
23
|
-
cookie: { maxAge: 60 *
|
24
|
+
cookie: { maxAge: 60 * 15 * 1000 },
|
24
25
|
resave: false,
|
25
26
|
saveUninitialized: false,
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
store: MongoStore.create({
|
28
|
+
mongoUrl: 'mongodb://localhost/FlowersShop', //YOUR MONGODB URL
|
29
|
+
ttl: 15 * 60 * 1000 ,
|
30
|
+
autoRemove: 'native'
|
31
|
+
})
|
31
32
|
})
|
32
33
|
app.use(session);
|
33
34
|
const passport = require('passport');
|
@@ -91,7 +92,7 @@ io.on('connection', function(socket) {
|
|
91
92
|
});
|
92
93
|
})
|
93
94
|
|
94
|
-
const port = 5000;
|
95
|
+
const port = process.env.PORT || 5000;
|
95
96
|
server.listen(port, () => {
|
96
97
|
console.log(`Server Running on port ${port}!`);
|
97
98
|
});
|
@@ -0,0 +1,68 @@
|
|
1
|
+
const OrderService = require("../Services/OrderService");
|
2
|
+
const UserService = require("../Services/UserService");
|
3
|
+
const mongoose = require('mongoose');
|
4
|
+
const Orders = mongoose.model('Orders');
|
5
|
+
const crypto = require('crypto');
|
6
|
+
var fs = require('fs');
|
7
|
+
const imagesMiddleware = require("../Middleware/uploadImage");
|
8
|
+
|
9
|
+
module.exports = class Order {
|
10
|
+
|
11
|
+
static async getOrders(req, res, next){
|
12
|
+
var status = req.body.status;
|
13
|
+
console.log(status);
|
14
|
+
var orders = [];
|
15
|
+
if(status == "All" || !status){
|
16
|
+
console.log("all");
|
17
|
+
orders = await OrderService.GetALL();
|
18
|
+
} else{
|
19
|
+
orders = await OrderService.GetOrderByStatus(status);
|
20
|
+
}
|
21
|
+
console.log(orders);
|
22
|
+
return res.json({orders: orders});
|
23
|
+
}
|
24
|
+
static async getClientOrders(req, res, next){
|
25
|
+
var id = req.user._id;
|
26
|
+
var olduser = await UserService.FindById(id);
|
27
|
+
if(olduser)
|
28
|
+
console.log(id);
|
29
|
+
var orders = [];
|
30
|
+
orders = await OrderService.GetClientOrders(id);
|
31
|
+
return res.json({orders: orders});
|
32
|
+
}
|
33
|
+
static async addNewOrder(req, res, next){
|
34
|
+
var order = req.body.order;
|
35
|
+
order.status = "pending";
|
36
|
+
const newOrder = new Orders(order);
|
37
|
+
await newOrder.save();
|
38
|
+
console.log('Order created:' + newOrder);
|
39
|
+
var id = newOrder._id;
|
40
|
+
console.log(id);
|
41
|
+
return res.json({status: 200, id: id});
|
42
|
+
}
|
43
|
+
|
44
|
+
static async updateOrder(req, res, next){
|
45
|
+
var oldOrder = await OrderService.FindById(req.body.order._id);
|
46
|
+
if(oldOrder){
|
47
|
+
var newOrder= req.body.order;
|
48
|
+
newOrder = new Orders(newOrder);
|
49
|
+
await OrderService.UpdateById(newOrder._id, newOrder)
|
50
|
+
console.log('order updated:' + newOrder);
|
51
|
+
} else{
|
52
|
+
return res.sendStatus(404);
|
53
|
+
}
|
54
|
+
return res.sendStatus(200);
|
55
|
+
}
|
56
|
+
static async updateOrderStatus(req, res, next){
|
57
|
+
var oldOrder = await OrderService.FindById(req.body._id);
|
58
|
+
var status = req.body.status
|
59
|
+
if(oldOrder){
|
60
|
+
await OrderService.UpdateStatus(req.body._id,status)
|
61
|
+
console.log('Order status updated:' + req.body._id);
|
62
|
+
} else{
|
63
|
+
return res.sendStatus(404);
|
64
|
+
}
|
65
|
+
return res.sendStatus(200);
|
66
|
+
}
|
67
|
+
|
68
|
+
}
|
@@ -3,6 +3,7 @@ const mongoose = require('mongoose');
|
|
3
3
|
const Shoppinglists = mongoose.model('Shoppinglists');
|
4
4
|
const Users = mongoose.model('Users');
|
5
5
|
const Products = mongoose.model('Products');
|
6
|
+
const Orders = mongoose.model('Orders');
|
6
7
|
|
7
8
|
module.exports = class Shoppinglist {
|
8
9
|
static async addNewProductToCart(req, res, next) {
|
@@ -178,7 +179,21 @@ module.exports = class Shoppinglist {
|
|
178
179
|
}
|
179
180
|
static async payNow(req, res, next) {
|
180
181
|
if (req.user) {
|
182
|
+
var cart = await ShoppinglistsService.GetCurrentCart(req.user._id);
|
181
183
|
await ShoppinglistsService.CartPaid(req.user._id);
|
184
|
+
cart.products = await ShoppinglistsService.GetProductsDetails(
|
185
|
+
cart.products
|
186
|
+
);
|
187
|
+
console.log("cart" + cart);
|
188
|
+
var totalPrice = cart.products.reduce((acc, item) => acc + item.price * item.quantity,0);
|
189
|
+
console.log(totalPrice);
|
190
|
+
var order = new Orders({userId: req.user._id,
|
191
|
+
products:cart.products,
|
192
|
+
totalPrice: totalPrice,
|
193
|
+
date: Date.now(),
|
194
|
+
status:"Pending"
|
195
|
+
})
|
196
|
+
await order.save();
|
182
197
|
return res.sendStatus(200);
|
183
198
|
}
|
184
199
|
return res.sendStatus(404);
|
@@ -26,26 +26,29 @@ module.exports = class User {
|
|
26
26
|
return res.sendStatus(400);
|
27
27
|
}
|
28
28
|
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
});
|
29
|
+
var cart = req.session.cart;
|
30
|
+
var wishlist = req.session.wishlist;
|
31
|
+
req.logIn(user, function(err) {
|
32
|
+
if (err) return next(err);
|
33
|
+
|
34
|
+
console.log('is authenticated?: ' + req.isAuthenticated());
|
35
|
+
console.log(req.session);
|
36
|
+
if(cart && cart.products != []){
|
37
|
+
ShoppinglistsService.AddProductsFromSession(req.user._id, cart.products)
|
38
|
+
}
|
39
|
+
if(wishlist && wishlist.products != []){
|
40
|
+
WishlistService.AddProductsFromSession(req.user._id, wishlist.products)
|
41
|
+
}
|
42
|
+
// req.session.cart = {products:[]}
|
43
|
+
// req.session.wishlist = {products:[]}
|
44
|
+
// req.session.save((err) => {
|
45
|
+
// console.log(err);
|
46
|
+
// });
|
48
47
|
return res.sendStatus(200);
|
48
|
+
}
|
49
|
+
);
|
50
|
+
|
51
|
+
|
49
52
|
})(req, res, next);
|
50
53
|
} else {
|
51
54
|
return res.sendStatus(404);
|
@@ -65,8 +68,10 @@ module.exports = class User {
|
|
65
68
|
|
66
69
|
static async logout(req, res, next) {
|
67
70
|
console.log("logout");
|
68
|
-
req.logout()
|
69
|
-
|
71
|
+
req.logout(function(err) {
|
72
|
+
if (err) { return next(err); }
|
73
|
+
return res.sendStatus(200);
|
74
|
+
});
|
70
75
|
}
|
71
76
|
|
72
77
|
static async emailForResetPassword(req, res, next) {
|
@@ -152,6 +157,7 @@ module.exports = class User {
|
|
152
157
|
}
|
153
158
|
const newUser = new Users(user);
|
154
159
|
newUser.setPassword(user.password);
|
160
|
+
newUser.isActivate = true;
|
155
161
|
newUser.isApproved = user.degree != "Customer" ? false: true;
|
156
162
|
await newUser.save();
|
157
163
|
console.log("user added successfullly");
|
@@ -180,7 +186,58 @@ static async getProfileImage(req, res, next){
|
|
180
186
|
return res.json({profileImage:user.profileImage});
|
181
187
|
}
|
182
188
|
|
183
|
-
|
189
|
+
|
190
|
+
|
191
|
+
static async getUsers(req, res, next){
|
192
|
+
var type = req.body.type;
|
193
|
+
console.log(type);
|
194
|
+
var users = [];
|
195
|
+
if(type == "All" || !type){
|
196
|
+
console.log("all");
|
197
|
+
users = await UserService.GetALL();
|
198
|
+
} else{
|
199
|
+
console.log(type);
|
200
|
+
users = await UserService.GetUserBydegree(type);
|
201
|
+
}
|
202
|
+
return res.json({users: users});
|
203
|
+
}
|
204
|
+
static async addNewUser(req, res, next){
|
205
|
+
var user = req.body.user;
|
206
|
+
user.isActivate = true;
|
207
|
+
const newUser = new User(user);
|
208
|
+
await newUser.save();
|
209
|
+
console.log('User created:' + newUser);
|
210
|
+
var id = newUser._id;
|
211
|
+
console.log(id);
|
212
|
+
return res.json({status: 200, id: id});
|
213
|
+
}
|
214
|
+
|
215
|
+
static async updateUser(req, res, next){
|
216
|
+
var oldUser = await UserService.FindById(req.body.user._id);
|
217
|
+
var exists = await UserService.FindByEmail(req.body.user.email)
|
218
|
+
if(exists && exists._id != req.body.user._id){
|
219
|
+
return res.sendStatus(400);
|
220
|
+
}
|
221
|
+
if(oldUser){
|
222
|
+
var newUser = req.body.user;
|
223
|
+
await UserService.UpdateById(req.body.user._id, newUser)
|
224
|
+
console.log('user updated:' + newUser);
|
225
|
+
} else{
|
226
|
+
return res.sendStatus(404);
|
227
|
+
}
|
228
|
+
return res.sendStatus(200);
|
229
|
+
}
|
230
|
+
static async deleteUser(req, res, next){
|
231
|
+
var oldUser = await UserService.FindById(req.body.id);
|
232
|
+
if(oldUser){
|
233
|
+
await UserService.REMOVE(req.body.id)
|
234
|
+
console.log('User deleted:' + req.body.id);
|
235
|
+
} else{
|
236
|
+
return res.sendStatus(404);
|
237
|
+
}
|
238
|
+
return res.sendStatus(200);
|
239
|
+
}
|
240
|
+
static async isLogged(req, res, next){
|
184
241
|
if(req.user)
|
185
242
|
return res.sendStatus(200);
|
186
243
|
return res.sendStatus(404);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
const mongo = require("mongoose");
|
2
|
+
const { Schema } = mongo;
|
3
|
+
|
4
|
+
const OrderSchema = new Schema({
|
5
|
+
userId: String,
|
6
|
+
products: Array,
|
7
|
+
totalPrice: Number,
|
8
|
+
date: Date,
|
9
|
+
status: String,
|
10
|
+
}, { autoIndex: false });
|
11
|
+
|
12
|
+
mongo.model('Orders', OrderSchema, 'Orders'); // if model name as lowercase with suffix "s" === collection name: User => users
|
@@ -3,8 +3,12 @@ const router = express.Router();
|
|
3
3
|
const UserCtrl = require("../Controllers/user.controller");
|
4
4
|
const CatalogCtrl = require("../Controllers/catalog.controller");
|
5
5
|
const ShoppinglistCtrl = require("../Controllers/shoppinglist.controller");
|
6
|
+
|
7
|
+
const OrderCtrl = require("../Controllers/order.controller");
|
8
|
+
|
6
9
|
const WishlistCtrl = require("../Controllers/wishlist.controller");
|
7
10
|
|
11
|
+
|
8
12
|
var bodyParser = require("body-parser");
|
9
13
|
var jsonParser = bodyParser.json();
|
10
14
|
const auth = require('./auth');
|
@@ -18,12 +22,20 @@ router.post("/updatePassword", jsonParser, UserCtrl.updatePassword);
|
|
18
22
|
router.post("/signup", jsonParser, UserCtrl.signup);
|
19
23
|
router.get("/getProfileImage", jsonParser, UserCtrl.getProfileImage);
|
20
24
|
router.post("/addUserProfile", jsonParser, UserCtrl.addUserProfile);
|
25
|
+
router.post("/getUsers", jsonParser, UserCtrl.getUsers);
|
26
|
+
router.post("/addNewUser", jsonParser, UserCtrl.addNewUser);
|
27
|
+
router.post("/updateUser", jsonParser, UserCtrl.updateUser);
|
28
|
+
router.post("/deleteUser", jsonParser, UserCtrl.deleteUser);
|
21
29
|
router.post("/getCatalog", jsonParser, CatalogCtrl.getCatalog);
|
22
30
|
router.post("/addNewProduct", jsonParser, CatalogCtrl.addNewProduct);
|
23
31
|
router.post("/addProductPicture", jsonParser, CatalogCtrl.addProductPicture);
|
24
32
|
router.post("/updateProduct", jsonParser, CatalogCtrl.updateProduct);
|
25
33
|
router.post("/deleteProduct", jsonParser, CatalogCtrl.deleteProduct);
|
26
|
-
|
34
|
+
router.post("/getOrders", jsonParser, OrderCtrl.getOrders);
|
35
|
+
router.post("/getClientOrders", jsonParser, OrderCtrl.getClientOrders);
|
36
|
+
router.post("/addNewOrder", jsonParser, OrderCtrl.addNewOrder);
|
37
|
+
router.post("/updateOrder", jsonParser, OrderCtrl.updateOrder);
|
38
|
+
router.post("/updateOrderStatus", jsonParser, OrderCtrl.updateOrderStatus);
|
27
39
|
router.get("/getCurrentCart", jsonParser, ShoppinglistCtrl.getCurrentCart);
|
28
40
|
router.get("/getCurrentWishlist", jsonParser, WishlistCtrl.getCurrentWishlist);
|
29
41
|
router.get("/isLogged", jsonParser, UserCtrl.isLogged);
|
@@ -37,4 +49,5 @@ router.get("/getSession", jsonParser, UserCtrl.getSession);
|
|
37
49
|
router.get("/payNow",jsonParser, ShoppinglistCtrl.payNow)
|
38
50
|
|
39
51
|
|
52
|
+
|
40
53
|
module.exports = router;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require("../Models/orders");
|
2
|
+
var mongoose = require("mongoose");
|
3
|
+
const Order = mongoose.model('Orders');
|
4
|
+
|
5
|
+
module.exports = class OrderService {
|
6
|
+
static async CREATE(order) {
|
7
|
+
return Order.create({
|
8
|
+
userId: order.userId,
|
9
|
+
products: order.products,
|
10
|
+
totalPrice: order.totalPrice,
|
11
|
+
date:order.date,
|
12
|
+
status: order.status,
|
13
|
+
});
|
14
|
+
}
|
15
|
+
|
16
|
+
static async GetALL() {
|
17
|
+
return Order.find({ }).exec();
|
18
|
+
}
|
19
|
+
static async GetOrderByStatus(s) {
|
20
|
+
return Order.find({ status: s }).exec();
|
21
|
+
}
|
22
|
+
static async GetClientOrders(id) {
|
23
|
+
return Order.find({ userId: id }).exec();
|
24
|
+
}
|
25
|
+
|
26
|
+
static async FindById(id) {
|
27
|
+
console.log("finding order:" + id);
|
28
|
+
return Order.findOne({ _id: id });
|
29
|
+
}
|
30
|
+
|
31
|
+
static async UpdateStatus(id, s) {
|
32
|
+
return Order.updateOne(
|
33
|
+
{ _id: id },
|
34
|
+
{ $set: { status: s } }
|
35
|
+
).exec();
|
36
|
+
}
|
37
|
+
|
38
|
+
static async UpdateById(id, order) {
|
39
|
+
return Order.updateOne(
|
40
|
+
{ _id: id },
|
41
|
+
{ $set: { userId: order.userId, products: order.products, totalPrice: order.totalPrice, status: order.status, date : order.date} }
|
42
|
+
).exec();
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
};
|
@@ -33,7 +33,7 @@ module.exports = class ProductService {
|
|
33
33
|
console.log("got order product")
|
34
34
|
var product = await Products.findById(orderProduct.productId)
|
35
35
|
console.log("got product")
|
36
|
-
var result = {id: product._id, name:product.name, price: product.price, quantity: orderProduct.quantity, image: product.image}
|
36
|
+
var result = {id: product._id, name:product.name, price: product.price, quantity: orderProduct.quantity, image: product.image, sellerId:product.sellerId}
|
37
37
|
return result;
|
38
38
|
}
|
39
39
|
|
@@ -77,7 +77,7 @@ module.exports = class ProductService {
|
|
77
77
|
if(orderProduct){
|
78
78
|
console.log("update quantity")
|
79
79
|
await OrderProducts.updateOne(
|
80
|
-
{
|
80
|
+
{ _id:orderProduct._id },
|
81
81
|
{ $set: { quantity: orderProduct.quantity + product.quantity } }
|
82
82
|
);
|
83
83
|
return;
|
@@ -20,8 +20,8 @@ module.exports = class UserService {
|
|
20
20
|
static async GetALL() {
|
21
21
|
return User.find({ isApproved:true, isActivate: true }).exec();
|
22
22
|
}
|
23
|
-
static async
|
24
|
-
return User.find({ isActivate: true, degree:
|
23
|
+
static async GetUserBydegree(deg) {
|
24
|
+
return User.find({isApproved:true ,isActivate: true, degree: deg }).exec();
|
25
25
|
}
|
26
26
|
static async FindById(id) {
|
27
27
|
console.log("finding user:" + id);
|
@@ -36,9 +36,15 @@ module.exports = class UserService {
|
|
36
36
|
return await User.findOne({ email: e, password: p, isApproved: true, isActivate:true});
|
37
37
|
}
|
38
38
|
|
39
|
-
static async REMOVE(e, p) {
|
39
|
+
//static async REMOVE(e, p) {
|
40
|
+
//return User.updateOne(
|
41
|
+
//{ email: e, password: p },
|
42
|
+
//{ $set: { isActivate: false } }
|
43
|
+
//).exec();
|
44
|
+
//}
|
45
|
+
static async REMOVE(id) {
|
40
46
|
return User.updateOne(
|
41
|
-
{
|
47
|
+
{ _id: id },
|
42
48
|
{ $set: { isActivate: false } }
|
43
49
|
).exec();
|
44
50
|
}
|
@@ -53,7 +59,7 @@ module.exports = class UserService {
|
|
53
59
|
static async UpdateById(id, user) {
|
54
60
|
return User.updateOne(
|
55
61
|
{ _id: id },
|
56
|
-
{ $set: { email: user.email,
|
62
|
+
{ $set: { email: user.email, degree: user.degree, profileImage: user.profileImage,phone:user.phone, name:user.name} }
|
57
63
|
).exec();
|
58
64
|
}
|
59
65
|
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import {React, Component} from 'react';
|
2
|
+
import sampleImage from '../logo.svg';
|
3
|
+
import '../css/shoppingCart.css';
|
4
|
+
import { FaHeart, FaRegHeart, FaShoppingCart, FaEye } from "react-icons/fa";
|
5
|
+
import Order from "./Order.js"
|
6
|
+
import swal from "sweetalert";
|
7
|
+
import { Container, Table, Row, Button } from "react-bootstrap";
|
8
|
+
|
9
|
+
class ManageOrders extends Component {
|
10
|
+
constructor(props) {
|
11
|
+
super(props);
|
12
|
+
this.state = {
|
13
|
+
orders: [],
|
14
|
+
status: false,
|
15
|
+
};
|
16
|
+
}
|
17
|
+
componentDidMount = async () => {
|
18
|
+
var status = this.state.status ? this.state.status : "All";
|
19
|
+
var options = {
|
20
|
+
method: "POST",
|
21
|
+
headers: { "Content-Type": "application/json" },
|
22
|
+
body:JSON.stringify({status: status})
|
23
|
+
};
|
24
|
+
console.log(status);
|
25
|
+
await fetch("/getOrders", options).then(res => res.json())
|
26
|
+
.then((result) => {
|
27
|
+
console.log(result);
|
28
|
+
this.setState({ orders: result.orders });
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
componentDidUpdate = async(prevProps,prevState) => {
|
33
|
+
if (this.state.status !== prevState.status) {
|
34
|
+
console.log('type changed');
|
35
|
+
var status = this.state.status ? this.state.status : "All";
|
36
|
+
var options = {
|
37
|
+
method: "POST",
|
38
|
+
headers: { "Content-Type": "application/json" },
|
39
|
+
body:JSON.stringify({status: status})
|
40
|
+
};
|
41
|
+
console.log(status);
|
42
|
+
await fetch("/getOrders", options).then(res => res.json())
|
43
|
+
.then((result) => {
|
44
|
+
console.log("hi");
|
45
|
+
this.setState({ orders: result.orders });
|
46
|
+
console.log(this.state.orders);
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}
|
50
|
+
refreshPage() {
|
51
|
+
window.location.reload(false);
|
52
|
+
}
|
53
|
+
|
54
|
+
async changeType(e){
|
55
|
+
var status = e.target.value;
|
56
|
+
this.setState({status:status});
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
render() {
|
62
|
+
return (
|
63
|
+
<div className="productSlider mb-5 mt-5">
|
64
|
+
<Container>
|
65
|
+
<h5 className="text-left mb-4 ps-2">Order List</h5>
|
66
|
+
<div style={{"marginTop":"inherit"}} class="btn-group" role="group" aria-label="Basic example">
|
67
|
+
<button type="button" onClick={(e) => this.changeType(e)} value="Pending" className="button-17">Pending</button>
|
68
|
+
<button type="button" onClick={(e) => this.changeType(e)} value="InProcess" className="button-17">In process</button>
|
69
|
+
<button type="button" onClick={(e) => this.changeType(e)} value="Completed" className="button-17">Completed</button>
|
70
|
+
<button type="button" onClick={(e) => this.changeType(e)} value="All" className="button-17">All</button>
|
71
|
+
<button type="button" onClick={() => this.refreshPage()} style={{"width":"10%","height":"5%",margin:"20px"}}>
|
72
|
+
<span><img src="images/refresh.png" style={{"height":"auto",width:"20%"}}/></span> Refresh
|
73
|
+
</button>
|
74
|
+
</div>
|
75
|
+
<Row>
|
76
|
+
<div className="col-9 cartShow">
|
77
|
+
<Table bordered hover responsive="sm">
|
78
|
+
<thead>
|
79
|
+
<tr>
|
80
|
+
<th>Order </th>
|
81
|
+
<th>Date </th>
|
82
|
+
<th>Products </th>
|
83
|
+
<th>Sub Total</th>
|
84
|
+
<th>Status</th>
|
85
|
+
</tr>
|
86
|
+
</thead>
|
87
|
+
<tbody>
|
88
|
+
{this.state.orders.map((order, idx) => (
|
89
|
+
<Order
|
90
|
+
key={order._id}
|
91
|
+
_id = {order._id}
|
92
|
+
userId = {order.userId}
|
93
|
+
products = {order.products}
|
94
|
+
totalPrice = {order.totalPrice}
|
95
|
+
date = {order.date}
|
96
|
+
status = {order.status}
|
97
|
+
/>
|
98
|
+
))}
|
99
|
+
</tbody>
|
100
|
+
</Table>
|
101
|
+
</div>
|
102
|
+
</Row>
|
103
|
+
</Container>
|
104
|
+
</div>
|
105
|
+
);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
export default ManageOrders;
|