import { GridSectionsState } from './GridSectionsState'; import { FiltersMap } from '@wix/bex-core'; import { observer } from 'mobx-react-lite'; import { GridSectionAndRepeater } from './GridSectionAndRepeater'; import React, { useEffect, useState } from 'react'; import { GridContentBaseProps } from '../Grid/GridContent'; import { GridState } from '../../state'; import { runInAction } from 'mobx'; import { Box } from '@wix/design-system'; import { GridSectionsSingleSkeletonGrid } from './GridSectionsSingleSkeletonGrid'; import type { GroupBy, RenderSection } from '../CollectionSectionHeader'; export interface GridSectionsContentProps extends GridContentBaseProps { state: GridState; groupBy: GroupBy; renderSection?: RenderSection; } function _GridSectionsContent( props: GridSectionsContentProps, ) { const { state: grid, groupBy, renderSection, layoutType } = props; const { toolbar } = grid; const { showInitialLoader, multi: { showRefreshLoader }, } = toolbar; const [state] = useState( () => (grid._sections ??= new GridSectionsState({ toolbar: grid.toolbar, collection: grid.collection, groupBy, renderSection, parentState: grid, })), ); const { sections } = state; useEffect(() => { runInAction(() => { state.groupBy = groupBy; if (renderSection) { state.renderSection = renderSection; } }); }, [groupBy, renderSection]); let child; if (!sections.length || showInitialLoader || showRefreshLoader) { child = ( ); } else { child = ( <> {sections.map((sectionDescriptor) => ( ))} ); } return ( {child} ); } export const GridSectionsContent = observer(_GridSectionsContent);