import clsx from "clsx" import { useEffect } from "react" import { Controller, useWatch } from "react-hook-form" import { useTranslation } from "react-i18next" import { NestedForm } from "../../../utils/nested-form" import Switch from "../../atoms/switch" import InfoIcon from "../../fundamentals/icons/info-icon" import Tooltip from "../../atoms/tooltip" export type AnalyticsConfigFormType = { anonymize: boolean opt_out: boolean } type Props = { form: NestedForm compact?: boolean } const AnalyticsConfigForm = ({ form, compact }: Props) => { const { control, setValue, path } = form const { t } = useTranslation() const watchOptOut = useWatch({ control, name: path("opt_out"), }) useEffect(() => { if (watchOptOut) { setValue(path("anonymize"), false) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [watchOptOut]) return (

{t("analytics-config-form-title", "Anonymize my usage data")}

{compact && ( )}
{!compact && (

{t( "analytics-config-form-description", "You can choose to anonymize your usage data. If this option is selected, we will not collect your personal information, such as your name and email address." )}

)}
{ return ( ) }} />

{t( "analytics-config-form-opt-out", "Opt out of sharing my usage data" )}

{compact && ( )}
{!compact && (

{t( "analytics-config-form-opt-out-later", "You can always opt out of sharing your usage data at any time." )}

)}
{ return }} />
) } export default AnalyticsConfigForm