diff --git a/src/components/Forms/LoginForm/LoginForm.tsx b/src/components/Forms/LoginForm/LoginForm.tsx index f4ec46a8..3443a668 100644 --- a/src/components/Forms/LoginForm/LoginForm.tsx +++ b/src/components/Forms/LoginForm/LoginForm.tsx @@ -17,6 +17,16 @@ import { Network } from '@data/networks'; import NetworkDropdown from '@components/Dropdowns/NetworkDropdown/NetworkDropdown'; import { setDefaultNetwork } from '@utils/localStorage'; import { useLocales } from '@context/LocalesContext'; +import CustomCheckbox from '@components/Inputs/CustomCheckbox/CustomCheckbox'; +import { useMatomoContext } from '@context/Matomo'; + +const ALLOW_TRACKING_KEY = 'allow-matomo'; + +function getDefaultTrackingValue(): boolean { + const enabled = localStorage.getItem(ALLOW_TRACKING_KEY); + + return enabled === 'true' || enabled === null ? true : false; +} const LoginForm: FC = () => { const CREATE_USER_URL = process.env.NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT; @@ -26,8 +36,10 @@ const LoginForm: FC = () => { const { errors, isValid } = formState; const { setUser, errorMessage, setErrorMessage } = useContext(UserContext); + const [allowTracking, setAllowTracking] = useState(getDefaultTrackingValue()); const [network, setNetwork] = useState(getDefaultNetwork()); const [loading, setLoading] = useState(false); + const { setEnabled } = useMatomoContext(); const { fdpClientRef, @@ -46,6 +58,7 @@ const LoginForm: FC = () => { setErrorMessage(null); const { user_name, password } = data; setFdpStorageType('native', network.config); + setEnabled(allowTracking); const wallet = await fdpClientRef.current.account.login( user_name, password @@ -67,6 +80,12 @@ const LoginForm: FC = () => { setNetwork(network); }; + const onAllowTrackingClick = () => { + const enabled = !allowTracking; + setAllowTracking(enabled); + localStorage.setItem(ALLOW_TRACKING_KEY, String(enabled)); + }; + useEffect(() => { setErrorMessage(null); }, []); @@ -154,6 +173,15 @@ const LoginForm: FC = () => { error={errors.password} /> + + {intl.get('ALLOW_TRACKING')} + +
-