/* 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 { actionCreators as ac, actionTypes as at } from "common/Actions.mjs"; export function ActivationWindowMessage({ dispatch, handleBlock, handleClick, handleDismiss, messageData, }) { const { content } = messageData; const hasButtons = content.primaryButton || content.secondaryButton; const onDismiss = useCallback(() => { handleDismiss(); handleBlock(); }, [handleDismiss, handleBlock]); const onPrimaryClick = useCallback(() => { handleClick("primary-button"); if (content.primaryButton?.action?.dismiss) { handleDismiss(); handleBlock(); } if (content.primaryButton?.action?.type === "SHOW_PERSONALIZE") { dispatch({ type: at.SHOW_PERSONALIZE }); dispatch(ac.UserEvent({ event: "SHOW_PERSONALIZE" })); } }, [dispatch, handleClick, handleDismiss, handleBlock, content]); const onSecondaryClick = useCallback(() => { handleClick("secondary-button"); if (content.secondaryButton?.action?.dismiss) { handleDismiss(); handleBlock(); } }, [handleClick, handleDismiss, handleBlock, content]); return ( ); }