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 21:21:02 +08:00
|
|
|
import NotificationImage from "./NotificationImage";
|
2017-08-08 21:44:28 +08:00
|
|
|
|
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}>
|
2017-08-09 21:21:02 +08:00
|
|
|
<NotificationImage type={type_of} />
|
2017-08-08 21:44:28 +08:00
|
|
|
</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
|
|
|
/> | <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;
|