sanity
Version:
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches
14 lines (10 loc) • 604 B
text/typescript
import {useState} from 'react'
import {type Schedule, type ScheduledDocValidations, type ValidationStatus} from '../types'
const EMPTY_VALIDATIONS: ScheduledDocValidations = {}
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function useValidations() {
const [validations, setValidations] = useState<ScheduledDocValidations>(EMPTY_VALIDATIONS)
const updateValidation = (s: Schedule, vs: ValidationStatus) =>
setValidations((current) => ({...current, [s.id]: vs}))
return [validations, updateValidation] as [typeof validations, typeof updateValidation]
}