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"
import NostrIcon from "../../../../public/images/nostr.png"
import { useToast } from "@/hooks/useToast";
// With current spacing the title can only be 1 line
const promotions = [
{
id: 1,
category: "PLEBDEVS",
title: "Content and Community platform",
description: "One of a kind Nostr / Lightning integrated Content and Community platform.",
icon: "pi pi-code",
video: "https://plebdevs-bucket.nyc3.cdn.digitaloceanspaces.com/plebdevs-montage.mp4",
},
{
id: 2,
category: "CONTENT",
title: "Comprehensive Learning Resources",
description: "Access the PlebDevs library of courses, videos, and documents.",
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",
description: "Learn and connect with other developers, share your projects, and level up together.",
icon: "pi pi-users",
image: "https://pikwizard.com/pw/medium/50238b1cad4ff412fdafc1325efa1c9f.jpg",
},
{
id: 4,
category: "LIGHTNING / NOSTR",
title: "Lightning and Nostr integrated platform",
description: "All content is published to and pulled from nostr relays and is fully interoperable with comments, zaps, and other nostr clients. Premium content is available for sale with lightning or by subscribing to plebdevs via a lightning subscription.",
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 { showToast } = useToast();
const windowWidth = useWindowWidth();
const isTabView = windowWidth <= 1360;
const isMobile = windowWidth <= 768;
const router = useRouter();
const videoRef = useRef(null);
const copyToClipboard = async (text) => {
try {
await navigator.clipboard.writeText(text);
showToast("success", "Copied", "Copied Lightning Address to clipboard");
if (window && window?.webln && window?.webln?.lnurl) {
await window.webln.enable();
const result = await window.webln.lnurl("austin@bitcoinpleb.dev");
if (result && result?.preimage) {
showToast("success", "Payment Sent", "Thank you for your donation!");
}
}
} catch (err) {
console.error('Failed to copy:', err);
}
};
useEffect(() => {
if (videoRef.current && selectedPromotion.video) {
videoRef.current.play();
}
}, [selectedPromotion]);
return (
{selectedPromotion.video ? (
) : (
)}
{isTabView ? (
{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;
}
})()
}
>
)}
{isTabView ? (
{promotions.map((promo) => (
setSelectedPromotion(promo)}>
{promo.title}
))}
) : (
promotions.map((promo) => (
setSelectedPromotion(promo)}>
{promo.title}
))
)}
{isTabView ? (
// todo: turn this into a stepper for multiple messages
Welcome! 👋
Plebdevs is open source software and is still in early development. If you have any questions drop an issue on the Github repo, or reach out to me in the Community tab, cheers! - Austin
window.open('https://github.com/austinkelsay/plebdevs', '_blank')}
title="Github"
/>
window.open('https://x.com/pleb_devs', '_blank')}
title="X"
/>
window.open('https://nostr.com/plebdevs@plebdevs.com', '_blank')}
title="Nostr"
/>
copyToClipboard("austin@bitcoinpleb.dev")}
title="Donate"
/>
) : (
Welcome! 👋
Plebdevs is open source software and is still in early development. If you have any questions drop an issue on the Github repo, or reach out to me in the Community tab, cheers! - Austin
window.open('https://github.com/austinkelsay/plebdevs', '_blank')}
title="Github"
/>
window.open('https://x.com/pleb_devs', '_blank')}
title="X"
/>
window.open('https://nostr.com/plebdevs@plebdevs.com', '_blank')}
title="Nostr"
/>
copyToClipboard("austin@bitcoinpleb.dev")}
title="Donate"
/>
)}
);
}
export default InteractivePromotionalCarousel;