Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getIconClass = () => {
let iconClass;
let colorClass;
const cardNumber = this.props.value;
if (cardNumber && cardNumber.length > 0) {
const cardType = Payment.fns.cardType(cardNumber);
if (cardType) {
iconClass = CARD_TYPE_ICONS[cardType] || CARD_TYPE_ICONS.unknown;
const cardTypeObject = Payment.getCardArray().find(card => card.type === cardType);
if (cardTypeObject.length.includes(cardNumber.replace(/\s/g, '').length)) {
if (Payment.fns.validateCardNumber(cardNumber)) {
colorClass = 'text-success';
} else {
iconClass = 'fa-exclamation-triangle';
colorClass = 'text-danger';
}
}
} else {
iconClass = CARD_TYPE_ICONS.unknown;
}
} else {
iconClass = CARD_TYPE_ICONS.unknown;
}
return classNames('fa', iconClass, colorClass);