@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 797 B
JavaScript
"use client";
import{jsx as _jsx}from"react/jsx-runtime";import PaymentSourceContext from"../../context/PaymentSourceContext";import capitalize from"lodash/capitalize";import{useContext}from"react";import Parent from"../utils/Parent";import CustomerPaymentSourceContext from"../../context/CustomerPaymentSourceContext";export function PaymentSourceBrandName({children,label,...props}){const{brand}=useContext(PaymentSourceContext),{brand:customerCardBrand}=useContext(CustomerPaymentSourceContext),cardBrand=brand??customerCardBrand,brandName=cardBrand&&capitalize(cardBrand.replace(/_|-/gm," ")),parentProps={brand:brandName,label,...props};return children?_jsx(Parent,{...parentProps,children}):_jsx("span",{...props,children:label||capitalize(brandName)})}export default PaymentSourceBrandName;