import type { ComponentType, ReactNode } from 'react'; import { Link } from 'react-router-dom'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { ProjectCard as DefaultProjectCard } from '../ProjectCard/ProjectCard'; import type { ProjectSchema } from 'openapi'; import loadingData from './loadingData'; import { TablePlaceholder } from 'component/common/Table'; import { styled } from '@mui/material'; import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext'; import { UpgradeProjectCard } from '../ProjectCard/UpgradeProjectCard'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; const StyledGridContainer = styled('div')(({ theme }) => ({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))', gap: theme.spacing(2), })); const StyledCardLink = styled(Link)(({ theme }) => ({ color: 'inherit', textDecoration: 'none', border: 'none', padding: '0', background: 'transparent', fontFamily: theme.typography.fontFamily, pointer: 'cursor', })); type ProjectGroupProps = { sectionTitle?: string; sectionSubtitle?: string; HeaderActions?: ReactNode; projects: ProjectSchema[]; loading: boolean; placeholder?: string; ProjectCardComponent?: ComponentType; link?: boolean; }; export const ProjectGroup = ({ projects, loading, placeholder = 'No projects available.', ProjectCardComponent, link = true, }: ProjectGroupProps) => { const ProjectCard = ProjectCardComponent ?? DefaultProjectCard; const { isOss } = useUiConfig(); const { searchQuery } = useSearchHighlightContext(); return ( <> 0} show={ No projects found matching “ {searchQuery} ” } elseShow={ {placeholder} } /> } elseShow={ ( <> {loadingData.map( (project: ProjectSchema) => ( ), )} )} elseShow={() => ( <> {projects.map((project) => link ? ( ) : ( ), )} )} /> {isOss() ? : null} } /> ); };