@@ -1,5 +1,6 @@ import React from 'react' import Link from 'next/link' +import { useSession } from 'next-auth/react' import { useAppSelector } from '#/app/store/store' import { getDeviceType } from '#/shared/lib/helpers' @@ -15,7 +16,9 @@ function getConsent(): string | null { } export function CookieConsent() { + const { status } = useSession() const account_type = useAppSelector((state) => state.user.account_type) + const meStatus = useAppSelector((state) => state.user.status) const [consent, setConsent] = React.useState(undefined) const desktop = getDeviceType() === 'desktop' @@ -32,6 +35,7 @@ export function CookieConsent() { if (value === 'all') initYandexMetrika() } + if (status === 'loading' || (status === 'authenticated' && meStatus !== 'succeeded')) return null if (account_type !== 'regular' || consent !== null) return null return ( @@ -3,37 +3,9 @@ import { Head, Html, Main, NextScript } from 'next/document' export default function Document() { return ( - -