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

export const MerchantTab = ({
  activeTab
}: MerchantTabProps) => {
  const { t } = useTranslation();
  const { navigate } = useNavigate();

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