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
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
<button onClick={this.handleOpen}>Open Modal</button>
|
|
|
|
|
|
|
|
|
|
<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);
|