2021-10-01 13:49:18 +02:00
|
|
|
import { capitalize, IconButton } from '@material-ui/core';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { useParams } from 'react-router-dom';
|
2021-10-08 11:23:29 +02:00
|
|
|
import { Link } from 'react-router-dom';
|
2021-10-01 13:49:18 +02:00
|
|
|
import useFeature from '../../../../../hooks/api/getters/useFeature/useFeature';
|
|
|
|
import { getFeatureTypeIcons } from '../../../../../utils/get-feature-type-icons';
|
|
|
|
import ConditionallyRender from '../../../../common/ConditionallyRender';
|
2021-10-08 11:23:29 +02:00
|
|
|
import { useStyles } from './FeatureOverviewMetadata.styles';
|
2021-10-01 13:49:18 +02:00
|
|
|
|
|
|
|
import { Edit } from '@material-ui/icons';
|
|
|
|
import { IFeatureViewParams } from '../../../../../interfaces/params';
|
|
|
|
|
2021-10-08 11:23:29 +02:00
|
|
|
const FeatureOverviewMetaData = () => {
|
2021-10-01 13:49:18 +02:00
|
|
|
const styles = useStyles();
|
|
|
|
const { projectId, featureId } = useParams<IFeatureViewParams>();
|
|
|
|
|
|
|
|
const { feature } = useFeature(projectId, featureId);
|
|
|
|
|
|
|
|
const { project, description, type } = feature;
|
|
|
|
|
|
|
|
const IconComponent = getFeatureTypeIcons(type);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classnames(styles.container)}>
|
|
|
|
<div className={styles.metaDataHeader}>
|
|
|
|
<IconComponent className={styles.headerIcon} />{' '}
|
|
|
|
<h3 className={styles.header}>
|
|
|
|
{capitalize(type || '')} toggle
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
<div className={styles.body}>
|
|
|
|
<span className={styles.bodyItem}>Project: {project}</span>
|
|
|
|
<ConditionallyRender
|
2021-10-08 11:23:29 +02:00
|
|
|
condition={description}
|
2021-10-01 13:49:18 +02:00
|
|
|
show={
|
|
|
|
<span className={styles.bodyItem}>
|
|
|
|
<div>Description:</div>
|
|
|
|
<div className={styles.descriptionContainer}>
|
|
|
|
<p>{description}</p>
|
2021-10-08 11:23:29 +02:00
|
|
|
<IconButton
|
|
|
|
component={Link}
|
|
|
|
to={`/projects/${projectId}/features2/${featureId}/settings`}
|
|
|
|
>
|
2021-10-01 13:49:18 +02:00
|
|
|
<Edit />
|
|
|
|
</IconButton>
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
elseShow={
|
|
|
|
<span>
|
2021-10-08 11:23:29 +02:00
|
|
|
<div className={styles.descriptionContainer}>
|
|
|
|
No description.{' '}
|
|
|
|
<IconButton
|
|
|
|
component={Link}
|
|
|
|
to={`/projects/${projectId}/features2/${featureId}/settings`}
|
|
|
|
>
|
|
|
|
<Edit />
|
|
|
|
</IconButton>
|
|
|
|
</div>
|
2021-10-01 13:49:18 +02:00
|
|
|
</span>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-10-08 11:23:29 +02:00
|
|
|
export default FeatureOverviewMetaData;
|