From b0f1913a1da3cc1ce045bba1d0c99eb5cb9c231d Mon Sep 17 00:00:00 2001 From: Vasek Mlejnsky Date: Thu, 27 Sep 2018 09:13:29 +0200 Subject: [PATCH] Add prop types & flow --- .../components/Group/index.js | 11 +++++++++ src/components/Notification/index.js | 23 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/components/Notification/NotificationGroups/components/Group/index.js b/src/components/Notification/NotificationGroups/components/Group/index.js index 2053c73d..c3915b77 100644 --- a/src/components/Notification/NotificationGroups/components/Group/index.js +++ b/src/components/Notification/NotificationGroups/components/Group/index.js @@ -1,4 +1,5 @@ import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import styled from 'styled-components'; import Icon from 'components/Icon'; import ICONS from 'config/icons'; @@ -99,4 +100,14 @@ class Group extends Component { } } +Group.propTypes = { + type: PropTypes.string, + groupNotifications: PropTypes.arrayOf({ + key: PropTypes.string, + type: PropTypes.string, + title: PropTypes.string, + message: PropTypes.string, + }), +}; + export default Group; \ No newline at end of file diff --git a/src/components/Notification/index.js b/src/components/Notification/index.js index 7c646164..49953fff 100644 --- a/src/components/Notification/index.js +++ b/src/components/Notification/index.js @@ -1,3 +1,5 @@ +/* @flow */ + import React from 'react'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; @@ -10,8 +12,25 @@ import { FONT_SIZE, FONT_WEIGHT } from 'config/variables'; import * as NotificationActions from 'actions/NotificationActions'; import Loader from 'components/Loader'; +import type { Action, State } from 'flowtype'; import NotificationButton from './components/NotificationButton'; +type Props = { + key?: number, + notifications: $ElementType, + close: (notif?: any) => Action, +}; + +type NProps = { + type: string, + cancelable?: boolean; + title: string; + message?: string; + actions?: Array; + close?: typeof NotificationActions.close, + loading?: boolean +}; + const Wrapper = styled.div` position: relative; color: ${colors.TEXT_PRIMARY}; @@ -141,7 +160,7 @@ export const Notification = (props: NProps): React$Element => { ); }; -export const NotificationGroup = (props) => { +export const NotificationGroup = (props: Props) => { const { notifications, close } = props; return notifications.map(n => ( ({ close: bindActionCreators(NotificationActions.close, dispatch), }), -)(NotificationGroup); \ No newline at end of file +)(NotificationGroup);