2019-12-16 08:49:10 +00:00
|
|
|
import React, { useLayoutEffect } from "react";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { AppState } from "@appsmith/reducers";
|
|
|
|
|
import type { RouteComponentProps } from "react-router-dom";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { withRouter } from "react-router-dom";
|
2019-12-16 08:49:10 +00:00
|
|
|
import { connect } from "react-redux";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { InjectedFormProps } from "redux-form";
|
|
|
|
|
import { reduxForm, Field } from "redux-form";
|
2022-09-02 17:15:08 +00:00
|
|
|
import { RESET_PASSWORD_FORM_NAME } from "@appsmith/constants/forms";
|
2022-04-12 10:50:01 +00:00
|
|
|
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
|
2019-12-16 08:49:10 +00:00
|
|
|
import { getIsTokenValid, getIsValidatingToken } from "selectors/authSelectors";
|
2022-10-05 11:06:49 +00:00
|
|
|
import FormTextField from "components/utils/ReduxFormTextField";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { Button, Callout, Link } from "design-system";
|
2019-12-16 08:49:10 +00:00
|
|
|
import Spinner from "components/editorComponents/Spinner";
|
|
|
|
|
import StyledForm from "components/editorComponents/Form";
|
|
|
|
|
import { isEmptyString, isStrongPassword } from "utils/formhelpers";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ResetPasswordFormValues } from "./helpers";
|
|
|
|
|
import { resetPasswordSubmitHandler } from "./helpers";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { FormActions, StyledFormGroup } from "./StyledComponents";
|
2019-12-16 08:49:10 +00:00
|
|
|
import { AUTH_LOGIN_URL, FORGOT_PASSWORD_URL } from "constants/routes";
|
|
|
|
|
import {
|
|
|
|
|
RESET_PASSWORD_PAGE_PASSWORD_INPUT_LABEL,
|
|
|
|
|
RESET_PASSWORD_PAGE_PASSWORD_INPUT_PLACEHOLDER,
|
|
|
|
|
RESET_PASSWORD_LOGIN_LINK_TEXT,
|
|
|
|
|
RESET_PASSWORD_SUBMIT_BUTTON_TEXT,
|
|
|
|
|
RESET_PASSWORD_PAGE_TITLE,
|
|
|
|
|
FORM_VALIDATION_INVALID_PASSWORD,
|
|
|
|
|
FORM_VALIDATION_EMPTY_PASSWORD,
|
|
|
|
|
RESET_PASSWORD_EXPIRED_TOKEN,
|
|
|
|
|
RESET_PASSWORD_FORGOT_PASSWORD_LINK,
|
|
|
|
|
RESET_PASSWORD_INVALID_TOKEN,
|
|
|
|
|
RESET_PASSWORD_RESET_SUCCESS,
|
|
|
|
|
RESET_PASSWORD_RESET_SUCCESS_LOGIN_LINK,
|
2021-03-13 14:24:45 +00:00
|
|
|
createMessage,
|
2022-02-11 18:08:46 +00:00
|
|
|
} from "@appsmith/constants/messages";
|
2022-12-09 14:43:47 +00:00
|
|
|
import Container from "./Container";
|
2023-05-19 18:37:06 +00:00
|
|
|
import type { CalloutProps } from "design-system/build/Callout/Callout.types";
|
2019-12-16 08:49:10 +00:00
|
|
|
|
|
|
|
|
const validate = (values: ResetPasswordFormValues) => {
|
|
|
|
|
const errors: ResetPasswordFormValues = {};
|
|
|
|
|
if (!values.password || isEmptyString(values.password)) {
|
2021-03-13 14:24:45 +00:00
|
|
|
errors.password = createMessage(FORM_VALIDATION_EMPTY_PASSWORD);
|
2019-12-16 08:49:10 +00:00
|
|
|
} else if (!isStrongPassword(values.password)) {
|
2021-03-13 14:24:45 +00:00
|
|
|
errors.password = createMessage(FORM_VALIDATION_INVALID_PASSWORD);
|
2019-12-16 08:49:10 +00:00
|
|
|
}
|
|
|
|
|
return errors;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type ResetPasswordProps = InjectedFormProps<
|
|
|
|
|
ResetPasswordFormValues,
|
|
|
|
|
{
|
2021-08-17 12:35:00 +00:00
|
|
|
verifyToken: (token: string) => void;
|
2019-12-16 08:49:10 +00:00
|
|
|
isTokenValid: boolean;
|
|
|
|
|
validatingToken: boolean;
|
|
|
|
|
}
|
|
|
|
|
> & {
|
2021-08-17 12:35:00 +00:00
|
|
|
verifyToken: (token: string) => void;
|
2019-12-16 08:49:10 +00:00
|
|
|
isTokenValid: boolean;
|
|
|
|
|
validatingToken: boolean;
|
|
|
|
|
} & RouteComponentProps<{ email: string; token: string }>;
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
export function ResetPassword(props: ResetPasswordProps) {
|
2019-12-16 08:49:10 +00:00
|
|
|
const {
|
|
|
|
|
error,
|
|
|
|
|
handleSubmit,
|
|
|
|
|
initialValues,
|
|
|
|
|
isTokenValid,
|
2021-05-13 08:35:39 +00:00
|
|
|
pristine,
|
|
|
|
|
submitFailed,
|
|
|
|
|
submitSucceeded,
|
|
|
|
|
submitting,
|
2019-12-16 08:49:10 +00:00
|
|
|
validatingToken,
|
|
|
|
|
verifyToken,
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
useLayoutEffect(() => {
|
2021-08-17 12:35:00 +00:00
|
|
|
if (initialValues.token) verifyToken(initialValues.token);
|
|
|
|
|
}, [initialValues.token, verifyToken]);
|
2019-12-16 08:49:10 +00:00
|
|
|
|
2021-08-17 12:35:00 +00:00
|
|
|
const showInvalidMessage = !initialValues.token;
|
2019-12-16 08:49:10 +00:00
|
|
|
const showExpiredMessage = !isTokenValid && !validatingToken;
|
|
|
|
|
const showSuccessMessage = submitSucceeded && !pristine;
|
|
|
|
|
const showFailureMessage = submitFailed && !!error;
|
|
|
|
|
|
|
|
|
|
let message = "";
|
2023-05-19 18:37:06 +00:00
|
|
|
let messageActions = undefined;
|
2019-12-16 08:49:10 +00:00
|
|
|
if (showExpiredMessage || showInvalidMessage) {
|
2022-11-30 05:10:53 +00:00
|
|
|
const messageActionText = createMessage(
|
|
|
|
|
RESET_PASSWORD_FORGOT_PASSWORD_LINK,
|
|
|
|
|
);
|
2019-12-16 08:49:10 +00:00
|
|
|
messageActions = [
|
|
|
|
|
{
|
2023-05-19 18:37:06 +00:00
|
|
|
to: FORGOT_PASSWORD_URL,
|
|
|
|
|
children: messageActionText,
|
|
|
|
|
target: "_self",
|
2019-12-16 08:49:10 +00:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if (showExpiredMessage) {
|
2021-03-13 14:24:45 +00:00
|
|
|
message = createMessage(RESET_PASSWORD_EXPIRED_TOKEN);
|
2019-12-16 08:49:10 +00:00
|
|
|
}
|
|
|
|
|
if (showInvalidMessage) {
|
2021-03-13 14:24:45 +00:00
|
|
|
message = createMessage(RESET_PASSWORD_INVALID_TOKEN);
|
2019-12-16 08:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (showSuccessMessage) {
|
2022-11-30 05:10:53 +00:00
|
|
|
const messageActionText = createMessage(
|
|
|
|
|
RESET_PASSWORD_RESET_SUCCESS_LOGIN_LINK,
|
|
|
|
|
);
|
2021-03-13 14:24:45 +00:00
|
|
|
message = createMessage(RESET_PASSWORD_RESET_SUCCESS);
|
2019-12-16 08:49:10 +00:00
|
|
|
messageActions = [
|
|
|
|
|
{
|
2023-05-19 18:37:06 +00:00
|
|
|
to: AUTH_LOGIN_URL,
|
|
|
|
|
children: messageActionText,
|
|
|
|
|
target: "_self",
|
2019-12-16 08:49:10 +00:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if (showFailureMessage) {
|
|
|
|
|
message = error;
|
2020-10-16 14:18:03 +00:00
|
|
|
if (
|
|
|
|
|
message
|
|
|
|
|
.toLowerCase()
|
2021-03-13 14:24:45 +00:00
|
|
|
.includes(
|
|
|
|
|
createMessage(RESET_PASSWORD_FORGOT_PASSWORD_LINK).toLowerCase(),
|
|
|
|
|
)
|
2020-10-16 14:18:03 +00:00
|
|
|
) {
|
2022-11-30 05:10:53 +00:00
|
|
|
const messageActionText = createMessage(
|
|
|
|
|
RESET_PASSWORD_FORGOT_PASSWORD_LINK,
|
|
|
|
|
);
|
2020-10-16 14:18:03 +00:00
|
|
|
messageActions = [
|
|
|
|
|
{
|
2023-05-19 18:37:06 +00:00
|
|
|
to: FORGOT_PASSWORD_URL,
|
|
|
|
|
children: messageActionText,
|
|
|
|
|
target: "_self",
|
2020-10-16 14:18:03 +00:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
}
|
2019-12-16 08:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const messageTagProps: CalloutProps = {
|
|
|
|
|
kind:
|
2019-12-16 08:49:10 +00:00
|
|
|
showInvalidMessage || showExpiredMessage || showFailureMessage
|
2023-05-19 18:37:06 +00:00
|
|
|
? "error"
|
|
|
|
|
: "success",
|
|
|
|
|
links: messageActions,
|
|
|
|
|
children: message,
|
2019-12-16 08:49:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (showInvalidMessage || showExpiredMessage) {
|
2023-05-19 18:37:06 +00:00
|
|
|
return <Callout {...messageTagProps} />;
|
2019-12-16 08:49:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isTokenValid && validatingToken) {
|
|
|
|
|
return <Spinner />;
|
|
|
|
|
}
|
|
|
|
|
return (
|
2022-12-09 14:43:47 +00:00
|
|
|
<Container
|
|
|
|
|
subtitle={
|
2023-05-19 18:37:06 +00:00
|
|
|
<Link
|
|
|
|
|
className="text-sm justify-center"
|
|
|
|
|
startIcon="arrow-left-line"
|
|
|
|
|
target="_self"
|
|
|
|
|
to={AUTH_LOGIN_URL}
|
|
|
|
|
>
|
2021-03-13 14:24:45 +00:00
|
|
|
{createMessage(RESET_PASSWORD_LOGIN_LINK_TEXT)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</Link>
|
2022-12-09 14:43:47 +00:00
|
|
|
}
|
|
|
|
|
title={createMessage(RESET_PASSWORD_PAGE_TITLE)}
|
|
|
|
|
>
|
2021-01-27 06:12:32 +00:00
|
|
|
{(showSuccessMessage || showFailureMessage) && (
|
2023-05-19 18:37:06 +00:00
|
|
|
<Callout {...messageTagProps} />
|
2021-01-27 06:12:32 +00:00
|
|
|
)}
|
|
|
|
|
<StyledForm onSubmit={handleSubmit(resetPasswordSubmitHandler)}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<StyledFormGroup
|
|
|
|
|
className="text-[color:var(--ads-v2\-color-fg)]"
|
2021-01-27 06:12:32 +00:00
|
|
|
intent={error ? "danger" : "none"}
|
2021-03-13 14:24:45 +00:00
|
|
|
label={createMessage(RESET_PASSWORD_PAGE_PASSWORD_INPUT_LABEL)}
|
2021-01-27 06:12:32 +00:00
|
|
|
>
|
|
|
|
|
<FormTextField
|
2021-04-28 10:28:39 +00:00
|
|
|
disabled={submitSucceeded}
|
2021-01-27 06:12:32 +00:00
|
|
|
name="password"
|
2021-03-13 14:24:45 +00:00
|
|
|
placeholder={createMessage(
|
|
|
|
|
RESET_PASSWORD_PAGE_PASSWORD_INPUT_PLACEHOLDER,
|
|
|
|
|
)}
|
2021-04-28 10:28:39 +00:00
|
|
|
type="password"
|
2021-01-27 06:12:32 +00:00
|
|
|
/>
|
2023-05-19 18:37:06 +00:00
|
|
|
</StyledFormGroup>
|
2021-04-28 10:28:39 +00:00
|
|
|
<Field component="input" name="email" type="hidden" />
|
|
|
|
|
<Field component="input" name="token" type="hidden" />
|
2021-01-27 06:12:32 +00:00
|
|
|
<FormActions>
|
|
|
|
|
<Button
|
2023-05-19 18:37:06 +00:00
|
|
|
isDisabled={pristine || submitSucceeded}
|
2021-04-28 10:28:39 +00:00
|
|
|
isLoading={submitting}
|
2023-05-19 18:37:06 +00:00
|
|
|
size="md"
|
2021-04-28 10:28:39 +00:00
|
|
|
type="submit"
|
2023-05-19 18:37:06 +00:00
|
|
|
>
|
|
|
|
|
{createMessage(RESET_PASSWORD_SUBMIT_BUTTON_TEXT)}
|
|
|
|
|
</Button>
|
2021-01-27 06:12:32 +00:00
|
|
|
</FormActions>
|
|
|
|
|
</StyledForm>
|
2022-12-09 14:43:47 +00:00
|
|
|
</Container>
|
2019-12-16 08:49:10 +00:00
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2019-12-16 08:49:10 +00:00
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|
(state: AppState, props: ResetPasswordProps) => {
|
|
|
|
|
const queryParams = new URLSearchParams(props.location.search);
|
|
|
|
|
return {
|
|
|
|
|
initialValues: {
|
|
|
|
|
token: queryParams.get("token") || undefined,
|
|
|
|
|
},
|
|
|
|
|
isTokenValid: getIsTokenValid(state),
|
|
|
|
|
validatingToken: getIsValidatingToken(state),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
(dispatch: any) => ({
|
2021-08-17 12:35:00 +00:00
|
|
|
verifyToken: (token: string) =>
|
2019-12-16 08:49:10 +00:00
|
|
|
dispatch({
|
|
|
|
|
type: ReduxActionTypes.RESET_PASSWORD_VERIFY_TOKEN_INIT,
|
2021-08-17 12:35:00 +00:00
|
|
|
payload: { token },
|
2019-12-16 08:49:10 +00:00
|
|
|
}),
|
|
|
|
|
}),
|
|
|
|
|
)(
|
|
|
|
|
reduxForm<
|
|
|
|
|
ResetPasswordFormValues,
|
|
|
|
|
{
|
2021-08-17 12:35:00 +00:00
|
|
|
verifyToken: (token: string) => void;
|
2019-12-16 08:49:10 +00:00
|
|
|
validatingToken: boolean;
|
|
|
|
|
isTokenValid: boolean;
|
|
|
|
|
}
|
|
|
|
|
>({
|
|
|
|
|
validate,
|
|
|
|
|
form: RESET_PASSWORD_FORM_NAME,
|
|
|
|
|
touchOnBlur: true,
|
2023-01-13 11:05:59 +00:00
|
|
|
})(withRouter(ResetPassword)),
|
2019-12-16 08:49:10 +00:00
|
|
|
);
|