import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser'; import { Box, Grid, IconButton, Link, List, ListItem, ListItemButton, styled, Typography, } from '@mui/material'; import type { Theme } from '@mui/material/styles/createTheme'; import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon'; import { type FC, useEffect, useState } from 'react'; import { useProfile } from 'hooks/api/getters/useProfile/useProfile'; import LinkIcon from '@mui/icons-material/Link'; import { Badge } from '../common/Badge/Badge'; import { ConnectSDK, CreateFlag } from './ConnectSDK'; import { PlaceholderFlagMetricsChart } from './FlagMetricsChart'; const ScreenExplanation = styled(Typography)(({ theme }) => ({ marginTop: theme.spacing(1), marginBottom: theme.spacing(8), maxWidth: theme.spacing(45), })); const StyledHeaderTitle = styled(Typography)(({ theme }) => ({ fontSize: theme.typography.h2.fontSize, fontWeight: 'normal', marginBottom: theme.spacing(2), })); const ContentGrid = styled(Grid)(({ theme }) => ({ backgroundColor: theme.palette.background.paper, borderRadius: `${theme.shape.borderRadiusLarge}px`, })); const ProjectBox = styled(Box)(({ theme }) => ({ display: 'flex', gap: theme.spacing(2), alignItems: 'center', width: '100%', })); const projectStyle = (theme: Theme) => ({ borderRadius: theme.spacing(0.5), borderLeft: `${theme.spacing(0.5)} solid transparent`, '&.Mui-selected': { borderLeft: `${theme.spacing(0.5)} solid ${theme.palette.primary.main}`, }, display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: theme.spacing(1), }); export const StyledCardTitle = styled('div')<{ lines?: number }>( ({ theme, lines = 2 }) => ({ fontWeight: theme.typography.fontWeightRegular, fontSize: theme.typography.body1.fontSize, lineClamp: `${lines}`, WebkitLineClamp: lines, lineHeight: '1.2', display: '-webkit-box', boxOrient: 'vertical', textOverflow: 'ellipsis', overflow: 'hidden', alignItems: 'flex-start', WebkitBoxOrient: 'vertical', wordBreak: 'break-word', }), ); const ActiveProjectDetails: FC<{ project: { flags: number; members: number; health: number }; }> = ({ project }) => { return ( {project.flags} flags {project.members} members {project.health}% health ); }; const SpacedGridItem = styled(Grid)(({ theme }) => ({ padding: theme.spacing(4), border: `0.5px solid ${theme.palette.divider}`, })); const useProjects = () => { const myProjects = useProfile().profile?.projects || []; // TODO: add real data for flags/members/health const projects = myProjects.map((project) => ({ name: project, flags: 0, members: 1, health: 100, })); const [activeProject, setActiveProject] = useState(projects[0]?.name); useEffect(() => { if (!activeProject && projects.length > 0) { setActiveProject(projects[0].name); } }, [JSON.stringify(projects)]); return { projects, activeProject, setActiveProject }; }; export const PersonalDashboard = () => { const { user } = useAuthUser(); const name = user?.name; const { projects, activeProject, setActiveProject } = useProjects(); return (
Welcome {name} Here are some tasks we think would be useful in order to get the most of Unleash Your resources My projects Setup incomplete {projects.map((project) => { return ( setActiveProject(project.name) } > {project.name} {project.name === activeProject ? ( ) : null} ); })} {activeProject ? ( ) : null} {activeProject ? ( ) : null} Your roles in this project:{' '} Member{' '} Another My feature flags You have not created or favorited any feature flags. Once you do, the will show up here. Feature flag metrics
); };