fix: correct LoginContext setter types and remove dead PASSWORD_RESET_ERROR code

LoginContext setFormFields/setErrors are useState setters that accept
updater functions, so their types should be Dispatch<SetStateAction<...>>
rather than plain function signatures.

PASSWORD_RESET_ERROR was checked in ResetPasswordPage but no code path
ever set status to that value, making the conditions dead code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Adolfo R. Brandes
2026-03-06 19:11:52 -03:00
committed by Adolfo R. Brandes
parent 1733f6ec01
commit fc40952da3
3 changed files with 7 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import {
createContext, FC, ReactNode, useContext, useMemo, useState,
createContext, Dispatch, FC, ReactNode, SetStateAction, useContext, useMemo, useState,
} from 'react';
export interface FormFields {
@@ -14,9 +14,9 @@ export interface FormErrors {
interface LoginContextType {
formFields: FormFields,
setFormFields: (fields: FormFields) => void,
setFormFields: Dispatch<SetStateAction<FormFields>>,
errors: FormErrors,
setErrors: (errors: FormErrors) => void,
setErrors: Dispatch<SetStateAction<FormErrors>>,
}
const LoginContext = createContext<LoginContextType | undefined>(undefined);

View File

@@ -17,7 +17,7 @@ import BaseContainer from '../base-container';
import { validatePassword } from './data/api';
import { useResetPassword, useValidateToken } from './data/apiHook';
import {
FORM_SUBMISSION_ERROR, PASSWORD_RESET, PASSWORD_RESET_ERROR, PASSWORD_VALIDATION_ERROR, TOKEN_STATE,
FORM_SUBMISSION_ERROR, PASSWORD_RESET, PASSWORD_VALIDATION_ERROR, TOKEN_STATE,
} from './data/constants';
import messages from './messages';
import ResetPasswordFailure from './ResetPasswordFailure';
@@ -47,7 +47,7 @@ const ResetPasswordPageInner = () => {
const { mutate: resetUserPassword, isPending: isResetting } = useResetPassword();
useEffect(() => {
if (status !== TOKEN_STATE.PENDING && status !== PASSWORD_RESET_ERROR) {
if (status !== TOKEN_STATE.PENDING) {
setErrorCode(status);
}
if (status === PASSWORD_VALIDATION_ERROR) {
@@ -176,7 +176,7 @@ const ResetPasswordPageInner = () => {
);
useEffect(() => {
if (status === PASSWORD_RESET_ERROR || status === PASSWORD_RESET.INVALID_TOKEN) {
if (status === PASSWORD_RESET.INVALID_TOKEN) {
navigate(updatePathWithQueryParams(RESET_PAGE), { state: { status } });
}
if (status === 'success') {

View File

@@ -289,7 +289,7 @@ describe('ResetPasswordPage', () => {
});
it('should redirect the user to Reset password email screen ', async () => {
// Mock an error scenario that would cause PASSWORD_RESET_ERROR
// Mock an error scenario that triggers an error state
mockValidateToken.mockImplementation((tokenValue, { onError }) => {
onError({
response: {