import React, { memo, useMemo, useState } from '../../lib/teact/teact'; import { getActions, withGlobal } from '../../global'; import type { FC } from '../../lib/teact/teact'; import type { ApiPaymentCredentials } from '../../api/types'; import type { FormState } from '../../hooks/reducers/usePaymentReducer'; import useLang from '../../hooks/useLang'; import PasswordMonkey from '../common/PasswordMonkey'; import PasswordForm from '../common/PasswordForm'; interface OwnProps { isActive?: boolean; state: FormState; savedCredentials?: ApiPaymentCredentials[]; onPasswordChange: (password: string) => void; } interface StateProps { error?: string; passwordHint?: string; savedCredentials?: ApiPaymentCredentials[]; } const PasswordConfirm: FC = ({ isActive, error, state, savedCredentials, passwordHint, onPasswordChange, }) => { const { clearPaymentError } = getActions(); 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): StateProps => { return { error: global.payment.error?.message, passwordHint: global.twoFaSettings.hint, savedCredentials: global.payment.savedCredentials, }; })(PasswordConfirm));