"use client";
import Image from "@/components/ui/resilient-image";
import { Children, Fragment, type ReactNode, useState } from "react";
import { Separator } from "@/components/ui/separator";
import { ScrollableNav } from "@/components/public/scrollable-nav";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
export function ConditionTabIcon({ iconUrl }: { iconUrl?: string | null }) {
return iconUrl
?
: null;
}
export function ConditionSwitcher({
children,
label = "เลือกเงื่อนไข",
labels,
iconUrls,
}: {
children: ReactNode;
label?: string;
labels?: readonly string[];
iconUrls?: readonly (string | null | undefined)[];
}) {
const items = Children.toArray(children);
const [active, setActive] = useState("0");
if (items.length <= 1) return items[0] ?? null;
return (
{items.map((_, index) => (
{index > 0 ? : null}
{labels?.[index] || `เงื่อนไข ${index + 1}`}
))}
{items.map((item, index) => {item})}
);
}