"use client";
import { useMemo, useState } from "react";
import Image from "next/image";
import { Icon } from "@iconify/react";
import { Button, ButtonIcon, ButtonLabel, Card, Typography } from "poyraz-ui/atoms";
import { Modal, ModalContent, ModalTitle } from "poyraz-ui/molecules";
import { useTranslations } from "next-intl";
import { YoutubeLiteEmbed } from "@/components/youtube-lite-embed";
import type { XVideo } from "@/data/x-videos";
import { X_JAVASCRIPT_ANATOMY_URL } from "@/data/x-videos";
import type { PdfNote } from "@/lib/content-page";
type ContentContentProps = {
youtubeLinks: readonly string[];
pdfFiles: PdfNote[];
xVideos: readonly XVideo[];
};
type SectionHeadingProps = {
title: string;
titlePrefix?: string;
titleIcon: string;
titleIconClassName?: string;
href: string;
label: string;
handle: string;
icon: string;
};
function SectionHeading({
title,
titlePrefix,
titleIcon,
titleIconClassName,
href,
label,
handle,
icon,
}: SectionHeadingProps) {
return (
{titlePrefix ? {titlePrefix} : null}
{title}
);
}
export function ContentContent({
youtubeLinks,
pdfFiles,
xVideos,
}: ContentContentProps) {
const t = useTranslations("Content");
const [pdfModalOpen, setPdfModalOpen] = useState(false);
const [activePdfIndex, setActivePdfIndex] = useState(0);
const activePdf = pdfFiles[activePdfIndex] ?? null;
const canGoPrev = activePdfIndex > 0;
const canGoNext = activePdfIndex < pdfFiles.length - 1;
const embeddedVideos = useMemo(
() => youtubeLinks.slice(0, 3),
[youtubeLinks],
);
const openPdfModal = (index: number) => {
setActivePdfIndex(index);
setPdfModalOpen(true);
};
return (
{embeddedVideos.map((link) => (
))}
{pdfFiles.map((pdf, index) => (
))}
{xVideos.map((video) => (
))}
{activePdf?.title ?? t("pdfModalDefaultTitle")}
{pdfFiles.length === 0
? "0 / 0"
: `${activePdfIndex + 1} / ${pdfFiles.length}`}
{activePdf ? (
) : (
{t("pdfNotFound")}
)}
);
}