import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './googleCloud.css';
import { withTranslation } from 'react-i18next';
import { Icon } from '@ohif/ui';
class LocationsList extends Component {
state = {
search: '',
};
static propTypes = {
locations: PropTypes.array,
loading: PropTypes.bool.isRequired,
error: PropTypes.string,
onSelect: PropTypes.func,
};
static defaultProps = {
loading: true,
};
renderTableRow = location => {
return (
{
this.onHighlightItem(location.locationId);
}}
onClick={() => {
this.props.onSelect(location);
}}
>
| {location.name.split('/')[3]} |
);
};
onHighlightItem(locationId) {
this.setState({ highlightedItem: locationId });
}
render() {
const { loading, locations, filter, error } = this.props;
if (error) {
return {error}
;
}
const loadingIcon = (
);
if (loading) {
return loadingIcon;
}
const body = (
{locations.filter(location => (location.name.split('/')[3].toLowerCase().includes(filter.toLowerCase()) || filter=="")).map(this.renderTableRow)}
);
return (
| {this.props.t('Location')} |
{locations && body}
);
}
}
export default withTranslation('Common')(LocationsList);