import { VFC } from 'react'; import { Box, styled } from '@mui/material'; import { ArrayParam, withDefault } from 'use-query-params'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { usePersistentTableState } from 'hooks/usePersistentTableState'; import { allOption, ProjectSelect, } from 'component/common/ProjectSelect/ProjectSelect'; import { useExecutiveDashboard } from 'hooks/api/getters/useExecutiveSummary/useExecutiveSummary'; import { useFilteredFlagsSummary } from './hooks/useFilteredFlagsSummary'; import { useFilteredTrends } from './hooks/useFilteredTrends'; import { Widget } from './components/Widget/Widget'; import { DashboardHeader } from './components/DashboardHeader/DashboardHeader'; import { UserStats } from './componentsStat/UserStats/UserStats'; import { FlagStats } from './componentsStat/FlagStats/FlagStats'; import { HealthStats } from './componentsStat/HealthStats/HealthStats'; import { UsersChart } from './componentsChart/UsersChart/UsersChart'; import { FlagsChart } from './componentsChart/FlagsChart/FlagsChart'; import { FlagsProjectChart } from './componentsChart/FlagsProjectChart/FlagsProjectChart'; import { ProjectHealthChart } from './componentsChart/ProjectHealthChart/ProjectHealthChart'; import { MetricsSummaryChart } from './componentsChart/MetricsSummaryChart/MetricsSummaryChart'; import { UsersPerProjectChart } from './componentsChart/UsersPerProjectChart/UsersPerProjectChart'; const StyledGrid = styled(Box)(({ theme }) => ({ display: 'grid', gridTemplateColumns: `repeat(2, 1fr)`, gridAutoRows: 'auto', gap: theme.spacing(2), paddingBottom: theme.spacing(2), [theme.breakpoints.up('md')]: { gridTemplateColumns: `300px 1fr`, }, })); const ChartWidget = styled(Widget)(({ theme }) => ({ [theme.breakpoints.down('md')]: { gridColumnStart: 'span 2', order: 2, }, })); export const ExecutiveDashboard: VFC = () => { const { executiveDashboardData, loading, error } = useExecutiveDashboard(); const stateConfig = { projects: withDefault(ArrayParam, [allOption.id]), }; const [state, setState] = usePersistentTableState('insights', stateConfig); const setProjects = (projects: string[]) => { setState({ projects }); }; const projects = state.projects ? (state.projects.filter(Boolean) as string[]) : []; const showAllProjects = projects[0] === allOption.id; const projectsData = useFilteredTrends( executiveDashboardData.projectFlagTrends, projects, ); const metricsData = useFilteredTrends( executiveDashboardData.metricsSummaryTrends, projects, ); const { users } = executiveDashboardData; const summary = useFilteredFlagsSummary(projectsData); const isOneProjectSelected = projects.length === 1; return ( <> ({ paddingBottom: theme.spacing(4) })}> } /> } elseShow={ } /> } elseShow={ } /> } elseShow={ } /> {/* */} ); };