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,118 @@
|
|
1
|
+
//components/ProductList.js
|
2
|
+
|
3
|
+
import React, { Component } from "react";
|
4
|
+
import Product from "./Product";
|
5
|
+
import NewProductModal from "./NewProductModal";
|
6
|
+
import "../css/catalog.css";
|
7
|
+
import { FaPlus } from "react-icons/fa";
|
8
|
+
import { FiRefreshCcw } from "react-icons/fi";
|
9
|
+
import LoadingIndicator from "./Spinner";
|
10
|
+
import { usePromiseTracker, trackPromise } from "react-promise-tracker";
|
11
|
+
class ProductList extends Component {
|
12
|
+
constructor(props) {
|
13
|
+
super(props);
|
14
|
+
|
15
|
+
this.state = {
|
16
|
+
products: false,
|
17
|
+
type: false,
|
18
|
+
wishlist: [],
|
19
|
+
showModal:false
|
20
|
+
};
|
21
|
+
}
|
22
|
+
|
23
|
+
componentDidMount(){
|
24
|
+
var type = this.state.type ? this.state.type : "All";
|
25
|
+
var options = {
|
26
|
+
method: "POST",
|
27
|
+
headers: { "Content-Type": "application/json" },
|
28
|
+
body:JSON.stringify({type: type})
|
29
|
+
};
|
30
|
+
console.log(type);
|
31
|
+
trackPromise(
|
32
|
+
fetch("/getCatalog", options).then(res => res.json())
|
33
|
+
.then((result) => {
|
34
|
+
this.setState({ products: result.products });
|
35
|
+
// console.log(this.state.products);
|
36
|
+
}));
|
37
|
+
options = {
|
38
|
+
method: "GET",
|
39
|
+
headers: { "Content-Type": "application/json" },
|
40
|
+
};
|
41
|
+
trackPromise(
|
42
|
+
fetch("/getCurrentWishlist", options).then(res => res.json())
|
43
|
+
.then((result) => {
|
44
|
+
console.log(result.wishlist.products[0]);
|
45
|
+
this.setState({ wishlist: result.wishlist.products.map(p => p.id) });
|
46
|
+
}));
|
47
|
+
}
|
48
|
+
|
49
|
+
componentDidUpdate = async(prevProps,prevState) => {
|
50
|
+
if (this.state.type !== prevState.type) {
|
51
|
+
console.log('type changed');
|
52
|
+
var type = this.state.type ? this.state.type : "All";
|
53
|
+
var options = {
|
54
|
+
method: "POST",
|
55
|
+
headers: { "Content-Type": "application/json" },
|
56
|
+
body:JSON.stringify({type: type})
|
57
|
+
};
|
58
|
+
console.log(type);
|
59
|
+
trackPromise(
|
60
|
+
fetch("/getCatalog", options).then(res => res.json())
|
61
|
+
.then((result) => {
|
62
|
+
this.setState({ products: result.products });
|
63
|
+
console.log(this.state.products);
|
64
|
+
}));
|
65
|
+
}
|
66
|
+
}
|
67
|
+
refreshPage() {
|
68
|
+
window.location.reload(false);
|
69
|
+
}
|
70
|
+
|
71
|
+
async changeType(e){
|
72
|
+
var type = e.target.value;
|
73
|
+
this.setState({type:type, products:false});
|
74
|
+
}
|
75
|
+
|
76
|
+
render() {
|
77
|
+
return (
|
78
|
+
<div className="container main-content">
|
79
|
+
<div className="catalog-btn" role="group" aria-label="Basic example">
|
80
|
+
<button type="button" onClick={() => this.refreshPage()} title="Refresh"><FiRefreshCcw/></button>
|
81
|
+
<button type="button" onClick={() => this.setState({showModal:true})} title="Add New Product"><FaPlus />{this.state.showModal? <NewProductModal showModal={true}/>:""}</button>
|
82
|
+
<button style={{width:"100px", height:"40px"}} type="button" onClick={(e) => this.changeType(e)} title="Show Flowers Only" value="Flower" >Flowers</button>
|
83
|
+
<button style={{width:"120px", height:"40px"}} type="button" onClick={(e) => this.changeType(e)} title="Show Bouquests Only" value="Bouquest">Bouquests</button>
|
84
|
+
<button className="sortersButtons" type="button" onClick={(e) => this.changeType(e)} title="Show All products" value="All">All</button>
|
85
|
+
</div>
|
86
|
+
<LoadingIndicator/>
|
87
|
+
{ this.state.products && this.state.products.length > 0 ?
|
88
|
+
this.state.products.map((product) => {
|
89
|
+
return (
|
90
|
+
<Product
|
91
|
+
id={product._id}
|
92
|
+
image={product.image}
|
93
|
+
name={product.name}
|
94
|
+
color={product.color}
|
95
|
+
price={product.price}
|
96
|
+
description={product.description}
|
97
|
+
type={product.type}
|
98
|
+
onUpdateCart={(num) => this.props.onUpdateCart(num)}
|
99
|
+
onUpdateWishlist={(num) => this.props.onUpdateWishlist(num)}
|
100
|
+
isInWishList={this.state.wishlist.indexOf(product._id) == -1 ? false: true}
|
101
|
+
maxAmount={product.maxAmount}
|
102
|
+
sellerName={product.sellerId}
|
103
|
+
/>
|
104
|
+
);
|
105
|
+
}):""}{ this.state.products && this.state.products.length == 0 ?
|
106
|
+
<h1> There are no products for this category</h1>
|
107
|
+
:""}
|
108
|
+
<br />
|
109
|
+
<br />
|
110
|
+
<br />
|
111
|
+
<br />
|
112
|
+
</div>
|
113
|
+
);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
export default ProductList;
|
118
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import ScrollToBottom from "react-scroll-to-bottom";
|
3
|
+
|
4
|
+
function Chat({ socket, username, room }) {
|
5
|
+
const [currentMessage, setCurrentMessage] = useState("");
|
6
|
+
const [messageList, setMessageList] = useState([]);
|
7
|
+
|
8
|
+
const sendMessage = async () => {
|
9
|
+
if (currentMessage !== "") {
|
10
|
+
const messageData = {
|
11
|
+
room: room,
|
12
|
+
author: username,
|
13
|
+
message: currentMessage,
|
14
|
+
time:
|
15
|
+
new Date(Date.now()).getHours() +
|
16
|
+
":" +
|
17
|
+
new Date(Date.now()).getMinutes(),
|
18
|
+
};
|
19
|
+
|
20
|
+
await socket.emit("send_message", messageData);
|
21
|
+
setMessageList((list) => [...list, messageData]);
|
22
|
+
setCurrentMessage("");
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
useEffect(() => {
|
27
|
+
socket.on("receive_message", (data) => {
|
28
|
+
setMessageList((list) => [...list, data]);
|
29
|
+
});
|
30
|
+
}, [socket]);
|
31
|
+
|
32
|
+
return (
|
33
|
+
<div className="chat-window">
|
34
|
+
<div className="chat-header">
|
35
|
+
<p>Live Chat</p>
|
36
|
+
</div>
|
37
|
+
<div className="chat-body">
|
38
|
+
<ScrollToBottom className="message-container">
|
39
|
+
{messageList.map((messageContent) => {
|
40
|
+
return (
|
41
|
+
<div
|
42
|
+
className="message"
|
43
|
+
id={username === messageContent.author ? "you" : "other"}
|
44
|
+
>
|
45
|
+
<div>
|
46
|
+
<div className="message-content">
|
47
|
+
<p>{messageContent.message}</p>
|
48
|
+
</div>
|
49
|
+
<div className="message-meta">
|
50
|
+
<p id="time">{messageContent.time}</p>
|
51
|
+
<p id="author">{messageContent.author}</p>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
);
|
56
|
+
})}
|
57
|
+
</ScrollToBottom>
|
58
|
+
</div>
|
59
|
+
<div className="chat-footer">
|
60
|
+
<input
|
61
|
+
type="text"
|
62
|
+
value={currentMessage}
|
63
|
+
placeholder="Hey..."
|
64
|
+
onChange={(event) => {
|
65
|
+
setCurrentMessage(event.target.value);
|
66
|
+
}}
|
67
|
+
onKeyPress={(event) => {
|
68
|
+
event.key === "Enter" && sendMessage();
|
69
|
+
}}
|
70
|
+
/>
|
71
|
+
<button onClick={sendMessage}>►</button>
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
);
|
75
|
+
}
|
76
|
+
|
77
|
+
export default Chat;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import React, { Component } from "react";
|
2
|
+
import '../css/contact.css';
|
3
|
+
|
4
|
+
class Contact extends Component {
|
5
|
+
render() {
|
6
|
+
return (
|
7
|
+
<div className="bg-contact100">
|
8
|
+
<div className="container-contact100">
|
9
|
+
<div className="wrap-contact100">
|
10
|
+
<div className="contact100-pic js-tilt" data-tilt>
|
11
|
+
<img src="images/contact-us.png" alt="IMG"/>
|
12
|
+
</div>
|
13
|
+
<form className="contact100-form validate-form">
|
14
|
+
<span className="contact100-form-title">
|
15
|
+
Get in touch
|
16
|
+
</span>
|
17
|
+
<div className="wrap-input100 validate-input" data-validate="Name is required">
|
18
|
+
<input className="input100" type="text" name="name" placeholder="Name"/>
|
19
|
+
<span className="focus-input100"></span>
|
20
|
+
<span className="symbol-input100">
|
21
|
+
<i className="fa fa-user" aria-hidden="true"></i>
|
22
|
+
</span>
|
23
|
+
</div>
|
24
|
+
<div className="wrap-input100 validate-input" data-validate="Valid email is required: ex@abc.xyz">
|
25
|
+
<input className="input100" type="text" name="email" placeholder="Email"/>
|
26
|
+
<span className="focus-input100"></span>
|
27
|
+
<span className="symbol-input100">
|
28
|
+
<i className="fa fa-envelope" aria-hidden="true"></i>
|
29
|
+
</span>
|
30
|
+
</div>
|
31
|
+
<div className="wrap-input100 validate-input" data-validate="Message is required">
|
32
|
+
<textarea className="input100" name="message" placeholder="Message"></textarea>
|
33
|
+
<span className="focus-input100"></span>
|
34
|
+
</div>
|
35
|
+
<div className="container-contact100-form-btn">
|
36
|
+
<button className="contact100-form-btn">
|
37
|
+
Send
|
38
|
+
</button>
|
39
|
+
</div>
|
40
|
+
</form>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
export default Contact;
|
@@ -0,0 +1,362 @@
|
|
1
|
+
import React, { Component } from "react";
|
2
|
+
import { confirmAlert } from 'react-confirm-alert'; // Import
|
3
|
+
import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css
|
4
|
+
import Button from "react-bootstrap/Button";
|
5
|
+
import Modal from "react-bootstrap/Modal";
|
6
|
+
import { NavLink } from "react-router-dom";
|
7
|
+
import { FaPlus } from "react-icons/fa";
|
8
|
+
import '../css/newProductModal.css';
|
9
|
+
import withAuth from "./Auth.js";
|
10
|
+
import {FaEye, FaPen, FaTrash } from "react-icons/fa";
|
11
|
+
import swal from 'sweetalert';
|
12
|
+
import LoadingIndicator from "./Spinner";
|
13
|
+
import { usePromiseTracker, trackPromise } from "react-promise-tracker";
|
14
|
+
class DetailsProductModal extends Component {
|
15
|
+
constructor(props) {
|
16
|
+
super(props);
|
17
|
+
console.log(props);
|
18
|
+
this.state = {
|
19
|
+
showModal: props.showModal,
|
20
|
+
isUpdate: false,
|
21
|
+
name: props.name,
|
22
|
+
price: props.price,
|
23
|
+
description: props.description,
|
24
|
+
color: props.color,
|
25
|
+
type: props.type,
|
26
|
+
id: props.id,
|
27
|
+
image:props.image,
|
28
|
+
picture: false,
|
29
|
+
src: false,
|
30
|
+
maxAmount:props.maxAmount,
|
31
|
+
ERROR: "",
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
handleClose = () => {
|
36
|
+
this.setState({ showModal: false });
|
37
|
+
};
|
38
|
+
handleShow = () => {
|
39
|
+
this.setState({ showModal: true });
|
40
|
+
};
|
41
|
+
changeUpdate = () => {
|
42
|
+
this.setState({ isUpdate: !this.state.isUpdate });
|
43
|
+
};
|
44
|
+
|
45
|
+
showConfirmDialog = () => {
|
46
|
+
this.handleClose();
|
47
|
+
confirmAlert({
|
48
|
+
title: 'Confirm to submit',
|
49
|
+
message: 'Are you sure to do this.',
|
50
|
+
buttons: [
|
51
|
+
{
|
52
|
+
label: 'Yes',
|
53
|
+
onClick: () => this.deleteProduct()
|
54
|
+
},
|
55
|
+
{
|
56
|
+
label: 'No',
|
57
|
+
}
|
58
|
+
]
|
59
|
+
});
|
60
|
+
};
|
61
|
+
async deleteProduct(){
|
62
|
+
var options = {
|
63
|
+
method: "POST",
|
64
|
+
headers: { "Content-Type": "application/json" },
|
65
|
+
body: JSON.stringify({id: this.state.id}),
|
66
|
+
};
|
67
|
+
trackPromise(
|
68
|
+
fetch("/deleteProduct", options).then(
|
69
|
+
(res) => {
|
70
|
+
console.log(res);
|
71
|
+
if (res.status == 200) {
|
72
|
+
console.log("deleting product was successful");
|
73
|
+
} else if (res.status == 404) {
|
74
|
+
this.setState({ ERROR: "Product does not exist already" });
|
75
|
+
} else if (res.status == 400) {
|
76
|
+
this.setState({ ERROR: "There was an error. Please try again" });
|
77
|
+
} else if (res.status == 500) {
|
78
|
+
this.setState({ ERROR: "There was an error on our side" });
|
79
|
+
}
|
80
|
+
},
|
81
|
+
(error) => {
|
82
|
+
this.setState({
|
83
|
+
ERROR: error,
|
84
|
+
});
|
85
|
+
}
|
86
|
+
));
|
87
|
+
swal("Deleted!", "Product deleted successfully!", "success");
|
88
|
+
}
|
89
|
+
async updateProduct() {
|
90
|
+
var name = this.state.name;
|
91
|
+
var price = this.state.price;
|
92
|
+
var description = this.state.description;
|
93
|
+
var color = this.state.color;
|
94
|
+
var type = this.state.type;
|
95
|
+
var maxAmount = this.state.maxAmount;
|
96
|
+
if (
|
97
|
+
name == "" ||
|
98
|
+
price == "" ||
|
99
|
+
description == "" ||
|
100
|
+
color == "" ||
|
101
|
+
type == "" ||
|
102
|
+
maxAmount == ""
|
103
|
+
) {
|
104
|
+
this.setState({ ERROR: "Please fill all the fields." });
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
var product = {
|
108
|
+
name: name,
|
109
|
+
color: color,
|
110
|
+
description: description,
|
111
|
+
price: price,
|
112
|
+
type: type,
|
113
|
+
maxAmount: maxAmount,
|
114
|
+
_id: this.state.id
|
115
|
+
};
|
116
|
+
|
117
|
+
var options = {
|
118
|
+
method: "POST",
|
119
|
+
headers: { "Content-Type": "application/json" },
|
120
|
+
body: JSON.stringify({product: product}),
|
121
|
+
};
|
122
|
+
trackPromise(
|
123
|
+
fetch("/updateProduct", options).then(
|
124
|
+
(res) => {
|
125
|
+
console.log(res);
|
126
|
+
if (res.status == 200) {
|
127
|
+
console.log("updating product was successful");
|
128
|
+
} else if (res.status == 400) {
|
129
|
+
this.setState({ ERROR: "There was an error. Please try again" });
|
130
|
+
} else if (res.status == 500) {
|
131
|
+
this.setState({ ERROR: "There was an error on our side" });
|
132
|
+
}
|
133
|
+
},
|
134
|
+
(error) => {
|
135
|
+
this.setState({
|
136
|
+
ERROR: error,
|
137
|
+
});
|
138
|
+
}
|
139
|
+
));
|
140
|
+
if (!this.state.picture) {
|
141
|
+
swal("Updated!", "Product updated successfully!", "success");
|
142
|
+
}else{
|
143
|
+
var myFormData = new FormData();
|
144
|
+
myFormData.append('file', this.state.picture);
|
145
|
+
myFormData.append('id', this.state.id);
|
146
|
+
|
147
|
+
const response = await fetch("/addProductPicture", {
|
148
|
+
method: "POST",
|
149
|
+
body: myFormData,
|
150
|
+
});
|
151
|
+
if (response.status == 200) {
|
152
|
+
swal("Updated!", "Product updated successfully!", "success");
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
renderPreview() {
|
157
|
+
if(this.state.src) {
|
158
|
+
return (
|
159
|
+
<img src={this.state.src} style={{"maxWidth": "inherit", "maxHeight": "inherit"}}/>
|
160
|
+
);
|
161
|
+
} else {
|
162
|
+
return (
|
163
|
+
<p>
|
164
|
+
No Preview
|
165
|
+
</p>
|
166
|
+
);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
handlePictureSelected(event) {
|
171
|
+
var picture = event.target.files[0];
|
172
|
+
var src = URL.createObjectURL(picture);
|
173
|
+
|
174
|
+
this.setState({
|
175
|
+
picture: picture,
|
176
|
+
src: src
|
177
|
+
});
|
178
|
+
}
|
179
|
+
|
180
|
+
inputsHandler = (e) => {
|
181
|
+
this.setState({ [e.target.name]: e.target.value });
|
182
|
+
};
|
183
|
+
radioHandler = (e) => {
|
184
|
+
this.setState({
|
185
|
+
[e.target.name]: document.querySelector(
|
186
|
+
`input[name=${e.target.name}]:checked`
|
187
|
+
).id,
|
188
|
+
});
|
189
|
+
};
|
190
|
+
colorSelected = (e) => {
|
191
|
+
this.setState({
|
192
|
+
color : e.target.value});
|
193
|
+
};
|
194
|
+
render() {
|
195
|
+
return (
|
196
|
+
<div>
|
197
|
+
<Modal
|
198
|
+
style={{ opacity: 1 }}
|
199
|
+
show={this.state.showModal}
|
200
|
+
onHide={() => this.handleClose()}
|
201
|
+
>
|
202
|
+
|
203
|
+
<Modal.Header>
|
204
|
+
<Modal.Title>
|
205
|
+
<div className="modal-header">
|
206
|
+
<img style={{"maxWidth": "inherit", "maxHeight": "50%","borderRadius":"50%"}} src={this.props.path}
|
207
|
+
onError={( e ) => {
|
208
|
+
e.target.src='https://www.freeiconspng.com/uploads/no-image-icon-11.PNG';
|
209
|
+
e.target.onerror = null; // prevents looping
|
210
|
+
}}
|
211
|
+
alt={this.state.name} height="150" />
|
212
|
+
<h5 className="modal-title" id="exampleModalLabel">
|
213
|
+
{this.state.name}
|
214
|
+
</h5>
|
215
|
+
</div>
|
216
|
+
</Modal.Title>
|
217
|
+
</Modal.Header>
|
218
|
+
<Modal.Body>
|
219
|
+
<LoadingIndicator/>
|
220
|
+
<form key={this.state.id}>
|
221
|
+
<div className="mb-3">
|
222
|
+
<input
|
223
|
+
type="text"
|
224
|
+
name="name"
|
225
|
+
id="name"
|
226
|
+
className="form-control"
|
227
|
+
placeholder="Name of the flower"
|
228
|
+
onChange={this.inputsHandler}
|
229
|
+
defaultValue={this.state.name}
|
230
|
+
required
|
231
|
+
autoFocus
|
232
|
+
disabled = {this.state.isUpdate? "" : "disabled"}
|
233
|
+
/>
|
234
|
+
</div>
|
235
|
+
<div className="mb-3" style={{display:this.state.isUpdate? "block" : "none"}}>
|
236
|
+
Pick a color
|
237
|
+
<input defaultValue={this.state.color} onChange={this.colorSelected} type="color" disabled = {this.state.isUpdate? "" : "disabled"}/>
|
238
|
+
</div>
|
239
|
+
<div className="mb-3" style={{display:!this.state.isUpdate? "block" : "none"}}>
|
240
|
+
<input type="color" value={this.state.color} disabled = "disabled"/>
|
241
|
+
</div>
|
242
|
+
<div className="mb-3">
|
243
|
+
<input
|
244
|
+
type="text"
|
245
|
+
name="description"
|
246
|
+
id="description"
|
247
|
+
className="form-control"
|
248
|
+
placeholder="Description"
|
249
|
+
defaultValue={this.state.description}
|
250
|
+
onChange={this.inputsHandler}
|
251
|
+
required
|
252
|
+
disabled = {this.state.isUpdate? "" :"disabled"}
|
253
|
+
/>
|
254
|
+
</div>
|
255
|
+
<div className="mb-3">
|
256
|
+
<input
|
257
|
+
type="number"
|
258
|
+
step="0.01"
|
259
|
+
name="price"
|
260
|
+
id="price"
|
261
|
+
className="form-control"
|
262
|
+
placeholder="Price"
|
263
|
+
onChange={this.inputsHandler}
|
264
|
+
defaultValue={this.state.price}
|
265
|
+
required
|
266
|
+
disabled = {this.state.isUpdate? "" :"disabled"}
|
267
|
+
/>
|
268
|
+
</div>
|
269
|
+
<div className="mb-3">
|
270
|
+
<input
|
271
|
+
type="number"
|
272
|
+
name="maxAmount"
|
273
|
+
id="maxAmount"
|
274
|
+
className="form-control"
|
275
|
+
placeholder="Max Amount"
|
276
|
+
onChange={this.inputsHandler}
|
277
|
+
defaultValue={this.state.maxAmount}
|
278
|
+
required
|
279
|
+
disabled = {this.state.isUpdate? "" :"disabled"}
|
280
|
+
/>
|
281
|
+
</div>
|
282
|
+
<div className="mb-3" style={{display: this.state.isUpdate? "none" : "block"}}>
|
283
|
+
<input
|
284
|
+
type="text"
|
285
|
+
name="type"
|
286
|
+
id="type"
|
287
|
+
className="form-control"
|
288
|
+
placeholder="Type"
|
289
|
+
defaultValue={this.state.type}
|
290
|
+
onChange={this.inputsHandler}
|
291
|
+
required
|
292
|
+
disabled = "disabled"
|
293
|
+
/>
|
294
|
+
</div>
|
295
|
+
<div className="mb-3" style={{display:this.state.isUpdate? "block" : "none"}}>
|
296
|
+
<input
|
297
|
+
type="radio"
|
298
|
+
name="type"
|
299
|
+
id="Bouquet"
|
300
|
+
onChange={this.radioHandler}
|
301
|
+
checked = {this.state.type == "Bouquet" ? "checked" : null}
|
302
|
+
/>
|
303
|
+
<label for="rd1">Bouquet</label>
|
304
|
+
<input
|
305
|
+
type="radio"
|
306
|
+
name="type"
|
307
|
+
id="Flower"
|
308
|
+
onChange={this.radioHandler}
|
309
|
+
checked = {this.state.type == "Flower" ? "checked" : null}
|
310
|
+
/>
|
311
|
+
<label for="rd2">Flower</label>
|
312
|
+
</div>
|
313
|
+
<div style={{display:this.state.isUpdate? "block" : "none"}} className="mb-3">
|
314
|
+
<h2>Upload Product Image</h2>
|
315
|
+
<input
|
316
|
+
name="file"
|
317
|
+
id="file"
|
318
|
+
type="file"
|
319
|
+
onChange={this.handlePictureSelected.bind(this)}
|
320
|
+
/>
|
321
|
+
<br/>
|
322
|
+
<div style={{"maxWidth": "80%", "maxHeight": "80%"}}>
|
323
|
+
{this.renderPreview()}
|
324
|
+
</div>
|
325
|
+
<hr/>
|
326
|
+
</div>
|
327
|
+
</form>
|
328
|
+
</Modal.Body>
|
329
|
+
<Modal.Footer>
|
330
|
+
<h5>{this.state.ERROR}</h5>
|
331
|
+
<div className="modal-footer">
|
332
|
+
<a
|
333
|
+
role="button"
|
334
|
+
style={{display: this.state.isUpdate? "block" : "none"}}
|
335
|
+
onClick={() => this.changeUpdate()}
|
336
|
+
>
|
337
|
+
<FaEye/>
|
338
|
+
</a>
|
339
|
+
<a
|
340
|
+
role="button"
|
341
|
+
style={{display: !this.state.isUpdate? "block" : "none"}}
|
342
|
+
onClick={() => this.showConfirmDialog()}
|
343
|
+
>
|
344
|
+
<FaTrash/>
|
345
|
+
</a>
|
346
|
+
<a
|
347
|
+
role="button"
|
348
|
+
style={{display: !this.state.isUpdate? "block" : "none"}}
|
349
|
+
onClick={() => this.changeUpdate()}
|
350
|
+
>
|
351
|
+
<FaPen/>
|
352
|
+
</a>
|
353
|
+
<button onClick={() => this.updateProduct()} className="button-17" style={{display: this.state.isUpdate? "block" : "none"}}>Update</button>
|
354
|
+
</div>
|
355
|
+
</Modal.Footer>
|
356
|
+
</Modal>
|
357
|
+
</div>
|
358
|
+
);
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
export default DetailsProductModal;
|