import React, { Component } from "react";
import { NavDropdown } from "react-bootstrap";
import { FormattedMessage } from "react-intl";
import axios from "axios";
import styled from "styled-components";
import { RECENT_NOTIFICATIONS_PATH } from "../../../app/routes";
import {
MAIN_COLOR_BLUE,
WILD_SAND_COLOR,
MYSTIC_COLOR
} from "../../../app/constants/colors";
import NotificationItem from "./NotificationItem";
import Spinner from "../../Spinner";
import CustomNavItem from "./CustomNavItem";
const StyledListHeader = styled(CustomNavItem)`
background-color: ${MAIN_COLOR_BLUE};
color: ${WILD_SAND_COLOR};
font-weight: bold;
padding: 8px;
& a, a:hover, a:active {
color: ${WILD_SAND_COLOR};
}
`;
const StyledListFooter = styled(CustomNavItem)`
background-color: ${MYSTIC_COLOR};
padding: 8px;
text-align: center;
`;
const StyledNavDropdown = styled(NavDropdown)`
& > .dropdown-menu {
max-height: 500px;
overflow-x: hidden;
overflow-y: scroll;
padding-bottom: 0;
padding-top: 0;
width: 450px;
word-wrap: break-word;
}
`;
class NotificationsDropdown extends Component {
constructor(props) {
super(props);
this.state = { notifications: [] };
this.getRecentNotifications = this.getRecentNotifications.bind(this);
this.renderNotifications = this.renderNotifications.bind(this);
}
getRecentNotifications(e) {
e.preventDefault();
axios
.get(RECENT_NOTIFICATIONS_PATH, { withCredentials: true })
.then(({ data }) => {
this.setState({ notifications: data });
})
.catch(error => {
console.log("get Notifications Error: ", error); // TODO change this
});
}
renderNotifications() {
const list = this.state.notifications.map(notification =>
);
const items =
this.state.notifications.length > 0
? list
:
;
return items;
}
render() {
return (
}
onClick={this.getRecentNotifications}
>
{this.renderNotifications()}
);
}
}
export default NotificationsDropdown;