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

  const [activeTab, ] = useState<AccountUserTabKeys>(AccountUserTabKeys.LoginAuthInfo);
  useSetHeaderTitle(t('account.userSettings'));
  useSetHeaderType(HeaderType.LeftArrow);
  useSetFooterMode(false);
  useSetOnBack(() => {
    navigate(PATHS.account.user.manage);
  });

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