2019-01-16 22:06:06 +01:00
|
|
|
import React from "react";
|
|
|
|
|
import { notificationmodalwrapper } from "utils/notificationmodalwrapper";
|
2019-01-19 16:53:27 +01:00
|
|
|
import axios from "axios";
|
2019-01-16 22:06:06 +01:00
|
|
|
|
|
|
|
|
const modalStyle = function() {
|
2019-01-19 16:53:27 +01:00
|
|
|
let top = 20;
|
|
|
|
|
let left = 20;
|
2019-01-16 22:06:06 +01:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
position: "absolute",
|
|
|
|
|
width: 400,
|
|
|
|
|
zIndex: 1040,
|
|
|
|
|
top: top + "%",
|
|
|
|
|
left: left + "%",
|
|
|
|
|
border: "1px solid #e5e5e5",
|
|
|
|
|
backgroundColor: "white",
|
|
|
|
|
boxShadow: "0 5px 15px rgba(0,0,0,.5)",
|
|
|
|
|
padding: 20
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-29 20:30:43 +01:00
|
|
|
const buttonStyle = function() {
|
|
|
|
|
return {
|
|
|
|
|
width: "100px",
|
|
|
|
|
margin: "0 auto",
|
|
|
|
|
position: "relative",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
display: "block",
|
|
|
|
|
padding: "10px 10px",
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
marginBottom: "20px",
|
|
|
|
|
color: "white",
|
|
|
|
|
backgroundColor: "#e91e63",
|
|
|
|
|
border: "1px solid #e91e63"
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-16 22:06:06 +01:00
|
|
|
class NotificationModal extends React.Component {
|
|
|
|
|
handleOpen = () => {
|
|
|
|
|
this.props.onModalOpen();
|
|
|
|
|
};
|
|
|
|
|
handleClose = () => {
|
|
|
|
|
this.props.onModalClose();
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-19 16:53:27 +01:00
|
|
|
handleInput = e => {
|
|
|
|
|
this.props.onUserDataChange({ info: "email", value: e.target.value });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleSaveMarketAlert = () => {
|
|
|
|
|
const {
|
|
|
|
|
userdata: { email, last_date, olx_url }
|
|
|
|
|
} = this.props;
|
|
|
|
|
axios
|
|
|
|
|
.post("/api/marketalerts", {
|
|
|
|
|
email,
|
|
|
|
|
last_date,
|
|
|
|
|
olx_url
|
|
|
|
|
})
|
|
|
|
|
.then(response => console.log(response.data))
|
|
|
|
|
.catch(error => console.log(error));
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-16 22:06:06 +01:00
|
|
|
render() {
|
|
|
|
|
const { modal } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2019-01-29 20:30:43 +01:00
|
|
|
<button style={buttonStyle()} onClick={this.handleOpen}>
|
|
|
|
|
Open Modal
|
|
|
|
|
</button>
|
2019-01-16 22:06:06 +01:00
|
|
|
|
|
|
|
|
<div style={modalStyle()} aria-labelledby="modal-label" hidden={!modal}>
|
|
|
|
|
<div>
|
2019-01-19 16:53:27 +01:00
|
|
|
<input
|
|
|
|
|
type="email"
|
|
|
|
|
placeholder="email"
|
|
|
|
|
onChange={this.handleInput}
|
|
|
|
|
/>
|
|
|
|
|
<button onClick={this.handleSaveMarketAlert}>
|
|
|
|
|
Save Market Alert
|
|
|
|
|
</button>
|
2019-01-16 22:06:06 +01:00
|
|
|
<button onClick={this.handleClose}>Close Modal</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default notificationmodalwrapper(NotificationModal);
|