import type { FC } from '../../lib/teact/teact'; import { memo, useMemo, useState } from '../../lib/teact/teact'; import { getActions, withGlobal } from '../../global'; import type { ApiPaymentCredentials } from '../../api/types'; import type { FormState } from '../../hooks/reducers/usePaymentReducer'; import type { RegularLangFnParameters } from '../../util/localization'; import { selectTabState } from '../../global/selectors'; import useLang from '../../hooks/useLang'; import useOldLang from '../../hooks/useOldLang'; import PasswordForm from '../common/PasswordForm'; import PasswordMonkey from '../common/PasswordMonkey'; interface OwnProps { isActive?: boolean; state: FormState; savedCredentials?: ApiPaymentCredentials[]; onPasswordChange: (password: string) => void; } interface StateProps { errorKey?: RegularLangFnParameters; passwordHint?: string; savedCredentials?: ApiPaymentCredentials[]; } const PasswordConfirm: FC = ({ isActive, errorKey, state, savedCredentials, passwordHint, onPasswordChange, }) => { const { clearPaymentError } = getActions(); const oldLang = useOldLang(); const lang = useLang(); const [shouldShowPassword, setShouldShowPassword] = useState(false); const cardName = useMemo(() => { return savedCredentials?.length && state.savedCredentialId ? savedCredentials.find(({ id }) => id === state.savedCredentialId)?.title : undefined; }, [savedCredentials, state.savedCredentialId]); return (
); }; export default memo(withGlobal((global): Complete => { const { payment } = selectTabState(global); return { errorKey: payment.error?.messageKey, passwordHint: global.twoFaSettings.hint, savedCredentials: payment.form?.type === 'regular' ? payment.form.savedCredentials : undefined, }; })(PasswordConfirm));