import { useState } from 'react'; import { EntityPageState, EntityPageStateParams } from '../state'; import { useWixPatternsContainer } from '@wix/bex-core/react'; import { FieldValues } from 'react-hook-form'; import { useWixPatternsRouter } from '../providers/WixPatternsRouterProvider'; export type UseEntityPageParams = Pick< EntityPageStateParams, | 'fetch' | 'onSave' | 'saveSuccessToast' | 'saveErrorToast' | 'form' | 'parentPageId' | 'parentPath' | 'schemaSource' >; export function useEntityPage( props: UseEntityPageParams, ): EntityPageState { const container = useWixPatternsContainer(); const routerState = useWixPatternsRouter(); const [state] = useState(() => { return new EntityPageState({ container, routerState, ...props }); }); return state; }