import { Col, Result, Row } from "antd"; import { LargeArrowBack } from "./Icons/LargeArrowBack"; import { MoodCreateModal } from "../Pages/Mood/MoodCreate"; import { NLView } from "../types"; import { ReactElement, useEffect } from "react"; import { Spin } from "./Spin"; import { useAppState } from "../overmind"; import Title from "../Pages/Explore/Title"; import useVisibility from "../hooks/useVisibility"; export type ItemGridParams = { title?: string; titleLink?: string; items?: any[]; limit?: number; render: (item: object, index: number) => ReactElement; loadMore?: () => void; setSelectedFolder?: React.Dispatch>; selectedFolder?: boolean; noEmptyResults?: boolean; gridRow?: number; wrapAt?: number; deeplikeActions?: boolean; deepLikeContainer?: React.MutableRefObject; }; export const ItemGrid: NLView> = ({ items, render, title, titleLink, loadMore, limit, noEmptyResults, wrapAt, deeplikeActions, deepLikeContainer, gridRow, }) => { const [isVisible, currentElement] = useVisibility(200); const state = useAppState(); useEffect(() => { loadMore && loadMore(); }, [isVisible]); items = items && limit ? items.slice(0, limit) : items ? items.slice(0, items.length) : []; const tagsInSources = items .filter(Boolean) .map((p) => (p.tags || [])?.map((t) => t.value)) .reduce((r, c) => [...r, ...c], []); if (state.indicators.isWorking === false && !items.length) return noEmptyResults ? <> : }>nothing here; return ( <> {items.length ? ( {items.map((item, index) => ( {render(item, index)} ))} ) : ( "" )}
{state.indicators.isWorking === true && loadMore ? : ""}
); }; { /* } /> */ }