import { useTranslation } from 'react-i18next';
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import {
  PaymentTabKeys,
  PaymentTabProps
} from '../model/types';

export const PaymentTab = ({
  activeTab
}: PaymentTabProps) => {
  const { t } = useTranslation();
  const { navigate } = useNavigate();

  const onClickToNavigation = (tab: PaymentTabKeys) => {
    if(activeTab !== tab){
      if(tab === PaymentTabKeys.Info){
        navigate(PATHS.payment.info);
      }
      else if(tab === PaymentTabKeys.NotificationData){
        navigate(PATHS.payment.notificationData);
      }
    }
  };
  return(
    <>
      <div className="subTab">
        <button
          className={`subtab-btn ${(activeTab === PaymentTabKeys.Info)? 'active': ''}` }
          onClick={ () => onClickToNavigation(PaymentTabKeys.Info) }
        >{t('payment.info')}</button>
        <button
          className={`subtab-btn ${(activeTab === PaymentTabKeys.NotificationData)? 'active': ''}` }
          onClick={ () => onClickToNavigation(PaymentTabKeys.NotificationData) }
        >{t('payment.notificationData')}</button>
      </div>
    </>
  );
};