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

export const SettlementTab = ({
  activeTab
}: SettlementTabProps) => {
  const { navigate } = useNavigate();
  const { t } = useTranslation();

  const onClickToNavigation = (tab: SettlementTabKeys) => {
    if(activeTab !== tab){
      if(tab === SettlementTabKeys.Calendar){
        navigate(PATHS.settlement.calendar);
      }
      else if(tab === SettlementTabKeys.List){
        navigate(PATHS.settlement.list);
      } 
    }
  };
  return(
    <>
      <div className="subTab">
        <button
          className={`subtab-btn ${(activeTab === SettlementTabKeys.Calendar)? 'active': ''}` }
          onClick={ () => onClickToNavigation(SettlementTabKeys.Calendar) }
        >{t('settlement.calendar')}</button>
        <button
          className={`subtab-btn ${(activeTab === SettlementTabKeys.List)? 'active': ''}` }
          onClick={ () => onClickToNavigation(SettlementTabKeys.List) }
        >{t('settlement.history')}</button>
      </div>
    </>
  );
};