2018-10-24 14:33:53 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { AppNotification } from 'app/types';
|
2019-02-06 19:42:04 +01:00
|
|
|
import { AlertBox } from '../AlertBox/AlertBox';
|
2018-10-24 14:33:53 +02:00
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
appNotification: AppNotification;
|
|
|
|
|
onClearNotification: (id) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default class AppNotificationItem extends Component<Props> {
|
|
|
|
|
shouldComponentUpdate(nextProps) {
|
|
|
|
|
return this.props.appNotification.id !== nextProps.appNotification.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
const { appNotification, onClearNotification } = this.props;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
onClearNotification(appNotification.id);
|
|
|
|
|
}, appNotification.timeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { appNotification, onClearNotification } = this.props;
|
2018-12-15 10:04:25 +01:00
|
|
|
|
2018-10-24 14:33:53 +02:00
|
|
|
return (
|
2019-02-06 19:42:04 +01:00
|
|
|
<AlertBox
|
|
|
|
|
severity={appNotification.severity}
|
|
|
|
|
title={appNotification.title}
|
|
|
|
|
text={appNotification.text}
|
|
|
|
|
icon={appNotification.icon}
|
|
|
|
|
onClose={() => onClearNotification(appNotification.id)}
|
|
|
|
|
/>
|
2018-10-24 14:33:53 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|