la-flowerita 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +70 -0
- package/package.json +78 -0
- package/public/favicon.ico +0 -0
- package/public/images/1.jpg +0 -0
- package/public/images/2.jpg +0 -0
- package/public/images/3.jpg +0 -0
- package/public/images/Logo.png +0 -0
- package/public/images/add-user.png +0 -0
- package/public/images/contact-us.png +0 -0
- package/public/images/flower.png +0 -0
- package/public/images/flower_shop.png +0 -0
- package/public/images/flower_shop1.png +0 -0
- package/public/images/flowers/buttercup.png +0 -0
- package/public/images/flowers/daffodil.png +0 -0
- package/public/images/flowers/daisy.png +0 -0
- package/public/images/flowers/jasmine.png +0 -0
- package/public/images/flowers/lily.png +0 -0
- package/public/images/flowers/marigold.png +0 -0
- package/public/images/flowers/orchid.png +0 -0
- package/public/images/flowers/rose.png +0 -0
- package/public/images/flowers/sunflower.png +0 -0
- package/public/images/flowers/tulip.png +0 -0
- package/public/images/garbage.png +0 -0
- package/public/images/icon1.jpg +0 -0
- package/public/images/login.png +0 -0
- package/public/images/refresh.png +0 -0
- package/public/images/transaction.png +0 -0
- package/public/index.html +41 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +26 -0
- package/public/offline.html +44 -0
- package/public/robots.txt +3 -0
- package/public/serviceworker.js +44 -0
- package/server.js +97 -0
- package/src/App.css +38 -0
- package/src/App.js +25 -0
- package/src/App.test.js +8 -0
- package/src/Config/db.js +5 -0
- package/src/Config/mail.js +7 -0
- package/src/Config/passport.js +34 -0
- package/src/Controllers/catalog.controller.js +78 -0
- package/src/Controllers/shoppinglist.controller.js +186 -0
- package/src/Controllers/user.controller.js +214 -0
- package/src/Controllers/wishlist.controller.js +150 -0
- package/src/Middleware/sendMail.js +29 -0
- package/src/Middleware/uploadImage.js +26 -0
- package/src/Models/orderProducts.js +10 -0
- package/src/Models/products.js +17 -0
- package/src/Models/shoppinglists.js +12 -0
- package/src/Models/userShoppinglists.js +9 -0
- package/src/Models/users.js +57 -0
- package/src/Models/wishlists.js +9 -0
- package/src/Routes/auth.js +21 -0
- package/src/Routes/indexRouter.js +40 -0
- package/src/Services/ProductService.js +76 -0
- package/src/Services/ShoppinglistService.js +135 -0
- package/src/Services/UserService.js +63 -0
- package/src/Services/WishlistService.js +105 -0
- package/src/components/About.js +45 -0
- package/src/components/Auth.js +15 -0
- package/src/components/Catalog.js +118 -0
- package/src/components/Chat.js +77 -0
- package/src/components/Contact.js +48 -0
- package/src/components/Dashboard.js +13 -0
- package/src/components/DetailsProductModal.js +362 -0
- package/src/components/LoginModal.js +173 -0
- package/src/components/NewProductModal.js +271 -0
- package/src/components/NoPermission.js +10 -0
- package/src/components/OrderedProduct.js +104 -0
- package/src/components/PreChat.js +51 -0
- package/src/components/Product.js +158 -0
- package/src/components/ResetPassword.js +211 -0
- package/src/components/ShoppingCart.js +198 -0
- package/src/components/SideNav.js +76 -0
- package/src/components/SignupModal.js +306 -0
- package/src/components/Spinner.js +22 -0
- package/src/components/Wishlist.js +195 -0
- package/src/components/social-config.js +17 -0
- package/src/css/about.css +12 -0
- package/src/css/catalog.css +218 -0
- package/src/css/chat.css +191 -0
- package/src/css/contact.css +404 -0
- package/src/css/index.css +129 -0
- package/src/css/newProductModal.css +69 -0
- package/src/css/noPermission.css +89 -0
- package/src/css/orderedProduct.css +0 -0
- package/src/css/resetPassword.css +44 -0
- package/src/css/shoppingCart.css +10 -0
- package/src/css/sideNav.css +68 -0
- package/src/css/spinner.css +23 -0
- package/src/images/1.jpg +0 -0
- package/src/images/2.jpg +0 -0
- package/src/images/3.jpg +0 -0
- package/src/images/Logo.png +0 -0
- package/src/images/add-user.png +0 -0
- package/src/images/buttercup.png +0 -0
- package/src/images/contact-us.png +0 -0
- package/src/images/daffodil.png +0 -0
- package/src/images/daisy.png +0 -0
- package/src/images/flower.png +0 -0
- package/src/images/flower_shop.png +0 -0
- package/src/images/flower_shop1.png +0 -0
- package/src/images/flowers/buttercup.png +0 -0
- package/src/images/flowers/daffodil.png +0 -0
- package/src/images/flowers/daisy.png +0 -0
- package/src/images/flowers/jasmine.png +0 -0
- package/src/images/flowers/lily.png +0 -0
- package/src/images/flowers/marigold.png +0 -0
- package/src/images/flowers/orchid.png +0 -0
- package/src/images/flowers/rose.png +0 -0
- package/src/images/flowers/sunflower.png +0 -0
- package/src/images/flowers/tulip.png +0 -0
- package/src/images/garbage.png +0 -0
- package/src/images/icon1.jpg +0 -0
- package/src/images/jasmine.png +0 -0
- package/src/images/lily.png +0 -0
- package/src/images/login.png +0 -0
- package/src/images/marigold.png +0 -0
- package/src/images/orchid.png +0 -0
- package/src/images/refresh.png +0 -0
- package/src/images/rose.png +0 -0
- package/src/images/sunflower.png +0 -0
- package/src/images/transaction.png +0 -0
- package/src/images/tulip.png +0 -0
- package/src/index.js +371 -0
- package/src/logo.svg +1 -0
- package/src/reportWebVitals.js +13 -0
- package/src/setupTests.js +5 -0
@@ -0,0 +1,306 @@
|
|
1
|
+
import React, { Component } from "react";
|
2
|
+
import Button from "react-bootstrap/Button";
|
3
|
+
import Modal from "react-bootstrap/Modal";
|
4
|
+
import { NavLink } from "react-router-dom";
|
5
|
+
import '../css/newProductModal.css';
|
6
|
+
import swal from 'sweetalert';
|
7
|
+
import {FaPenSquare} from "react-icons/fa"
|
8
|
+
import LoadingIndicator from "./Spinner";
|
9
|
+
import { usePromiseTracker, trackPromise } from "react-promise-tracker";
|
10
|
+
class SignupModal extends Component {
|
11
|
+
constructor() {
|
12
|
+
super();
|
13
|
+
this.state = {
|
14
|
+
showModal: false,
|
15
|
+
user: {
|
16
|
+
email: "",
|
17
|
+
password: "",
|
18
|
+
degree: "",
|
19
|
+
name: "",
|
20
|
+
phone: "",
|
21
|
+
address: "",
|
22
|
+
picture: false,
|
23
|
+
src: false,
|
24
|
+
},
|
25
|
+
ERROR: "",
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
handleClose = () => {
|
30
|
+
this.setState({ showModal: false });
|
31
|
+
};
|
32
|
+
handleShow = () => {
|
33
|
+
this.setState({ showModal: true });
|
34
|
+
};
|
35
|
+
async signup() {
|
36
|
+
// check inputs
|
37
|
+
var email = this.state.email;
|
38
|
+
var password = this.state.password;
|
39
|
+
var degree = this.state.degree;
|
40
|
+
var name = this.state.name;
|
41
|
+
var phone = this.state.phone;
|
42
|
+
var address = this.state.address;
|
43
|
+
var re_pass = document.getElementById("re_pass").value;
|
44
|
+
if (email == "" || password == "" || degree== undefined || name == "" || phone == "" || address == "") {
|
45
|
+
this.setState({ ERROR: "Please fill all the fields" });
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
if (!email.includes("@")) {
|
49
|
+
this.setState({ ERROR: "Email is not valid." });
|
50
|
+
return;
|
51
|
+
}
|
52
|
+
if(re_pass != password){
|
53
|
+
this.setState({ ERROR: "Passwords don't match each other" });
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
// pass inputs to server
|
57
|
+
let user = { email, password, degree, name, phone, address };
|
58
|
+
var options = {
|
59
|
+
method: "POST",
|
60
|
+
headers: { "Content-Type": "application/json" },
|
61
|
+
body: JSON.stringify({user: user}),
|
62
|
+
};
|
63
|
+
var id = 0;
|
64
|
+
trackPromise(
|
65
|
+
fetch("/signup", options).then(res => res.json())
|
66
|
+
.then(
|
67
|
+
(res) => {
|
68
|
+
console.log(res);
|
69
|
+
if (res.status == 200) {
|
70
|
+
id = res.id;
|
71
|
+
if (id != 0) {
|
72
|
+
var message = degree == "Customer" ? "You may login to your account": "To finish the process of signing up you will need to wait for the manager's approval \n You will get an answer to your email.";
|
73
|
+
if (!this.state.picture) {
|
74
|
+
swal("You signedup successfully!", message, "success");
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
if (
|
78
|
+
this.state.picture.type.includes("png") ||
|
79
|
+
this.state.picture.type.includes("jpg")
|
80
|
+
) {
|
81
|
+
this.setState({ ERROR: "Only types: PNG or JPG" });
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
var myFormData = new FormData();
|
85
|
+
myFormData.append("file", this.state.picture);
|
86
|
+
myFormData.append("id", id);
|
87
|
+
|
88
|
+
fetch("/addUserProfile", {
|
89
|
+
method: "POST",
|
90
|
+
body: myFormData,
|
91
|
+
}).then(response =>{
|
92
|
+
if (response.status == 200) {
|
93
|
+
swal("You signedup successfully!", message, "success");
|
94
|
+
// document.location.href = "/";
|
95
|
+
}
|
96
|
+
else {
|
97
|
+
swal("Error","Didn't get id","error");
|
98
|
+
}})
|
99
|
+
}
|
100
|
+
}
|
101
|
+
else if(res.status == 409){
|
102
|
+
this.setState({ ERROR: "Email already exists." });
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
else if(res.status == 400){
|
106
|
+
this.setState({ ERROR: "There was an error. Please try again" });
|
107
|
+
return;
|
108
|
+
}
|
109
|
+
else if(res.status == 422){
|
110
|
+
this.setState({ ERROR: "Please fill all the fields correctly." });
|
111
|
+
return;
|
112
|
+
} else if(res.status == 500){
|
113
|
+
this.setState({ ERROR: "There was an error. Please try again" });
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
},
|
117
|
+
// Note: it's important to handle errors here
|
118
|
+
// instead of a catch() block so that we don't swallow
|
119
|
+
// exceptions from actual bugs in components.
|
120
|
+
(error) => {
|
121
|
+
this.setState({
|
122
|
+
ERROR: error
|
123
|
+
});
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
))
|
127
|
+
|
128
|
+
}
|
129
|
+
|
130
|
+
renderPreview() {
|
131
|
+
if(this.state.src) {
|
132
|
+
return (
|
133
|
+
<img src={this.state.src} style={{"max-width": "inherit", "max-height": "inherit"}}/>
|
134
|
+
);
|
135
|
+
} else {
|
136
|
+
return (
|
137
|
+
<p>
|
138
|
+
No Preview
|
139
|
+
</p>
|
140
|
+
);
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
handlePictureSelected(event) {
|
145
|
+
var picture = event.target.files[0];
|
146
|
+
var src = URL.createObjectURL(picture);
|
147
|
+
|
148
|
+
this.setState({
|
149
|
+
picture: picture,
|
150
|
+
src: src
|
151
|
+
});
|
152
|
+
}
|
153
|
+
inputsHandler = (e) => {
|
154
|
+
this.setState({ [e.target.name]: e.target.value });
|
155
|
+
};
|
156
|
+
radioHandler = (e) => {
|
157
|
+
this.setState({ [e.target.name]: document.querySelector(`input[name=${e.target.name}]:checked`).id});
|
158
|
+
};
|
159
|
+
render() {
|
160
|
+
return (
|
161
|
+
<div>
|
162
|
+
<Button
|
163
|
+
title="Sign Up"
|
164
|
+
class="btn btn-primary btn-lg btn-floating"
|
165
|
+
style={{display: this.props.showButton,"background-color": "#17c0eb"}}
|
166
|
+
onClick={() => this.handleShow()}
|
167
|
+
>
|
168
|
+
{this.props.menuCollapse ? "" :"SignUp"}<FaPenSquare/>
|
169
|
+
</Button>
|
170
|
+
<Modal
|
171
|
+
style={{ opacity: 1 }}
|
172
|
+
show={this.state.showModal}
|
173
|
+
onHide={() => this.handleClose()}
|
174
|
+
>
|
175
|
+
<Modal.Header>
|
176
|
+
<Modal.Title>
|
177
|
+
<div className="modal-header">
|
178
|
+
{/* <img src="images\login.png"/> */}
|
179
|
+
<h5 className="modal-title" id="exampleModalLabel">
|
180
|
+
Sign up
|
181
|
+
</h5>
|
182
|
+
</div>
|
183
|
+
</Modal.Title>
|
184
|
+
</Modal.Header>
|
185
|
+
<Modal.Body>
|
186
|
+
<LoadingIndicator/>
|
187
|
+
<form>
|
188
|
+
<div className="mb-3">
|
189
|
+
<input
|
190
|
+
type="text"
|
191
|
+
name="name"
|
192
|
+
id="name"
|
193
|
+
className="form-control"
|
194
|
+
placeholder="Full name"
|
195
|
+
onChange={this.inputsHandler}
|
196
|
+
required
|
197
|
+
autoFocus
|
198
|
+
/>
|
199
|
+
</div>
|
200
|
+
<div className="mb-3">
|
201
|
+
<input
|
202
|
+
type="text"
|
203
|
+
name="phone"
|
204
|
+
id="phone"
|
205
|
+
className="form-control"
|
206
|
+
placeholder="Phone"
|
207
|
+
onChange={this.inputsHandler}
|
208
|
+
required
|
209
|
+
/>
|
210
|
+
</div>
|
211
|
+
<div className="mb-3">
|
212
|
+
<input
|
213
|
+
type="text"
|
214
|
+
name="address"
|
215
|
+
id="address"
|
216
|
+
className="form-control"
|
217
|
+
placeholder="Address"
|
218
|
+
onChange={this.inputsHandler}
|
219
|
+
required
|
220
|
+
/>
|
221
|
+
</div>
|
222
|
+
<div className="mb-3">
|
223
|
+
<input type="radio" name="degree" id="Customer" onChange={this.radioHandler}/>
|
224
|
+
<label for="rd1">Customer</label>
|
225
|
+
<input type="radio" name="degree" id="Seller" onChange={this.radioHandler}/>
|
226
|
+
<label for="rd2">Seller</label>
|
227
|
+
<input type="radio" name="degree" id="Manager" onChange={this.radioHandler}/>
|
228
|
+
<label for="rd2">Manager</label>
|
229
|
+
</div>
|
230
|
+
<div className="mb-3">
|
231
|
+
{/* <span><i aria-hidden="true" class="fa fa-envelope"></i></span> */}
|
232
|
+
<input
|
233
|
+
type="email"
|
234
|
+
name="email"
|
235
|
+
id="email"
|
236
|
+
className="form-control"
|
237
|
+
placeholder="Email address"
|
238
|
+
onChange={this.inputsHandler}
|
239
|
+
required
|
240
|
+
autoFocus
|
241
|
+
/>
|
242
|
+
</div>
|
243
|
+
<div className="mb-3">
|
244
|
+
<input
|
245
|
+
type="password"
|
246
|
+
name="password"
|
247
|
+
id="password"
|
248
|
+
className="form-control"
|
249
|
+
placeholder="Password"
|
250
|
+
onChange={this.inputsHandler}
|
251
|
+
required
|
252
|
+
/>
|
253
|
+
</div>
|
254
|
+
<div className="mb-3">
|
255
|
+
<input
|
256
|
+
type="password"
|
257
|
+
name="re_pass"
|
258
|
+
id="re_pass"
|
259
|
+
className="form-control"
|
260
|
+
placeholder="Confirm Password"
|
261
|
+
onChange={this.inputsHandler}
|
262
|
+
required
|
263
|
+
/>
|
264
|
+
</div>
|
265
|
+
<div className="mb-3">
|
266
|
+
<h2>Upload Profile Image</h2>
|
267
|
+
<input
|
268
|
+
name="file"
|
269
|
+
id="file"
|
270
|
+
type="file"
|
271
|
+
onChange={this.handlePictureSelected.bind(this)}
|
272
|
+
/>
|
273
|
+
<br/>
|
274
|
+
<div style={{"max-width": "80%", "max-height": "80%"}}>
|
275
|
+
{this.renderPreview()}
|
276
|
+
</div>
|
277
|
+
<hr/>
|
278
|
+
</div>
|
279
|
+
</form>
|
280
|
+
</Modal.Body>
|
281
|
+
<Modal.Footer>
|
282
|
+
<h5>{this.state.ERROR}</h5>
|
283
|
+
<div className="modal-footer">
|
284
|
+
<button
|
285
|
+
className="btn btn-lg btn-primary btn-block"
|
286
|
+
onClick={() => this.signup()}
|
287
|
+
type="submit"
|
288
|
+
>
|
289
|
+
Sign up
|
290
|
+
</button>
|
291
|
+
<NavLink
|
292
|
+
style={{cursor:"pointer"}}
|
293
|
+
onClick={() => this.handleClose()}
|
294
|
+
to="/resetPassword"
|
295
|
+
>
|
296
|
+
forgot pasword ? click here
|
297
|
+
</NavLink>
|
298
|
+
</div>
|
299
|
+
</Modal.Footer>
|
300
|
+
</Modal>
|
301
|
+
</div>
|
302
|
+
);
|
303
|
+
}
|
304
|
+
}
|
305
|
+
|
306
|
+
export default SignupModal;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React, { Component } from 'react';
|
2
|
+
import { render } from 'react-dom';
|
3
|
+
import {ThreeDots} from 'react-loader-spinner'
|
4
|
+
import { usePromiseTracker, trackPromise } from "react-promise-tracker";
|
5
|
+
const LoadingIndicator = props => {
|
6
|
+
const { promiseInProgress } = usePromiseTracker();
|
7
|
+
|
8
|
+
return promiseInProgress &&
|
9
|
+
<div
|
10
|
+
style={{
|
11
|
+
width: "100%",
|
12
|
+
height: "100",
|
13
|
+
display: "flex",
|
14
|
+
justifyContent: "center",
|
15
|
+
alignItems: "center"
|
16
|
+
}}
|
17
|
+
>
|
18
|
+
<ThreeDots type="ThreeDots" color="#2BAD60" height="100" width="100" />
|
19
|
+
</div>
|
20
|
+
};
|
21
|
+
|
22
|
+
export default LoadingIndicator;
|
@@ -0,0 +1,195 @@
|
|
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 OrderedProduct from "./OrderedProduct.js";
|
6
|
+
import swal from "sweetalert";
|
7
|
+
import { Container, Table, Row, Button } from "react-bootstrap";
|
8
|
+
import LoadingIndicator from "./Spinner";
|
9
|
+
import { usePromiseTracker, trackPromise } from "react-promise-tracker";
|
10
|
+
|
11
|
+
class Wishlist extends Component {
|
12
|
+
constructor(props) {
|
13
|
+
super(props);
|
14
|
+
this.state = {
|
15
|
+
id: -1,
|
16
|
+
totalPrice: 0,
|
17
|
+
products: [],
|
18
|
+
deleted: [],
|
19
|
+
loggedIn: false,
|
20
|
+
onUpdateWishlist: props.onUpdateWishlist,
|
21
|
+
onUpdateCart: props.onUpdateCart
|
22
|
+
};
|
23
|
+
}
|
24
|
+
componentDidMount = async () => {
|
25
|
+
var options = {
|
26
|
+
method: "GET",
|
27
|
+
headers: { "Content-Type": "application/json" },
|
28
|
+
};
|
29
|
+
trackPromise(
|
30
|
+
fetch("/getCurrentWishlist", options)
|
31
|
+
.then((res) => res.json())
|
32
|
+
.then(
|
33
|
+
(result) => {
|
34
|
+
console.log(result);
|
35
|
+
if (result.status == 200) {
|
36
|
+
this.setState({
|
37
|
+
id: result.wishlist._id,
|
38
|
+
products: result.wishlist.products,
|
39
|
+
totalPrice: result.wishlist.products.reduce(
|
40
|
+
(acc, item) => acc + item.price * item.quantity,
|
41
|
+
0
|
42
|
+
),
|
43
|
+
});
|
44
|
+
}
|
45
|
+
},
|
46
|
+
(error) => {
|
47
|
+
console.log(error);
|
48
|
+
}
|
49
|
+
));
|
50
|
+
};
|
51
|
+
componentDidUpdate(prevProps, prevState) {
|
52
|
+
if (this.state.products.length != prevState.products.length) {
|
53
|
+
this.state.onUpdateWishlist(this.state.products.length);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
async intoWishList() {}
|
58
|
+
async deleteFromWishlist(id) {
|
59
|
+
swal({
|
60
|
+
title: "Are you sure?",
|
61
|
+
text: "Do you want to delete this product from wishlist?",
|
62
|
+
icon: "warning",
|
63
|
+
buttons: true,
|
64
|
+
dangerMode: true,
|
65
|
+
}).then((willDelete) => {
|
66
|
+
if (willDelete) {
|
67
|
+
var options = {
|
68
|
+
method: "POST",
|
69
|
+
headers: { "Content-Type": "application/json" },
|
70
|
+
body: JSON.stringify({ productId: id }),
|
71
|
+
};
|
72
|
+
trackPromise(
|
73
|
+
fetch("/deleteProductFromWishlist", options)
|
74
|
+
.then((res) => res.json())
|
75
|
+
.then(
|
76
|
+
(result) => {
|
77
|
+
console.log(result);
|
78
|
+
if (result.status == 200) {
|
79
|
+
this.setState({
|
80
|
+
products: result.wishlist.products,
|
81
|
+
totalPrice: result.wishlist.products.reduce(
|
82
|
+
(acc, item) => acc + item.price * item.quantity,
|
83
|
+
0
|
84
|
+
),
|
85
|
+
});
|
86
|
+
swal("Success","Product Deleted Successfully From Wish List", "success")
|
87
|
+
}
|
88
|
+
},
|
89
|
+
(error) => {
|
90
|
+
console.log(error);
|
91
|
+
}
|
92
|
+
));
|
93
|
+
}
|
94
|
+
});
|
95
|
+
}
|
96
|
+
|
97
|
+
async updateQuantity(e, id) {
|
98
|
+
var quantity = Number(e.target.value);
|
99
|
+
var product = this.state.products.filter((p) => p.id == id);
|
100
|
+
product = product[0];
|
101
|
+
product.quantity = quantity;
|
102
|
+
var products = this.state.products;
|
103
|
+
products.map((p) => {
|
104
|
+
if (p.id == id) p = product;
|
105
|
+
});
|
106
|
+
var options = {
|
107
|
+
method: "POST",
|
108
|
+
headers: { "Content-Type": "application/json" },
|
109
|
+
body: JSON.stringify({
|
110
|
+
product: {
|
111
|
+
productId: product.id,
|
112
|
+
price: product.price,
|
113
|
+
quantity: product.quantity,
|
114
|
+
},
|
115
|
+
}),
|
116
|
+
};
|
117
|
+
await fetch("/updateProductInWishlist", options)
|
118
|
+
.then((res) => res.json())
|
119
|
+
.then(
|
120
|
+
(result) => {
|
121
|
+
console.log(result);
|
122
|
+
if (result.status == 200) {
|
123
|
+
this.setState({
|
124
|
+
products: result.wishlist.products,
|
125
|
+
totalPrice: result.wishlist.products.reduce(
|
126
|
+
(acc, item) => acc + item.price * item.quantity,
|
127
|
+
0
|
128
|
+
),
|
129
|
+
});
|
130
|
+
}
|
131
|
+
},
|
132
|
+
(error) => {
|
133
|
+
console.log(error);
|
134
|
+
}
|
135
|
+
);
|
136
|
+
}
|
137
|
+
|
138
|
+
async addToCart(id) {
|
139
|
+
var options = {
|
140
|
+
method: "POST",
|
141
|
+
headers: { "Content-Type": "application/json" },
|
142
|
+
body: JSON.stringify({ productId: id }),
|
143
|
+
};
|
144
|
+
fetch("/addNewProductToCart", options).then(res => res.json()).then(
|
145
|
+
(result) => {
|
146
|
+
if (result.status == 200) {
|
147
|
+
this.state.onUpdateCart(result.cart.products.length);
|
148
|
+
swal("Success","Product Added Successfully To Cart", "success")
|
149
|
+
}
|
150
|
+
},
|
151
|
+
(error) => {
|
152
|
+
console.log(error);
|
153
|
+
}
|
154
|
+
);
|
155
|
+
}
|
156
|
+
render() {
|
157
|
+
return (
|
158
|
+
<div className="productSlider mb-5 mt-5">
|
159
|
+
<Container>
|
160
|
+
<h5 className="text-left mb-4 ps-2">Wish List</h5>
|
161
|
+
<Row>
|
162
|
+
<div className="col-9 wishlistShow">
|
163
|
+
<Table bordered hover responsive="sm">
|
164
|
+
<thead>
|
165
|
+
<tr>
|
166
|
+
<th>Product Img</th>
|
167
|
+
<th>Name</th>
|
168
|
+
<th>Price</th>
|
169
|
+
<th>Add To Cart</th>
|
170
|
+
<th>Delete</th>
|
171
|
+
</tr>
|
172
|
+
</thead>
|
173
|
+
<tbody>
|
174
|
+
<LoadingIndicator />
|
175
|
+
{this.state.products.map((product, idx) => (
|
176
|
+
<OrderedProduct
|
177
|
+
key={product.id}
|
178
|
+
isCart={false}
|
179
|
+
product={product}
|
180
|
+
onDelete={(id) => this.deleteFromWishlist(id)}
|
181
|
+
onUpdate={(e, id) => this.updateQuantity(e, id)}
|
182
|
+
onAdd={(e, id) => this.addToCart(e, id)}
|
183
|
+
/>
|
184
|
+
))}
|
185
|
+
</tbody>
|
186
|
+
</Table>
|
187
|
+
</div>
|
188
|
+
</Row>
|
189
|
+
</Container>
|
190
|
+
</div>
|
191
|
+
);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
export default Wishlist;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
const facebook = {
|
2
|
+
appId: "YOUR FB APP ID GOES HERE",
|
3
|
+
cookie: true,
|
4
|
+
xfbml: true,
|
5
|
+
version: "v12.0",
|
6
|
+
scope: "email",
|
7
|
+
return_scopes: false
|
8
|
+
};
|
9
|
+
|
10
|
+
export const facebookConfig = facebook;
|
11
|
+
|
12
|
+
const google = {
|
13
|
+
client_id: "YOUR_CLIENT_ID.apps.googleusercontent.com",
|
14
|
+
scope: "profile email"
|
15
|
+
};
|
16
|
+
|
17
|
+
export const googleConfig = google;
|