import {
Box,
IconButton,
Link,
List,
ListItem,
ListItemButton,
Typography,
} from '@mui/material';
import { Badge } from '../common/Badge/Badge';
import { ProjectIcon } from '../common/ProjectIcon/ProjectIcon';
import LinkIcon from '@mui/icons-material/ArrowForward';
import { ProjectSetupComplete } from './ProjectSetupComplete';
import { ConnectSDK, CreateFlag, ExistingFlag } from './ConnectSDK';
import { LatestProjectEvents } from './LatestProjectEvents';
import { RoleAndOwnerInfo } from './RoleAndOwnerInfo';
import { forwardRef, useEffect, useRef, type FC } from 'react';
import { StyledCardTitle } from './PersonalDashboard';
import type {
PersonalDashboardProjectDetailsSchema,
PersonalDashboardSchemaAdminsItem,
PersonalDashboardSchemaProjectsItem,
} from '../../openapi';
import {
ContentGridContainer,
EmptyGridItem,
ListItemBox,
listItemStyle,
ProjectGrid,
GridItem,
SpacedGridItem,
} from './Grid';
import { ContactAdmins, DataError } from './ProjectDetailsError';
const ActiveProjectDetails: FC<{
project: PersonalDashboardSchemaProjectsItem;
}> = ({ project }) => {
return (
{project.featureCount}
flags
{project.memberCount}
members
{project.health}%
health
);
};
const ProjectListItem: FC<{
project: PersonalDashboardSchemaProjectsItem;
selected: boolean;
onClick: () => void;
}> = ({ project, selected, onClick }) => {
const activeProjectRef = useRef(null);
useEffect(() => {
if (activeProjectRef.current) {
activeProjectRef.current.scrollIntoView({
block: 'nearest',
inline: 'start',
});
}
}, []);
return (
{project.name}
{selected ? : null}
);
};
export const MyProjects = forwardRef<
HTMLDivElement,
{
projects: PersonalDashboardSchemaProjectsItem[];
personalDashboardProjectDetails?: PersonalDashboardProjectDetailsSchema;
activeProject: string;
setActiveProject: (project: string) => void;
admins: PersonalDashboardSchemaAdminsItem[];
}
>(
(
{
projects,
personalDashboardProjectDetails,
setActiveProject,
activeProject,
admins,
},
ref,
) => {
const activeProjectStage =
personalDashboardProjectDetails?.onboardingStatus.status ??
'loading';
const setupIncomplete =
activeProjectStage === 'onboarding-started' ||
activeProjectStage === 'first-flag-created';
const error = personalDashboardProjectDetails === undefined;
const box1Content = () => {
if (error) {
return ;
}
if (
activeProjectStage === 'onboarded' &&
personalDashboardProjectDetails
) {
return (
);
} else if (
activeProjectStage === 'onboarding-started' ||
activeProjectStage === 'loading'
) {
return ;
} else if (activeProjectStage === 'first-flag-created') {
return ;
}
};
const box2Content = () => {
if (error) {
return ;
}
if (
activeProjectStage === 'onboarded' &&
personalDashboardProjectDetails
) {
return (
);
}
if (setupIncomplete || activeProjectStage === 'loading') {
return ;
}
};
return (
My projects
{setupIncomplete ? (
Setup incomplete
) : null}
{error ? (
Setup state unknown
) : null}
{projects.map((project) => (
setActiveProject(project.id)}
/>
))}
{box1Content()}
{box2Content()}
role.name,
) ?? []
}
owners={
personalDashboardProjectDetails?.owners ?? [
{ ownerType: 'user', name: '?' },
]
}
/>
);
},
);