import { useEffect , useState } from 'react' ; type Capabilities = any ; export interface UseGetUserAlertsPermissionsProps { crud : boolean ; read : boolean ; loading : boolean ; } export const useGetUserAlertsPermissions = ( uiCapabilities , featureId ) : UseGetUserAlertsPermissionsProps => { const [ alertsPermissions , setAlertsPermissions ] = useState < UseGetUserAlertsPermissionsProps > ( { crud : false , read : false , loading : true , } ) ; useEffect ( ( ) => { const capabilitiesCanUserCRUD = typeof uiCapabilities [ featureId ] . crud_alerts === 'boolean' ? uiCapabilities [ featureId ] . crud_alerts : false ; const capabilitiesCanUserRead = typeof uiCapabilities [ featureId ] . read_alerts === 'boolean' ? uiCapabilities [ featureId ] . read_alerts : false ; setAlertsPermissions ( { crud : capabilitiesCanUserCRUD , read : capabilitiesCanUserRead , loading : false , } ) ; } , [ featureId , uiCapabilities ] ) ; return alertsPermissions ; } ;