import React, { useState, useRef, useEffect } from 'react'; import { FormattedMessage as T, useIntl } from 'react-intl'; import classNames from 'classnames'; import { paymentmethod } from 'common/subscriptionModels'; function BillingPeriod({ price, period, currency, onSelected, selected }) { return (
{price} {currency}
); } function BillingPeriods({ formik, title, selected = 1 }) { const billingRef = useRef(null); useEffect(() => { const billingPriod = billingRef.current.querySelectorAll('a'); const billingSelected = billingRef.current.querySelector( '.billing-selected', ); billingPriod.forEach((el) => { el.addEventListener('click', () => { billingSelected.classList.remove('billing-selected'); el.classList.add('billing-selected'); }); }); }); return (

{paymentmethod.map((pay, index) => ( formik.setFieldValue('period', pay.period)} selected={selected == index + 1} /> ))}
); } export default BillingPeriods;