scinote-web/app/javascript/packs/shared/navigation/components/NotificationItem.jsx

57 lines
1.5 KiB
React
Raw Normal View History

2017-08-08 21:44:28 +08:00
import React from "react";
import PropTypes from "prop-types";
import { Col, Row } from "react-bootstrap";
import { FormattedTime } from "react-intl";
2017-08-09 20:49:29 +08:00
import styled from "styled-components";
2017-08-08 21:44:28 +08:00
import CustomNavItem from "./CustomNavItem";
2017-08-09 20:49:29 +08:00
const StyledListItem = styled(CustomNavItem)`
border-bottom: 1px solid #d2d2d2;
padding-bottom: 10px;
padding-top: 10px;
`;
2017-08-08 21:44:28 +08:00
const NotificationItem = ({ notification }) => {
const { title, message, created_at, type_of } = notification;
return (
2017-08-09 20:49:29 +08:00
<StyledListItem>
2017-08-08 21:44:28 +08:00
<Row>
<Col xs={2}>
<div className="text-center">
<span className="assignment">
<i className="fa fa-newspaper-o" />
</span>
</div>
</Col>
<Col xs={10}>
2017-08-09 20:49:29 +08:00
<strong dangerouslySetInnerHTML={{ __html: title }} />
2017-08-08 21:44:28 +08:00
<br />
<FormattedTime
value={created_at}
day="numeric"
month="numeric"
year="numeric"
hour="numeric"
minute="numeric"
2017-08-09 20:49:29 +08:00
/>&nbsp;|&nbsp;<span dangerouslySetInnerHTML={{ __html: message }} />
2017-08-08 21:44:28 +08:00
</Col>
</Row>
2017-08-09 20:49:29 +08:00
</StyledListItem>
2017-08-08 21:44:28 +08:00
);
};
NotificationItem.propTypes = {
notification: PropTypes.shape({
id: PropTypes.number.isRequired,
title: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
type_of: PropTypes.string.isRequired,
created_at: PropTypes.string.isRequired
}).isRequired
};
export default NotificationItem;