'use client'; import { AlertDialog, Button, Flex, Heading, Link, Text, } from '@radix-ui/themes'; import { usePathname } from 'next/navigation'; import { useEffect, useState } from 'react'; import { extendAuth } from '../../core/blitz/extendAuth'; import { logout } from '../../core/blitz/logout'; import isDev from '../../core/blitzkit/isDev'; import { isLocalhost } from '../../core/blitzkit/isLocalhost'; import { CURRENT_POLICIES_AGREEMENT_INDEX, useApp } from '../../stores/app'; const DEV_BUILD_AGREEMENT_COOLDOWN = 8 * 24 * 60 * 60 * 1000; export function Checks() { const [showDevBuildAlert, setShowDevBuildAlert] = useState(false); const login = useApp((state) => state.login); const policiesAgreementIndex = useApp( (state) => state.policiesAgreementIndex, ); const pathname = usePathname(); const isLegal = pathname.startsWith('/legal'); const [showPoliciesAgreement, setShowPoliciesAgreement] = useState(false); useEffect(() => { setShowDevBuildAlert( isDev() && !isLocalhost() && Date.now() - useApp.getState().devBuildAgreementTime >= DEV_BUILD_AGREEMENT_COOLDOWN, ); }, []); useEffect(() => { setShowPoliciesAgreement( policiesAgreementIndex !== CURRENT_POLICIES_AGREEMENT_INDEX && !isLegal, ); }, [policiesAgreementIndex, isLegal]); useEffect(() => { if (!login) return; const expiresIn = login.expiresAt - Date.now() / 1000; const expiresInDays = expiresIn / 60 / 60 / 24; if (expiresInDays < 0) { logout(); } else if (expiresInDays < 7) { extendAuth(); } }); return ( <> Experimental version! This version may have a lot of issues. Report issues to{' '} the official Discord server . Also consider using{' '} the more stable release version. You will be asked again in 8 days. {showPoliciesAgreement && ( {policiesAgreementIndex === -1 ? "BlitzKit's cookies" : "BlitzKit's policies have changed"} This website utilizes cookies to perform analytics and personalize your experience. You can learn more through{' '} our privacy policy. You may opt out of personalized advertizement by visiting{' '} Google Ad Settings . By using BlitzKit, you also agree to our{' '} terms of service. )} ); }