import { MonitorRule } from '@/services/data/data-quality/rule-types' ; import { DropdownOption } from '@/widgets/basic/types' ; import { useForceUpdate } from '@/widgets/basic/utils' ; import { useRulesEventBus } from './rules-event-bus' ; import { RulesEventTypes } from './rules-event-bus-types' ; export const useEnabledAndSeverity = ( rules ) => { const { fire } = useRulesEventBus ( ) ; const forceUpdate = useForceUpdate ( ) ; const onEnabledChanged = ( rule ) => ( value ) => { rule . enabled = value ; if ( ! rules . includes ( rule ) ) { rules . push ( rule ) ; } fire ( RulesEventTypes . RULE_CHANGED , rule ) ; forceUpdate ( ) ; } ; const onSeverityChanged = ( rule ) => ( option ) => { rule . severity = option . value ; if ( ! rules . includes ( rule ) ) { rules . push ( rule ) ; } fire ( RulesEventTypes . RULE_CHANGED , rule ) ; forceUpdate ( ) ; } ; return { onEnabledChanged , onSeverityChanged } ; } ;