Files
supabase/apps/studio/data/content/notebooks/notebooks-infinite-query.ts
Joshen Lim 2893c783d5 Hook up APIs for Notebooks CRUD (#49254)
## Context

API changes are ready so hooking up the endpoints for full CRUD UX E2E
- Can create notebooks
- Can load notebooks
- Can delete notebooks
- Can update notebooks
2026-08-20 22:23:20 +08:00

44 lines
1.1 KiB
TypeScript

import { type InfiniteData } from '@tanstack/react-query'
import { ContentData, ContentError, useContentInfiniteQuery } from '../content-infinite-query'
import type { ContentOfType } from '../content-query'
import type { UseCustomInfiniteQueryOptions } from '@/types'
export type NotebookRow = ContentOfType<'notebook'>
export interface NotebooksVariables {
projectRef?: string
name?: string
limit?: number
sort?: 'name' | 'inserted_at'
}
export interface NotebooksPage {
cursor: string | undefined
content: NotebookRow[]
}
export const useNotebooksInfiniteQuery = (
{ projectRef, name, limit, sort }: NotebooksVariables,
options: Omit<
UseCustomInfiniteQueryOptions<
ContentData,
ContentError,
InfiniteData<NotebooksPage>,
ReadonlyArray<unknown>,
string | undefined
>,
'select'
> = {}
) =>
useContentInfiniteQuery<NotebooksPage>(
{ projectRef, type: 'notebook', name, limit, sort },
{
...options,
select: (data) => ({
...data,
pages: data.pages.map((page) => ({ ...page, content: page.content as NotebookRow[] })),
}),
}
)