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

  const [activeTab, ] = useState<AccountUserTabKeys>(AccountUserTabKeys.AccountAuth);
  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>
            <UserAccountAuthWrap
              mid={ mid || '' }
              usrid={ usrid || '' }
              idCL={ idCL || '' }
              status={ status || '' }
            ></UserAccountAuthWrap>
          </div>
        </div>
      </main>
    </>
  );
};