0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(console): use getSafe on the sie page (#2735)

This commit is contained in:
Xiao Yijun 2022-12-27 14:47:18 +08:00 committed by GitHub
parent a24b6df53f
commit ae7a89f0ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -1,5 +1,5 @@
import type { SignInIdentifier } from '@logto/schemas'; import type { SignInIdentifier } from '@logto/schemas';
import { get } from '@silverhand/essentials'; import { getSafe } from '@silverhand/essentials';
import { detailedDiff } from 'deep-object-diff'; import { detailedDiff } from 'deep-object-diff';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -28,13 +28,13 @@ const SignInDiffSection = ({ before, after, isAfter = false }: Props) => {
const displaySignInMethodsObject = isAfter ? afterSignInMethodsObject : beforeSignInMethodsObject; const displaySignInMethodsObject = isAfter ? afterSignInMethodsObject : beforeSignInMethodsObject;
const hasIdentifierChanged = (identifierKey: SignInIdentifier) => const hasIdentifierChanged = (identifierKey: SignInIdentifier) =>
get(signInDiff, `added.${identifierKey.toLocaleLowerCase()}`) !== undefined; getSafe(signInDiff, `added.${identifierKey.toLocaleLowerCase()}`) !== undefined;
const hasAuthenticationChanged = ( const hasAuthenticationChanged = (
identifierKey: SignInIdentifier, identifierKey: SignInIdentifier,
authenticationKey: keyof SignInMethodsObject[SignInIdentifier] authenticationKey: keyof SignInMethodsObject[SignInIdentifier]
) => ) =>
get(signInDiff, `updated.${identifierKey.toLocaleLowerCase()}.${authenticationKey}`) !== getSafe(signInDiff, `updated.${identifierKey.toLocaleLowerCase()}.${authenticationKey}`) !==
undefined; undefined;
// eslint-disable-next-line no-restricted-syntax // eslint-disable-next-line no-restricted-syntax

View file

@ -1,5 +1,5 @@
import type { SignUp } from '@logto/schemas'; import type { SignUp } from '@logto/schemas';
import { get } from '@silverhand/essentials'; import { getSafe } from '@silverhand/essentials';
import { diff } from 'deep-object-diff'; import { diff } from 'deep-object-diff';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { snakeCase } from 'snake-case'; import { snakeCase } from 'snake-case';
@ -22,7 +22,7 @@ const SignUpDiffSection = ({ before, after, isAfter = false }: Props) => {
const parsedAfter = signInExperienceParser.toLocalSignUp(after); const parsedAfter = signInExperienceParser.toLocalSignUp(after);
const signUpDiff = isAfter ? diff(parsedBefore, parsedAfter) : diff(parsedAfter, parsedBefore); const signUpDiff = isAfter ? diff(parsedBefore, parsedAfter) : diff(parsedAfter, parsedBefore);
const signUp = isAfter ? parsedAfter : parsedBefore; const signUp = isAfter ? parsedAfter : parsedBefore;
const hasChanged = (path: keyof SignUpForm) => get(signUpDiff, path) !== undefined; const hasChanged = (path: keyof SignUpForm) => getSafe(signUpDiff, path) !== undefined;
const { identifier, password, verify } = signUp; const { identifier, password, verify } = signUp;
const hasAuthentication = password || verify; const hasAuthentication = password || verify;