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 { UserLoginAuthInfoWrap } from '@/entities/account/ui/user-login-auth-info-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 UserLoginAuthInfoPage = () => {
  const { navigate } = useNavigate();
  const location = useLocation();
  const [tid, setTid] = useState<string>(location?.state.tid);

  const [activeTab, setActiveTab] = useState<AccountUserTabKeys>(AccountUserTabKeys.LoginAuthInfo);
  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>
            <UserLoginAuthInfoWrap
              tid={ tid }
            ></UserLoginAuthInfoWrap>
          </div>
        </div>
      </main>
    </>
  );
};