import { IFunnelPaymentPlacement } from "@/entities/session/funnel/types";

const getProperty = (
  paymentData: IFunnelPaymentPlacement | IFunnelPaymentPlacement[] | null,
  key: string
) => {
  const properties = Array.isArray(paymentData)
    ? []
    : (paymentData?.properties ?? []);

  return (
    properties.find(p => p.key === key) ?? {
      key,
      value: `property: "${key}" not found`,
    }
  );
};

export { getProperty };
