///////////////////////////////////////////////////////////// // // pgAdmin 4 - PostgreSQL Tools // // Copyright (C) 2013 - 2024, The pgAdmin Development Team // This software is released under the PostgreSQL Licence // ////////////////////////////////////////////////////////////// import React, { useState } from 'react'; import LoginImage from '../../img/login.svg?svgr'; import { InputSelect, InputText, MESSAGE_TYPE, NotifierMessage } from '../components/FormComponents'; import BasePage, { SecurityButton } from './BasePage'; import { useDelayedCaller } from '../custom_hooks'; import gettext from 'sources/gettext'; import PropTypes from 'prop-types'; function EmailValidateView({mfaView, sendEmailUrl, csrfHeader, csrfToken}) { const [inputValue, setInputValue] = useState(''); const [error, setError] = useState(''); const [sentMessage, setSentMessage] = useState(''); const [sending, setSending] = useState(false); const [showResend, setShowResend] = useState(false); const showResendAfter = useDelayedCaller(()=>{ setShowResend(true); }); const sendCodeToEmail = ()=>{ setSending(true); let accept = 'text/html; charset=utf-8;'; fetch(sendEmailUrl, { method: 'POST', mode: 'cors', cache: 'no-cache', headers: { 'Accept': accept, 'Content-Type': 'application/json; charset=utf-8;', [csrfHeader]: csrfToken, }, redirect: 'follow' }).then((resp) => { if (!resp.ok) { resp.text().then(msg => setError(msg)); return; } return resp.json(); }).then((resp) => { if (!resp) return; setSentMessage(resp.message); showResendAfter(20000); }).finally(()=>{ setSending(false); }); }; return <>