import { useState } from 'react';
import { useLocation } from 'react-router-dom';
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 location = useLocation();
  const { mid, usrid, tid } = location.state || {};
  const { navigate } = useNavigate();

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

  // const { mutateAsync: userFindAuthMethod } = useUserFindAuthMethodMutation();

  // const callUserFindAuthMethod = (mid: string, usrid: string) => {
  //   let parms: UserFindAuthMethodParams = {
  //     mid: mid,
  //     usrid: usrid
  //   }
  //   userFindAuthMethod(params).then((rs: UserFindAuthMethodResponse) => {
  //     console.log("User Find Auth Method: ", rs)
  //   });
  // }

  // useEffect(() => {
  //   callUserFindAuthMethod(mid, usrid);
  // }, [mid, usrid]);

  return (
    <>
      <main>
        <div className="tab-content">
          <div className="tab-pane pt-46 active">
            <AccountUserTab
              activeTab={ activeTab }
              tid={tid || ''}
              mid={mid || ''}
              usrid={usrid || ''}
            ></AccountUserTab>
            <UserLoginAuthInfoWrap
              mid={mid || ''}
              usrid={usrid || ''}
            ></UserLoginAuthInfoWrap>
          </div>
        </div>
      </main>
    </>
  );
};