'use client'; import { useState, useEffect, use } from 'react'; import Link from 'next/link'; import { useTranslations } from 'next-intl'; import { ResourceCard } from '@/components/ResourceCard'; import { getLessons } from '@/lib/actions/lessonActions'; import { getCheatsheets } from '@/lib/actions/cheatsheetActions'; import { getCategories } from '@/lib/actions/categoryActions'; import { Search, Sparkles, Code2, FileCheck2, Layers, Download, Users, CheckCircle2, ArrowRight, ShieldAlert, Zap, Loader2 } from 'lucide-react'; import { YoutubeIcon as Youtube } from '@/components/icons/YoutubeIcon'; export default function HomePage({ params }: { params: Promise<{ locale: string }> }) { const { locale } = use(params); const t = useTranslations('hero'); const sec = useTranslations('sections'); const feat = useTranslations('features'); const [searchQuery, setSearchQuery] = useState(''); const [selectedCategory, setSelectedCategory] = useState(null); const [categories, setCategories] = useState([]); const [lessons, setLessons] = useState([]); const [cheatsheets, setCheatsheets] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { getCategories().then(setCategories); }, []); useEffect(() => { async function loadData() { setLoading(true); const [fetchedLessons, fetchedCheatsheets] = await Promise.all([ getLessons({ query: searchQuery, category: selectedCategory || undefined }), getCheatsheets() ]); setLessons(fetchedLessons); setCheatsheets(fetchedCheatsheets); setLoading(false); } loadData(); }, [searchQuery, selectedCategory]); const featuredVideo = lessons.find((v) => v.isFeatured) || lessons[0]; return (
{/* HERO SECTION */}
{/* Glow Effects */}
{/* Badge */}
{t('badge')}
{/* Main Heading */}

{t('title')}

{/* Subtitle */}

{t('subtitle')}

{/* Search Bar */}
setSearchQuery(e.target.value)} className="w-full bg-transparent px-3 py-2 text-sm text-white placeholder-slate-500 focus:outline-none" /> {searchQuery && ( )}
{/* Category Chips */}
{categories.map((cat) => ( ))}
{/* Statistics Bar */}
120+
{t('statVideos')}
100K+
{t('statDownloads')}
50K+
{t('statSubscribers')}
99.8%
{t('statSatisfaction')}
{/* FEATURED LESSON BANNER */} {featuredVideo && !selectedCategory && !searchQuery && (

{sec('featured')}

{/* Thumbnail preview */}
{featuredVideo.title}
{/* Info & CTA */}
{featuredVideo.category}

{featuredVideo.title}

{featuredVideo.summary}

Files Included:
{featuredVideo.codeSnippets.map((snip: any) => ( {snip.fileName} ))}
Explore Code & Notes Watch on YouTube
)} {/* ALL LESSONS GRID */}

{sec('allLessons')}

{lessons.length} tutorials found in database {selectedCategory && `(${selectedCategory})`}

View All Lessons
{loading ? (
Loading tutorials...
) : lessons.length > 0 ? (
{lessons.map((lesson) => ( ))}
) : (

No Tutorials Found

Try adjusting your search terms or clearing selected filters.

)}
{/* AYRIS.TECH YOUTUBE CHANNEL FEATURES */}
Creator Innovation

{sec('whyUsTitle')}

{sec('whyUsSubtitle')}

{/* Feature 1 */}

{feat('codeTabsTitle')}

{feat('codeTabsDesc')}

{/* Feature 2 */}

{feat('chaptersTitle')}

{feat('chaptersDesc')}

{/* Feature 3 */}

{feat('zipDownloadTitle')}

{feat('zipDownloadDesc')}

{/* Feature 4 */}

{feat('noDocsTitle')}

{feat('noDocsDesc')}

{/* FEATURED CHEATSHEETS PREVIEW */}

{sec('cheatsheetsTitle')}

Explore All Cheatsheets
{cheatsheets.map((cs) => (
{cs.category}

{cs.title}

{cs.description}

{cs.items.slice(0, 3).map((item: any, idx: number) => (
{item.command} {item.description}
))}
Open Cheatsheet
))}
); }