React 19 drops defaultProps on function components. Converted the 9 of
ours that used it (App, Navigation, ReSendEmail, Reconnect, OAuthLoginButton,
PageHeader, Page, EditDocument, EditSubscription) to destructured default
params; App defaults userId/emailAddress in its withTracker instead (it
spreads {...props} widely). Class components keep defaultProps (still
supported). The only defaultProps warnings left are from the react-share
npm package (CreatedButton/Icon), not our code. REST smoke byte-identical.
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Alert, Button } from 'react-bootstrap';
|
|
import { Trans, withTranslation } from 'react-i18next';
|
|
import { T9n } from 'meteor-accounts-t9n';
|
|
|
|
const handleResendVerificationEmail = (emailAddress, t) => {
|
|
Meteor.call('users.sendVerificationEmail', (error) => {
|
|
if (error) {
|
|
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
|
} else {
|
|
Bert.alert(t("checkVerificationEmail", {email: emailAddress}), 'success');
|
|
}
|
|
});
|
|
};
|
|
|
|
const ReSendEmail = ({ userId = '', emailAddress = '', emailVerified, t }) => (
|
|
<div>
|
|
{userId && !emailVerified ? <Alert className="verify-email text-center"><p><Trans i18nKey="verifyEmail" values={{ email: emailAddress }} /> <Button variant="link" onClick={() => handleResendVerificationEmail(emailAddress, t)} href="#"><Trans parent="span">Reenviar email de verificación</Trans></Button></p></Alert> : ''}
|
|
</div>
|
|
);
|
|
|
|
ReSendEmail.propTypes = {
|
|
loading: PropTypes.bool.isRequired,
|
|
userId: PropTypes.string,
|
|
emailAddress: PropTypes.string,
|
|
emailVerified: PropTypes.bool.isRequired,
|
|
};
|
|
|
|
export default withTranslation()(ReSendEmail);
|