import { Select, Typography } from 'antd'; import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder'; import { useAppContext } from 'providers/App/App'; import { useMemo } from 'react'; import { useCreateAlertState } from '../context'; import { ANOMALY_ALGORITHM_OPTIONS, ANOMALY_SEASONALITY_OPTIONS, ANOMALY_THRESHOLD_MATCH_TYPE_OPTIONS, ANOMALY_THRESHOLD_OPERATOR_OPTIONS, ANOMALY_TIME_DURATION_OPTIONS, } from '../context/constants'; import { AnomalyAndThresholdProps } from './types'; import { getQueryNames, NotificationChannelsNotFoundContent, RoutingPolicyBanner, } from './utils'; function AnomalyThreshold({ channels, isLoadingChannels, isErrorChannels, refreshChannels, }: AnomalyAndThresholdProps): JSX.Element { const { user } = useAppContext(); const { thresholdState, setThresholdState, notificationSettings, setNotificationSettings, } = useCreateAlertState(); const { currentQuery } = useQueryBuilder(); const queryNames = getQueryNames(currentQuery); const deviationOptions = useMemo(() => { const options = []; for (let i = 1; i <= 7; i++) { options.push({ label: i.toString(), value: i }); } return options; }, []); const updateThreshold = ( id: string, field: string, value: string | string[], ): void => { setThresholdState({ type: 'SET_THRESHOLDS', payload: thresholdState.thresholds.map((t) => t.id === id ? { ...t, [field]: value } : t, ), }); }; return (