import React, { useEffect, useState, useRef } from 'react'; import useWindowWidth from '@/hooks/useWindowWidth'; import Image from 'next/image'; import { getSession, signIn, useSession } from 'next-auth/react'; import { useRouter } from 'next/router'; import { Avatar } from 'primereact/avatar'; import { AvatarGroup } from 'primereact/avatargroup'; import GenericButton from '../buttons/GenericButton'; import HeroImage from '../../../public/images/hero-image.png'; const HeroBanner = () => { const [currentTech, setCurrentTech] = useState('Bitcoin'); const [isAnimating, setIsAnimating] = useState(false); const techs = ['Bitcoin', 'Lightning', 'Nostr']; const windowWidth = useWindowWidth(); const router = useRouter(); const { data: session } = useSession(); const isTabView = windowWidth <= 1360; const isMobile = windowWidth <= 800; const isWideScreen = windowWidth >= 2200; const isSuperWideScreen = windowWidth >= 2600; useEffect(() => { const interval = setInterval(() => { setIsAnimating(true); setTimeout(() => { setCurrentTech(prev => { const currentIndex = techs.indexOf(prev); return techs[(currentIndex + 1) % techs.length]; }); setIsAnimating(false); }, 400); // Half of the interval for smooth transition }, 2800); return () => clearInterval(interval); }, []); const getColorClass = (tech) => { switch (tech) { case 'Bitcoin': return 'text-orange-400'; case 'Lightning': return 'text-blue-500'; case 'Nostr': return 'text-purple-400'; default: return 'text-white'; } }; const getHeroHeight = () => { if (isSuperWideScreen) return 'h-[700px]'; if (isWideScreen) return 'h-[550px]'; if (isMobile) return 'h-[400px]'; return 'h-[500px]'; }; const handleLearnToCode = async () => { const starterCourseUrl = '/course/naddr1qvzqqqr4xspzpueu32tp0jc47uzlcuxdgcw06m40ytu7ynpna2adnqty3e0vda6pqy88wumn8ghj7mn0wvhxcmmv9uq32amnwvaz7tmjv4kxz7fwv3sk6atn9e5k7tcpr9mhxue69uhhyetvv9ujuumwdae8gtnnda3kjctv9uq3wamnwvaz7tmjv4kxz7fwdehhxarj9e3xzmny9uq36amnwvaz7tmjv4kxz7fwd46hg6tw09mkzmrvv46zucm0d5hsz9mhwden5te0wfjkccte9ec8y6tdv9kzumn9wshszynhwden5te0dehhxarjxgcjucm0d5hszynhwden5te0dehhxarjw4jjucm0d5hsz9nhwden5te0wp6hyurvv4ex2mrp0yhxxmmd9uq3wamnwvaz7tmjv4kxz7fwv3jhvueww3hk7mrn9uqzge34xvuxvdtrx5knzcfhxgkngwpsxsknsetzxyknxe3sx43k2cfkxsurwdq68epwa?active=starter'; // If user is already signed in, redirect directly if (session?.user) { router.push(starterCourseUrl); return; } // Check for stored keys const storedPubkey = localStorage.getItem('anonymousPubkey'); const storedPrivkey = localStorage.getItem('anonymousPrivkey'); if (storedPubkey && storedPrivkey) { // Sign in with stored keys const result = await signIn('anonymous', { pubkey: storedPubkey, privkey: storedPrivkey, redirect: false, callbackUrl: starterCourseUrl }); if (result?.ok) { router.push(starterCourseUrl); } } else { // Proceed with anonymous sign in const result = await signIn('anonymous', { callbackUrl: starterCourseUrl, redirect: false, }); if (result?.ok) { // Wait a moment for the session to be updated await new Promise(resolve => setTimeout(resolve, 1000)); // Fetch the session const session = await getSession(); if (session?.user?.pubkey && session?.user?.privkey) { localStorage.setItem('anonymousPubkey', session.user.pubkey); localStorage.setItem('anonymousPrivkey', session.user.privkey); router.push('/'); } else { console.error("Session data incomplete:", session); } } } }; return (
Banner
{!isTabView && (
)}

Learn to code Build on{' '} {currentTech} Become a dev

{isMobile ? (

A one of a kind developer education, content, and community platform built on Nostr and fully Lightning integrated.

) : (

A one of a kind developer education, content, and community platform built on Nostr and fully Lightning integrated.

)}
!isMobile && window.open('https://www.udemy.com/user/austin-james-kelsay/', '_blank')} style={{ cursor: isMobile ? 'default' : 'pointer' }} >
{Array.from({ length: 5 }).map((_, index) => ( ))}

4.87

500+ students enrolled
} rounded severity="success" className="border-2" outlined onClick={handleLearnToCode} />
); }; export default HeroBanner;