import React from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; // services import pagesService from "services/pages.service"; // components import { PagesView } from "components/pages"; // ui import { Loader } from "components/ui"; // helpers import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper"; // types import { TPagesListProps } from "./types"; import { RecentPagesResponse } from "types"; // fetch-keys import { RECENT_PAGES_LIST } from "constants/fetch-keys"; export const RecentPagesList: React.FC = ({ viewType }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; const { data: pages } = useSWR( workspaceSlug && projectId ? RECENT_PAGES_LIST(projectId as string) : null, workspaceSlug && projectId ? () => pagesService.getRecentPages(workspaceSlug as string, projectId as string) : null ); return ( <> {pages ? ( Object.keys(pages).length > 0 ? (
{Object.keys(pages).map((key) => { if (pages[key].length === 0) return null; return (

{replaceUnderscoreIfSnakeCase(key)}

); })}
) : (

No issues found

) ) : ( )} ); };