import React, { useRef, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import SnapSettingsCard from '../../../../components/app/flask/snap-settings-card'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import { JustifyContent, AlignItems, Color, TEXT_ALIGN, FLEX_DIRECTION, Size, } from '../../../../helpers/constants/design-system'; import Box from '../../../../components/ui/box'; import { SNAPS_VIEW_ROUTE } from '../../../../helpers/constants/routes'; import { disableSnap, enableSnap } from '../../../../store/actions'; import { getSnaps } from '../../../../selectors'; import { handleSettingsRefs } from '../../../../helpers/utils/settings-search'; import { Icon, ICON_NAMES, ICON_SIZES, } from '../../../../components/component-library/icon/deprecated'; import { BannerTip, BannerTipLogoType, ButtonLink, Text, } from '../../../../components/component-library'; const SnapListTab = () => { const t = useI18nContext(); const history = useHistory(); const dispatch = useDispatch(); const snaps = useSelector(getSnaps); const settingsRef = useRef(); const onClick = (snap) => { history.push(`${SNAPS_VIEW_ROUTE}/${encodeURIComponent(snap.id)}`); }; const onToggle = (snap) => { if (snap.enabled) { dispatch(disableSnap(snap.id)); } else { dispatch(enableSnap(snap.id)); } }; useEffect(() => { handleSettingsRefs(t, t('snaps'), settingsRef); }, [settingsRef, t]); return (