Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 4x 9x 9x 9x 9x 9x | import { useAppSelector } from '@/store/hooks.ts';
import { PROJECT_STATE } from '@/shared/constants';
import { useDelayedSkeleton } from '@/shared/lib/hooks';
import { useFetchProjectsOnMount } from '@/features/project-list/model';
import { projectsSelectors } from '@/entities/project/model/selectors';
import {
ProjectListCardsView,
ProjectListEmptyView,
ProjectListSkeletonView,
} from './views';
export const ProjectList = () => {
const projects = useAppSelector(projectsSelectors.selectAll);
const loading = useAppSelector(projectsSelectors.selectLoading);
useFetchProjectsOnMount(projects.length);
const showSkeletons = useDelayedSkeleton(loading === PROJECT_STATE.PENDING);
const isEmpty =
projects.length === 0 &&
(loading === PROJECT_STATE.IDLE || loading === PROJECT_STATE.SUCCEEDED);
if (showSkeletons) return <ProjectListSkeletonView />;
if (isEmpty) return <ProjectListEmptyView />;
return <ProjectListCardsView projects={projects} />;
};
|