Convert class to function component (#25769)

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Thomas Brq
2024-01-09 15:24:12 +01:00
коммит произвёл GitHub
родитель e959d9e4ea
Коммит eca13a947b

Просмотреть файл

@@ -15,8 +15,14 @@ type Props = {
status?: 'warning' | 'error';
}
export default class StatisticCount extends React.PureComponent<Props> {
public render(): JSX.Element {
const StatisticCount = ({
title,
icon,
count,
id,
children,
status,
}: Props) => {
const loading = (
<FormattedMessage
id='analytics.chart.loading'
@@ -29,33 +35,34 @@ export default class StatisticCount extends React.PureComponent<Props> {
<div
className={classNames({
'total-count': true,
'total-count--has-message': Boolean(this.props.status),
'total-count--has-message': Boolean(status),
})}
>
<div
data-testid={`${this.props.id}Title`}
data-testid={`${id}Title`}
className={classNames({
title: true,
'team_statistics--warning': this.props.status === 'warning',
'team_statistics--error': this.props.status === 'error',
'team_statistics--warning': status === 'warning',
'team_statistics--error': status === 'error',
})}
>
{this.props.title}
<i className={'fa ' + this.props.icon}/>
{title}
<i className={'fa ' + icon}/>
</div>
<div
data-testid={this.props.id}
data-testid={id}
className={classNames({
content: true,
'team_statistics--warning': this.props.status === 'warning',
'team_statistics--error': this.props.status === 'error',
'team_statistics--warning': status === 'warning',
'team_statistics--error': status === 'error',
})}
>
{typeof this.props.count === 'undefined' || isNaN(this.props.count) ? loading : this.props.count}
{typeof count === 'undefined' || isNaN(count) ? loading : count}
</div>
</div>
{this.props.children}
{children}
</div>
);
}
}
};
export default React.memo(StatisticCount);