(props: IProps)
| 40 | const SPECIAL_PREDICATE = ['<', '<=', '>', '>=']; |
| 41 | |
| 42 | const RuleContent = (props: IProps) => { |
| 43 | const { |
| 44 | rule, |
| 45 | disabled, |
| 46 | ruleIndex, |
| 47 | // useSegment, |
| 48 | subjectOptions, |
| 49 | conditionIndex, |
| 50 | condition, |
| 51 | ruleContainer, |
| 52 | segmentContainer, |
| 53 | hooksFormContainer, |
| 54 | } = props; |
| 55 | |
| 56 | const intl = useIntl(); |
| 57 | const [ options, setOption ] = useState<IOption[]>([]); |
| 58 | const [ popupOpen, setPopupOpen ] = useState<boolean>(false); |
| 59 | const segmentList: ISegmentList = segmentContainer?.useContainer().segmentList; |
| 60 | |
| 61 | useEffect(() => { |
| 62 | const handler = () => { |
| 63 | if (popupOpen) { |
| 64 | setPopupOpen(false); |
| 65 | } |
| 66 | }; |
| 67 | window.addEventListener('click', handler); |
| 68 | |
| 69 | return () => window.removeEventListener('click', handler); |
| 70 | }, [popupOpen]); |
| 71 | |
| 72 | const { |
| 73 | handleChangeAttr, |
| 74 | handleChangeOperator, |
| 75 | handleChangeDateTime, |
| 76 | handleChangeTimeZone, |
| 77 | handleChangeValue, |
| 78 | handleDeleteCondition, |
| 79 | handleChangeRightValue, |
| 80 | handleChangePredict, |
| 81 | handleChangeRightPredict, |
| 82 | } = ruleContainer.useContainer(); |
| 83 | |
| 84 | const { |
| 85 | formState: { errors }, |
| 86 | register, |
| 87 | unregister, |
| 88 | setValue, |
| 89 | trigger, |
| 90 | getValues, |
| 91 | clearErrors, |
| 92 | setError, |
| 93 | } = hooksFormContainer.useContainer(); |
| 94 | |
| 95 | const handleDelete = useCallback(async (ruleIndex: number, conditionIndex: number, ruleId?: string) => { |
| 96 | for(const key in getValues()) { |
| 97 | if (key.startsWith(`rule_${ruleId}_condition`)) { |
| 98 | unregister(key); |
| 99 | clearErrors(key); |
nothing calls this directly
no test coverage detected