import { useState } from "react"; import { Link } from "react-router-dom"; import { PROJECTS_FETCH_LIMIT } from "../../constants"; import { IProject } from "../../types"; import Spinner from "../../components/global/Spinner"; import PreviewBlock from "./PreviewBlock"; import { useProjects } from "../../hooks/useProjects"; const Projects = () => { const [limit] = useState(PROJECTS_FETCH_LIMIT); const [offset, setOffset] = useState(0); const { isLoading, isError, error, data, isFetching, isPreviousData } = useProjects(limit, offset); return ( <>

Projects

New
{isFetching && (
)} {!isFetching && ( <>
{error && (

Something went wrong...

)}
{data.results.length > 0 && data.results.map((project: IProject) => { return (
); })}
{data.results.length === 0 && (

Nothing here

Get started by creating a project.

)}
{data.count > PROJECTS_FETCH_LIMIT && (
)} )}
); }; export default Projects;