Refactor APIErrorsNotice to Typescript

[MAILPOET-2658]
This commit is contained in:
Amine Ben hammou
2020-02-26 15:16:42 +01:00
committed by Jack Kitterhing
parent 25aec60bc9
commit 83f3729e37
2 changed files with 11 additions and 8 deletions

View File

@@ -3,7 +3,7 @@ import MailPoet from 'mailpoet';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { Link } from 'react-router-dom';
import APIErrorsNotice from 'notices/api_errors_notice.jsx';
import APIErrorsNotice from 'notices/api_errors_notice.tsx';
const QueuePropType = PropTypes.shape({
status: PropTypes.string,

View File

@@ -1,15 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';
import React, { FC } from 'react';
import PropTypes, { InferProps } from 'prop-types';
import Notice from 'notices/notice.tsx';
const APIErrorsNotice = ({ errors }) => {
if (errors.length < 1) return null;
return <Notice type="error" closable={false}>{errors.map((err) => <p key={err.message}>{err.message}</p>)}</Notice>;
};
APIErrorsNotice.propTypes = {
const propTypes = {
errors: PropTypes.arrayOf(PropTypes.shape({
message: PropTypes.string.isRequired,
})).isRequired,
};
const APIErrorsNotice: FC<InferProps<typeof propTypes>> = ({ errors }) => {
if (errors.length < 1) return null;
return <Notice type="error" closable={false}>{errors.map((err) => <p key={err.message}>{err.message}</p>)}</Notice>;
};
APIErrorsNotice.propTypes = propTypes;
export default APIErrorsNotice;