From a0fbd7fcf145a2c5a0ea45ed282b29d88cd68bf2 Mon Sep 17 00:00:00 2001 From: simeng-li Date: Wed, 14 Aug 2024 15:43:01 +0800 Subject: [PATCH] fix(experience): update some namings update some namings --- packages/experience/src/apis/experience.ts | 13 +++++++------ .../src/hooks/use-password-policy-checker.ts | 4 ++-- .../src/hooks/use-password-rejection-handler.ts | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/experience/src/apis/experience.ts b/packages/experience/src/apis/experience.ts index ac19fb356..50fa4ddf1 100644 --- a/packages/experience/src/apis/experience.ts +++ b/packages/experience/src/apis/experience.ts @@ -10,9 +10,10 @@ import api from './api'; const prefix = '/api/experience'; -const experienceRoutes = Object.freeze({ +const experienceApiRoutes = Object.freeze({ prefix, identification: `${prefix}/identification`, + submit: `${prefix}/submit`, verification: `${prefix}/verification`, profile: `${prefix}/profile`, mfa: `${prefix}/profile/mfa`, @@ -27,27 +28,27 @@ type SubmitInteractionResponse = { }; const initInteraction = async (interactionEvent: InteractionEvent) => - api.put(`${experienceRoutes.prefix}`, { + api.put(`${experienceApiRoutes.prefix}`, { json: { interactionEvent, }, }); const identifyUser = async (payload: IdentificationApiPayload = {}) => - api.post(experienceRoutes.identification, { json: payload }); + api.post(experienceApiRoutes.identification, { json: payload }); const submitInteraction = async () => - api.post(`${experienceRoutes.prefix}/submit`).json(); + api.post(`${experienceApiRoutes.submit}`).json(); const updateProfile = async (payload: UpdateProfileApiPayload) => { - await api.post(experienceRoutes.profile, { json: payload }); + await api.post(experienceApiRoutes.profile, { json: payload }); }; export const signInWithPasswordIdentifier = async (payload: PasswordVerificationPayload) => { await initInteraction(InteractionEvent.SignIn); const { verificationId } = await api - .post(`${experienceRoutes.verification}/password`, { + .post(`${experienceApiRoutes.verification}/password`, { json: payload, }) .json(); diff --git a/packages/experience/src/hooks/use-password-policy-checker.ts b/packages/experience/src/hooks/use-password-policy-checker.ts index afc08ff72..0db020b1b 100644 --- a/packages/experience/src/hooks/use-password-policy-checker.ts +++ b/packages/experience/src/hooks/use-password-policy-checker.ts @@ -3,11 +3,11 @@ import { useCallback } from 'react'; import usePasswordErrorMessage from './use-password-error-message'; import { usePasswordPolicy } from './use-sie'; -type PasswordPolicyCheckProps = { +type Options = { setErrorMessage: (message?: string) => void; }; -const usePasswordPolicyChecker = ({ setErrorMessage }: PasswordPolicyCheckProps) => { +const usePasswordPolicyChecker = ({ setErrorMessage }: Options) => { const { getErrorMessage } = usePasswordErrorMessage(); const { policyChecker } = usePasswordPolicy(); diff --git a/packages/experience/src/hooks/use-password-rejection-handler.ts b/packages/experience/src/hooks/use-password-rejection-handler.ts index 99969f039..6a4f8f84b 100644 --- a/packages/experience/src/hooks/use-password-rejection-handler.ts +++ b/packages/experience/src/hooks/use-password-rejection-handler.ts @@ -4,11 +4,11 @@ import { useCallback, useMemo } from 'react'; import type { ErrorHandlers } from './use-error-handler'; import usePasswordErrorMessage from './use-password-error-message'; -type ErrorHandlerProps = { +type Options = { setErrorMessage: (message?: string) => void; }; -const usePasswordRejectionErrorHandler = ({ setErrorMessage }: ErrorHandlerProps) => { +const usePasswordRejectionErrorHandler = ({ setErrorMessage }: Options) => { const { getErrorMessageFromBody } = usePasswordErrorMessage(); const passwordRejectionHandler = useCallback(