import { useParams } from 'common' import dayjs from 'dayjs' import { NotebookText, Plus } from 'lucide-react' import { AiIconAnimation, Badge, Button } from 'ui' import { Row } from 'ui-patterns/Row' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { HomeCard } from './HomeCard' import { useAnalyzeNotebook, useCreateNotebook } from '@/components/interfaces/Explorer/hooks' import { AlertError } from '@/components/ui/AlertError' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import { useNotebooksInfiniteQuery, type NotebookRow, } from '@/data/content/notebooks/notebooks-infinite-query' const MAX_HOMEPAGE_NOTEBOOKS = 4 export const NotebooksSection = () => { const { ref: projectRef } = useParams() const { createNotebook } = useCreateNotebook() const { data, error, isPending, isError, isSuccess, refetch } = useNotebooksInfiniteQuery({ projectRef, limit: MAX_HOMEPAGE_NOTEBOOKS, sort: 'inserted_at', }) // The content endpoint can return more rows than `limit`, so cap the row here too const notebooks = (data?.pages[0]?.content ?? []).slice(0, MAX_HOMEPAGE_NOTEBOOKS) return (
Save queries and notes together to revisit and share
} onClick={onCreateNotebook}> Create your first notebook