/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ import React, { useCallback } from "react"; import { useDispatch } from "react-redux"; import { actionCreators as ac, actionTypes as at } from "common/Actions.mjs"; import { useIntersectionObserver } from "../../../lib/utils"; const PREF_PROMO_CARD_DISMISSED = "discoverystream.promoCard.visible"; /** * The PromoCard component displays a promotional message. * It is used next to the AdBanner component in a four-column layout. */ const PromoCard = () => { const dispatch = useDispatch(); const onCtaClick = useCallback(() => { dispatch( ac.AlsoToMain({ type: at.PROMO_CARD_CLICK, }) ); }, [dispatch]); const onDismissClick = useCallback(() => { dispatch( ac.AlsoToMain({ type: at.PROMO_CARD_DISMISS, }) ); dispatch(ac.SetPref(PREF_PROMO_CARD_DISMISSED, false)); }, [dispatch]); const handleIntersection = useCallback(() => { dispatch( ac.AlsoToMain({ type: at.PROMO_CARD_IMPRESSION, }) ); }, [dispatch]); const ref = useIntersectionObserver(handleIntersection); return (
{ ref.current = [el]; }} >
); }; export { PromoCard };