import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { Link, useHistory } from 'react-router-dom'; import useMediaQuery from '@material-ui/core/useMediaQuery'; import { List, ListItem, ListItemAvatar, IconButton, Icon, ListItemText, Button, Tooltip } from '@material-ui/core'; import { CREATE_STRATEGY, DELETE_STRATEGY } from '../../../permissions'; import ConditionallyRender from '../../common/ConditionallyRender/ConditionallyRender'; import PageContent from '../../common/PageContent/PageContent'; import HeaderTitle from '../../common/HeaderTitle'; import { useStyles } from './styles'; const StrategiesList = ({ strategies, fetchStrategies, removeStrategy, deprecateStrategy, reactivateStrategy, hasPermission, }) => { const history = useHistory(); const styles = useStyles(); const smallScreen = useMediaQuery('(max-width:700px)'); useEffect(() => { fetchStrategies(); }, []); const headerButton = () => ( history.push('/strategies/create')}> add } elseShow={ } /> } /> ); const strategyLink = ({ name, deprecated }) => ( {name} (Deprecated)} /> ); const reactivateButton = strategy => ( reactivateStrategy(strategy)}> visibility ); const deprecateButton = strategy => (
visibility_off
} elseShow={
deprecateStrategy(strategy)}> visibility_off
} /> ); const deleteButton = strategy => ( removeStrategy(strategy)}> delete } elseShow={
delete
} /> ); const strategyList = () => strategies.map(strategy => ( extension )); return ( }> 0} show={strategyList()} elseShow={No strategies found} /> ); }; StrategiesList.propTypes = { strategies: PropTypes.array.isRequired, fetchStrategies: PropTypes.func.isRequired, removeStrategy: PropTypes.func.isRequired, deprecateStrategy: PropTypes.func.isRequired, reactivateStrategy: PropTypes.func.isRequired, history: PropTypes.object.isRequired, hasPermission: PropTypes.func.isRequired, name: PropTypes.string, deprecated: PropTypes.bool, }; export default StrategiesList;