From 17534fcd2702f7b803e206d8a334cf7317de8e1d Mon Sep 17 00:00:00 2001 From: simeng-li Date: Mon, 5 Aug 2024 10:15:31 +0800 Subject: [PATCH] fix(experience): fix get sso connectors bug gix get sso connectors bug --- packages/experience/src/apis/experience.ts | 2 +- packages/experience/src/hooks/use-check-single-sign-on.ts | 4 ++-- packages/experience/src/hooks/use-single-sign-on-watch.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/experience/src/apis/experience.ts b/packages/experience/src/apis/experience.ts index de952d30c..56d3553bf 100644 --- a/packages/experience/src/apis/experience.ts +++ b/packages/experience/src/apis/experience.ts @@ -206,7 +206,7 @@ export const getSsoConnectors = async (email: string) => email, }, }) - .json(); + .json<{ connectorIds: string[] }>(); export const getSsoAuthorizationUrl = async (connectorId: string, payload: unknown) => { await initInteraction(InteractionEvent.SignIn); diff --git a/packages/experience/src/hooks/use-check-single-sign-on.ts b/packages/experience/src/hooks/use-check-single-sign-on.ts index 9c26daf97..67a9077d8 100644 --- a/packages/experience/src/hooks/use-check-single-sign-on.ts +++ b/packages/experience/src/hooks/use-check-single-sign-on.ts @@ -56,8 +56,8 @@ const useCheckSingleSignOn = () => { return; } - const connectors = result - ?.map((connectorId) => availableSsoConnectorsMap.get(connectorId)) + const connectors = result?.connectorIds + .map((connectorId) => availableSsoConnectorsMap.get(connectorId)) // eslint-disable-next-line unicorn/prefer-native-coercion-functions -- make the type more specific .filter((connector): connector is SsoConnectorMetadata => Boolean(connector)); diff --git a/packages/experience/src/hooks/use-single-sign-on-watch.ts b/packages/experience/src/hooks/use-single-sign-on-watch.ts index 7b7ae0f29..a9c17f682 100644 --- a/packages/experience/src/hooks/use-single-sign-on-watch.ts +++ b/packages/experience/src/hooks/use-single-sign-on-watch.ts @@ -43,7 +43,7 @@ const useSingleSignOnWatch = (identifierInput?: IdentifierInputValue) => { return false; } - const connectors = result + const connectors = result.connectorIds .map((connectorId) => availableSsoConnectorsMap.get(connectorId)) // eslint-disable-next-line unicorn/prefer-native-coercion-functions -- make the type more specific .filter((connector): connector is SsoConnectorMetadata => Boolean(connector));