import { Alert, styled } from '@mui/material'; import { formatEditStrategyPath } from 'component/feature/FeatureStrategy/FeatureStrategyEdit/FeatureStrategyEdit'; import { IProjectCard } from 'interfaces/project'; import { IFeatureStrategy } from 'interfaces/strategy'; import { Link } from 'react-router-dom'; import { formatStrategyName } from 'utils/strategyNames'; const StyledUl = styled('ul')(({ theme }) => ({ listStyle: 'none', paddingLeft: 0, })); const StyledAlert = styled(Alert)(({ theme }) => ({ marginTop: theme.spacing(1), })); interface ISegmentProjectAlertProps { projects: IProjectCard[]; strategies: IFeatureStrategy[]; projectsUsed: string[]; availableProjects: IProjectCard[]; } export const SegmentProjectAlert = ({ projects, strategies, projectsUsed, availableProjects, }: ISegmentProjectAlertProps) => { const projectList = ( {Array.from(projectsUsed).map(projectId => (
  • {projects.find(({ id }) => id === projectId)?.name ?? projectId}
  • ))}
    ); if (projectsUsed.length > 1) { return ( You can't specify a project for this segment because it is used in multiple projects: {projectList} ); } if (availableProjects.length === 1) { return ( You can't specify a project other than{' '} {availableProjects[0].name} for this segment because it is used here: {projectList} ); } return null; }; const formatStrategyNameParens = (strategy: IFeatureStrategy): string => { if (!strategy.strategyName) { return ''; } return `(${formatStrategyName(strategy.strategyName)})`; };