import { useState } from 'react';
import { useLocation } from 'react-router';
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { SettlementTab } from '@/entities/settlement/ui/settlement-tab';
import { ListWrap } from '@/entities/settlement/ui/list-wrap';
import { SettlementTabKeys } from '@/entities/settlement/model/types'; 
import { FooterItemActiveKey } from '@/entities/common/model/types';
import { HeaderType } from '@/entities/common/model/types';
import {
	useSetHeaderTitle,
	useSetHeaderType,
	useSetFooterMode,
  useSetOnBack
} from '@/widgets/sub-layout/use-sub-layout';
import { useTranslation } from 'react-i18next';

export const ListPage = () => {
  const { navigate } = useNavigate();
  const { t } = useTranslation();
  const location = useLocation();

  const startDate: string | undefined  = location?.state?.startDate;
  const endDate: string | undefined  = location?.state?.endDate;

  const [activeTab, setActiveTab] = useState<SettlementTabKeys>(SettlementTabKeys.List);

  useSetHeaderTitle(t('settlement.title'));
  useSetHeaderType(HeaderType.LeftArrow);
  useSetFooterMode(false);
  useSetOnBack(() => {
    navigate(PATHS.home);
  });
  
  return (
    <>
      <main>
        <div className="tab-content">
          <div className="tab-pane pt-46 active">
            <SettlementTab activeTab={ activeTab }></SettlementTab>
            <ListWrap
              startDateFromCalendar={ startDate }
              endDateFromCalendar={ endDate }
            ></ListWrap>
          </div>
        </div>
      </main>
    </>
  );
};