import Image from "next/image"
import { useState, useRef, useEffect } from "react"
import { useImageProxy } from "@/hooks/useImageProxy"
import GenericButton from "@/components/buttons/GenericButton"
import { useRouter } from "next/router"
import useWindowWidth from "@/hooks/useWindowWidth"
// With current spacing the title can only be 1 line
const promotions = [
{
id: 1,
category: "PLEBDEVS",
title: "Developer education & community platform",
description: "PlebDevs is your gateway to mastering Bitcoin, Lightning, and Nostr technologies. Join our community of aspiring developers and start your journey today!",
icon: "pi pi-code",
video: "/videos/plebdevs-montage.mp4",
},
{
id: 2,
category: "CONTENT",
title: "Comprehensive Learning Resources",
description: "Access our extensive library of courses, videos, and documents. From structured learning paths to hands-on workshops, we've got everything you need to master Bitcoin, Lightning, and Nostr development.",
icon: "pi pi-book",
image: "https://media.istockphoto.com/id/1224500457/photo/programming-code-abstract-technology-background-of-software-developer-and-computer-script.jpg?s=612x612&w=0&k=20&c=nHMypkMTU1HUUW85Zt0Ff7MDbq17n0eVeXaoM9Knt4Q=",
},
{
id: 3,
category: "COMMUNITY",
title: "Join Our Community of learners, hackers, and plebs",
description: "Connect with other developers, share your projects, and get support from our community of Bitcoin enthusiasts.",
icon: "pi pi-users",
image: "https://pikwizard.com/pw/medium/50238b1cad4ff412fdafc1325efa1c9f.jpg",
},
{
id: 4,
category: "LIGHTNING / NOSTR",
title: "Lightning and Nostr integrated platform",
description: "This platform is the first of its kind to integrate Lightning Network and Nostr protocols, allowing users to send and receive payments and interact with the Nostr network.",
icon: "pi pi-bolt",
image: "https://www.financemagnates.com/wp-content/uploads/2016/05/Bicoin-lightning.jpg",
},
]
const InteractivePromotionalCarousel = () => {
const [selectedPromotion, setSelectedPromotion] = useState(promotions[0])
const { returnImageProxy } = useImageProxy();
const windowWidth = useWindowWidth();
const isMobileView = windowWidth <= 1360;
const router = useRouter();
const videoRef = useRef(null);
useEffect(() => {
if (videoRef.current && selectedPromotion.video) {
videoRef.current.play();
}
}, [selectedPromotion]);
return (
{selectedPromotion.video ? (
) : (
)}
{isMobileView ? (
{selectedPromotion.category}
{selectedPromotion.title}
{selectedPromotion.description}
{
(() => {
switch (selectedPromotion.category) {
case "PLEBDEVS":
return (
router.push('/subscribe')} severity="warning" icon={} label="Subscribe" className="w-fit py-2 font-semibold" size="small" outlined />
router.push('/content?tag=all')} severity="primary" icon={} label="View all content" className="w-fit py-2 font-semibold" size="small" outlined />
);
case "CONTENT":
return (
<>
router.push('/content?tag=courses')} icon={} label="Courses" className="py-2 font-semibold" size="small" outlined />
router.push('/content?tag=videos')} icon={} label="Videos" className="py-2 font-semibold" size="small" outlined />
router.push('/content?tag=documents')} icon={} label="Documents" className="py-2 font-semibold" size="small" outlined />
>
);
case "COMMUNITY":
return (
router.push('/feed?channel=global')} icon={} label="Open Community Feed" className="w-fit py-2 font-semibold" size="small" outlined />
);
case "LIGHTNING / NOSTR":
return (
router.push('/subscribe')} severity="warning" icon={} label="Subscribe" className="w-fit py-2 font-semibold" size="small" outlined />
);
default:
return null;
}
})()
}
) : (
<>
{selectedPromotion.category}
{selectedPromotion.title}
{selectedPromotion.description}
{
(() => {
switch (selectedPromotion.category) {
case "PLEBDEVS":
return (
<>
router.push('/about')} severity="success" icon={} label="Learn More" className="py-2 font-semibold" size="small" outlined />
router.push('/subscribe')} severity="warning" icon={} label="Subscribe" className="py-2 font-semibold" size="small" outlined />
router.push('/content?tag=all')} severity="primary" icon={} label="View all content" className="py-2 font-semibold" size="small" outlined />
>
);
case "CONTENT":
return (
<>
router.push('/content?tag=courses')} icon={} label="Courses" className="py-2 font-semibold" size="small" outlined />
router.push('/content?tag=videos')} icon={} label="Videos" className="py-2 font-semibold" size="small" outlined />
router.push('/content?tag=documents')} icon={} label="Documents" className="py-2 font-semibold" size="small" outlined />
>
);
case "COMMUNITY":
return (
router.push('/feed?channel=global')} icon={} label="Open Community Feed" className="py-2 font-semibold" size="small" outlined />
);
case "LIGHTNING / NOSTR":
return (
router.push('/subscribe')} severity="warning" icon={} label="Subscribe" className="py-2 font-semibold" size="small" outlined />
);
default:
return null;
}
})()
}
>
)}
{isMobileView ? (
{promotions.map((promo) => (
setSelectedPromotion(promo)}>
{promo.title}
))}
) : (
promotions.map((promo) => (
setSelectedPromotion(promo)}>
{promo.title}
))
)}
);
}
export default InteractivePromotionalCarousel;