import data from '../../utils/data';
export const PayPalCheckbox = ( props ) => {
return (
props.handleCheckboxState( e.target.checked, props )
}
/>
{ data().getImage( 'icon-checkbox.svg' ) }
);
};
export const PayPalRdb = ( props ) => {
return (
props.handleRdbState( props.value ) }
/>
);
};
export const PayPalRdbWithContent = ( props ) => {
const className = [ 'ppcp-r__radio-wrapper' ];
if ( props?.className ) {
className.push( props.className );
}
return (
{ props.description && (
) }
{ props?.toggleAdditionalContent &&
props.children &&
props.value === props.currentValue && (
{ props.children }
) }
);
};
export const handleCheckboxState = ( checked, props ) => {
let newValue = null;
if ( checked ) {
newValue = [ ...props.currentValue, props.value ];
props.changeCallback( newValue );
} else {
newValue = props.currentValue.filter(
( value ) => value !== props.value
);
}
props.changeCallback( newValue );
};