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