UNPKG

@sanity/scheduled-publishing

Version:

> [!IMPORTANT] > As of [v3.39.0](https://www.sanity.io/changelog/e6013ee5-8214-4e03-9593-f7b19124b8a3) of Sanity Studio, this plugin has been deprecated and the Scheduled Publishing functionality has been moved into the core studio package. > Read more an

23 lines (19 loc) 722 B
import {Schedule} from '../types' import {useMemo} from 'react' import {SchemaType, useSchema} from 'sanity' import {getScheduledDocument} from '../utils/paneItemHelpers' export function useScheduleSchemaType(schedule: Schedule): SchemaType | undefined { const firstDocument = getScheduledDocument(schedule) const schema = useSchema() const schemaName = firstDocument.documentType return useMemo(() => { if (!schemaName) { return undefined } return schema.get(schemaName) as SchemaType }, [schemaName, schema]) } export function useSchemaType(schemaName: string): SchemaType { const schema = useSchema() return useMemo(() => schema.get(schemaName) as SchemaType, [schemaName, schema]) }