"use client"; import type { PaymentMethod } from "@/lib/saleor/payments/types"; import { PaymentMethodCard } from "./PaymentMethodCard"; import { useTranslations } from "next-intl"; interface PaymentMethodSelectorProps { methods: PaymentMethod[]; selectedMethodId: string; onSelectMethod: (methodId: string) => void; locale: string; disabled?: boolean; } export function PaymentMethodSelector({ methods, selectedMethodId, onSelectMethod, locale, disabled = false, }: PaymentMethodSelectorProps) { const t = useTranslations("Payment"); // Filter to only available methods const availableMethods = methods.filter((m) => m.available); if (availableMethods.length === 0) { return (
{t("noMethodsAvailable")}
); } // If only one method, show it as selected but don't allow changing const isSingleMethod = availableMethods.length === 1; return (

{t("title")}

{availableMethods.map((method) => ( onSelectMethod(method.id)} disabled={disabled || isSingleMethod} locale={locale} /> ))}
{isSingleMethod && (

{t("singleMethodNotice")}

)}
); }