import { useTranslation } from 'react-i18next';
import { PATHS } from '@/shared/constants/paths';
import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import { checkGrant } from '@/shared/lib/check-grant';
import { showAlert } from '@/widgets/show-alert';

export const PasswordManageWrap = () => {
  const { t } = useTranslation();
  const { navigate } = useNavigate();

  const changeLoginPassword = () => {
    if (!checkGrant(46, 'X')) {
      showAlert(t('common.nopermission'));
      return;
    }
    navigate(PATHS.account.password.modifyLoginPassword);
  };

  const changeCancelPassword = () => {
    if (!checkGrant(46, 'X')) {
      showAlert(t('common.nopermission'));
      return;
    }
    navigate(PATHS.account.password.modifyCancelPassword);
  };

  return (
    <>
      <div className="ing-list">
        <div className="pwd-manage mt-20">
          <div className="pwd-buttons">
            <button
              className="btn-44 btn-white pwd-btn"
              type="button"
              onClick={changeLoginPassword}
            >{t('account.changeLoginPassword')}</button>
            <button
              className="btn-44 btn-white pwd-btn"
              type="button"
              onClick={changeCancelPassword}
            >{t('account.changeCancelPassword')}</button>
          </div>
        </div>
      </div>
    </>
  )
};