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

export const VatReturnTab = ({
  activeTab
}: VatReturnTabProps) => {
  const { t } = useTranslation();
  const { navigate } = useNavigate();

  const onClickToNavigation = (tab: VatReturnTabKeys) => {
    if(activeTab !== tab){
      if(tab === VatReturnTabKeys.List){
        navigate(PATHS.vatReturn.list);
      }
      else if(tab === VatReturnTabKeys.VatReference){
        navigate(PATHS.vatReturn.reference);
      }
    }
  };
  return(
    <>
      <div className="subTab">
        <button
          className={`subtab-btn ${(activeTab === VatReturnTabKeys.List)? 'active': ''}` }
          onClick={ () => onClickToNavigation(VatReturnTabKeys.List) }
        >{t('vatReturn.taxInvoice')}</button>
        <button
          className={`subtab-btn ${(activeTab === VatReturnTabKeys.VatReference)? 'active': ''}` }
          onClick={ () => onClickToNavigation(VatReturnTabKeys.VatReference) }
        >{t('vatReturn.vatReference')}</button>
      </div>
    </>
  );
};