ToolJet/frontend/src/ForgotPassword/ForgotPasswordPage.jsx
Kavin Venkatachalam 7f702c1d6b
[Feature]: Added Localisation (#3746)
* Added localisation

* Closed modal after language selection

* updated transaltaion setup

* Updated language tooltip

* Added fallback language support

* Adding english library resource for translation (#3844)

* Adding English dictionary for the widget lists in the inspector

* added leftSideBar object in en.json and implemented it for leftSidebar icon text

* renamed leftSideBar to leftSidebar and added resources for tip in the left side bar

* added english translation resources for leftsidebar debugger

* added english language resources for the global settings

* added english language resources for data sources in left sidebar

* added english language resources for the share button and share modal in the editor

* added english language resources for release button, manageOrgUsers, appVersionManager

* added english language resources for Queries and Please select a widget to inspect in the editor

* added english language resources for data source list , data source manager, and query manager(partially)

* added english language resources for queryManager, transformation, preview

* added english language resources for dark mode toggle in the headers inside homepage

* added fallback message for dark mode toggle

* added resources for language change in the headers inside homepage

* added resources for notification center in the header inside homepage

* added resources for organization and manage users components in header inside homepage

* added resources in manageGroupPermission

* added resources for manageGroupPermissionsResources component

* added resources for manageSSO and generalSettings components

* added resources for google sso

* added resources for github sso

* added resources for environment variables in manageSSO

* added resources for profile and setting page

* added resources for app card and app card menu

* added resources for folder section and app list in homepage

* added resources for header section in the homepage

* added resources for pagination in homepage

* added resources for modals in the homepage

* added resources for blank page

* added resources for login page

* added resources for forgot password page

* added resources for sign up page

* added resources for onBoarding component

* added resources for reset password page

* deleted duplicate key for readDocumentation

* deleted duplicate key for cancel in en.json and added translation for cancel at few places

* removing duplicate copy of save key in en.json

* added translation for CommentActions.jsx components

* deleted duplicate copy of search key in en.json and added resources for create and search queries , select keys

* fix typo errors

* fixed typo errors

* shorten the key for loginAndSignUpAndForgotPassword to loginSignupPage in en.json file and related files

* shorten the key noLoginMethodsEnabledForThisWorkspace to noLoginMethodsEnabled

* shorten the key pleaseCheckYourEmailForConfirmationLink to emailConfirmLink

* shorten the key dontHaveAccountYet to dontHaveAccount

* shorten keys from loginSignupPage key in en.json

* shorten keys of shareModal nested object in en.json

* shorten the key in appVersionManager nested object

* shorten the keys for queryManager nested object in the en.json

* delete duplicate copy of environmentVar and shorten manageEnvironmentVariables,environmentVariables

* shorten keys in the organization nested object

* shorten keys in the homePage nested object in en.json file

* added inspector and eventManager empty object

* added resources to RedirectSSO component

* added resources for OAuth2

* added resources for TemplateCard.jsx

* added resources for TemplateLibraryModal.jsx

* added resources for ConfirmationPage.jsx

* added resources for ConfirmationPage component

* removed translation in App.jsx file

* added resources for Slack.jsx

* added resources for GoogleSheets.jsx

* added resources for CodeBuilder.jsx

* added resources for CommentBody and CommentFooter

* added resources for TestConnection component

* added resources for AllignButton.jsx

* added resources for Openapi and Stripe components

* added resources for ErrorBoundary

* added resources for Viewer.jsx

* Translation for widgets, table

Co-authored-by: Kavin Venkatachalam <kavin.saratha@gmail.com>

* Commented Language selection

* Fixed typos

* Updated fr.json file

Co-authored-by: Manish Kushare <kushare.manish9@gmail.com>
2022-09-14 13:34:49 +05:30

100 lines
3.3 KiB
JavaScript

import React from 'react';
import { Link } from 'react-router-dom';
import { toast } from 'react-hot-toast';
import { validateEmail } from '../_helpers/utils';
import { authenticationService } from '@/_services';
import { withTranslation } from 'react-i18next';
class ForgotPasswordComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoading: false,
email: '',
};
}
handleChange = (event) => {
this.setState({ [event.target.name]: event.target.value });
};
handleClick = (event) => {
event.preventDefault();
if (!validateEmail(this.state.email)) {
toast.error('Invalid email', {
id: 'toast-forgot-password-email-error',
});
return;
}
this.setState({ isLoading: true });
authenticationService
.forgotPassword(this.state.email)
.then(() => {
toast.success('Password reset link sent to the email id, please check your mail', {
id: 'toast-forgot-password-confirmation-code',
});
this.props.history.push('/login');
})
.catch((res) => {
toast.error(res.error || 'Something went wrong, please try again', {
id: 'toast-forgot-password-email-error',
});
this.setState({ isLoading: false });
});
};
render() {
const { isLoading } = this.state;
return (
<div className="page page-center">
<div className="container-tight py-2">
<div className="text-center mb-4">
<a href="." className="navbar-brand-autodark">
<img src="assets/images/logo-color.svg" height="30" alt="" />
</a>
</div>
<form className="card card-md" action="." method="get" autoComplete="off">
<div className="card-body">
<h2 className="card-title text-center mb-4">
{this.props.t('loginSignupPage.forgotPassword', 'Forgot Password')}
</h2>
<div className="mb-3">
<label className="form-label">{this.props.t('loginSignupPage.emailAddress', 'Email address')}</label>
<input
onChange={this.handleChange}
name="email"
type="email"
className="form-control"
placeholder={this.props.t('loginSignupPage.enterEmail', 'Enter email')}
data-testid="emailField"
/>
</div>
<div className="form-footer">
<button
data-testid="submitButton"
className={`btn btn-primary w-100 ${isLoading ? 'btn-loading' : ''}`}
onClick={this.handleClick}
disabled={isLoading || !this.state.email}
>
{this.props.t('loginSignupPage.resetPassword', 'Reset Password')}
</button>
</div>
</div>
</form>
<div className="text-center text-muted mt-3">
{this.props.t('loginSignupPage.dontHaveAccount', `Don't have account yet?`)}
<Link to={'/signup'} tabIndex="-1">
{this.props.t('loginSignupPage.signUp', `Sign up`)}
</Link>
</div>
</div>
</div>
);
}
}
export const ForgotPassword = withTranslation()(ForgotPasswordComponent);