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,
  useSetFooterCurrentPage,
  useSetOnBack
} from '@/widgets/sub-layout/use-sub-layout';

export const ListPage = () => {
  const { navigate } = useNavigate();
  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('정산조회');
  useSetHeaderType(HeaderType.LeftArrow);
  useSetFooterMode(true);
  useSetFooterCurrentPage(FooterItemActiveKey.Settlement);
  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>
    </>
  );
};