import { styled, Typography, useTheme } from '@mui/material'; import Add from '@mui/icons-material/Add'; import { CREATE_FEATURE } from 'component/providers/AccessProvider/permissions'; import { FlagCreationButton } from '../ProjectFeatureTogglesHeader/ProjectFeatureTogglesHeader'; import ResponsiveButton from 'component/common/ResponsiveButton/ResponsiveButton'; import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview'; import { useFeature } from 'hooks/api/getters/useFeature/useFeature'; import { getFeatureTypeIcons } from 'utils/getFeatureTypeIcons'; import { Link } from 'react-router-dom'; import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip'; import useFeatureTypes from 'hooks/api/getters/useFeatureTypes/useFeatureTypes'; interface IWelcomeToProjectProps { projectId: string; setConnectSdkOpen: (open: boolean) => void; } interface IExistingFlagsProps { featureId: string; projectId: string; } const Container = styled('div')(({ theme }) => ({ display: 'flex', flexDirection: 'column', backgroundColor: theme.palette.background.paper, flexBasis: '70%', borderRadius: theme.shape.borderRadiusLarge, })); const TitleBox = styled('div')(({ theme }) => ({ padding: theme.spacing(2, 7, 2, 7), borderBottom: '1px solid', borderColor: theme.palette.divider, })); const Actions = styled('div')(({ theme }) => ({ display: 'flex', flexGrow: 1, })); const ActionBox = styled('div')(({ theme }) => ({ flexBasis: '50%', padding: theme.spacing(3, 2, 6, 8), display: 'flex', gap: theme.spacing(3), flexDirection: 'column', })); const TitleContainer = styled('div')(({ theme }) => ({ display: 'flex', flexDirection: 'row', gap: theme.spacing(2), alignItems: 'center', fontSize: theme.spacing(1.75), fontWeight: 'bold', })); const NeutralCircleContainer = styled('span')(({ theme }) => ({ width: '28px', height: '28px', display: 'flex', alignItems: 'center', justifyContent: 'center', backgroundColor: theme.palette.neutral.border, borderRadius: '50%', })); const MainCircleContainer = styled(NeutralCircleContainer)(({ theme }) => ({ backgroundColor: theme.palette.primary.main, color: theme.palette.background.paper, })); const TypeCircleContainer = styled(MainCircleContainer)(({ theme }) => ({ borderRadius: '20%', })); const StyledLink = styled(Link)({ fontWeight: 'bold', textDecoration: 'none', display: 'flex', justifyContent: 'center', }); export const WelcomeToProject = ({ projectId, setConnectSdkOpen, }: IWelcomeToProjectProps) => { const { project } = useProjectOverview(projectId); const isFirstFlagCreated = project.onboardingStatus.status === 'first-flag-created'; return ( Welcome to your project Complete the steps below to start working with this project {project.onboardingStatus.status === 'first-flag-created' ? ( ) : ( )} 2 Connect an SDK We have not detected any connected SDKs on this project. { setConnectSdkOpen(true); }} maxWidth='200px' projectId={projectId} Icon={Add} disabled={!isFirstFlagCreated} permission={CREATE_FEATURE} > Connect SDK ); }; const CreateFlag = () => { return ( <> 1 Create a feature flag The project currently holds no feature toggles. Create a feature flag to get started. > ); }; const ExistingFlag = ({ featureId, projectId }: IExistingFlagsProps) => { const theme = useTheme(); const { feature } = useFeature(projectId, featureId); const { featureTypes } = useFeatureTypes(); const IconComponent = getFeatureTypeIcons(feature.type); const typeName = featureTypes.find( (featureType) => featureType.id === feature.type, )?.name; const typeTitle = `${typeName || feature.type} flag`; return ( <> ✓ Create a feature flag {feature.name} Your project is not yet connected to any SDK. In order to start using your feature flag connect an SDK to the project. > ); };