import { useEffect, useState } from 'react';
import { useLocation } from 'react-router';
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { AccountUserTab } from '@/entities/account/ui/account-user-tab';
import { UserAccountAuthWrap } from '@/entities/account/ui/user-account-auth-wrap';
import { AccountUserTabKeys } from '@/entities/account/model/types';
import { HeaderType } from '@/entities/common/model/types';
import { 
  useSetHeaderTitle,
  useSetHeaderType,
  useSetFooterMode,
  useSetOnBack
} from '@/widgets/sub-layout/use-sub-layout';

export const UserAccountAuthPage = () => {
  const { navigate } = useNavigate();
  const location = useLocation();
  const [tid, setTid] = useState<string>(location?.state.tid);

  const [activeTab, setActiveTab] = useState<AccountUserTabKeys>(AccountUserTabKeys.AccountAuth);
  useSetHeaderTitle('사용자 설정');
  useSetHeaderType(HeaderType.LeftArrow);
  useSetFooterMode(true);
  useSetOnBack(() => {
    navigate(PATHS.account.user.manage);
  });

  useEffect(() => {
    console.log('tid : ', tid);
  });

  return (
    <>
      <main>
        <div className="tab-content">
          <div className="tab-pane sub active">
            <AccountUserTab 
              activeTab={ activeTab }
              tid={ tid }
            ></AccountUserTab>
            <UserAccountAuthWrap
              tid={ tid }
            ></UserAccountAuthWrap>
          </div>
        </div>
      </main>
    </>
  );
};