From c364a4a9cfcc4d03ab0fd6f0cb5fb00f293c0bbe Mon Sep 17 00:00:00 2001 From: Pauline Date: Mon, 14 Oct 2024 16:09:45 +0800 Subject: [PATCH] Fix formatting --- pages/fitbit.tsx | 1 - services/rest-source-client.ts | 29 +++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/pages/fitbit.tsx b/pages/fitbit.tsx index a8d1ffc..a3c27dc 100644 --- a/pages/fitbit.tsx +++ b/pages/fitbit.tsx @@ -40,7 +40,6 @@ const Fitbit: NextPage = () => { const traits = data?.identity?.traits setTraits(traits) setProjects(traits.projects) // - }) }, [flowId, router, router.isReady, returnTo]) diff --git a/services/rest-source-client.ts b/services/rest-source-client.ts index 55a8c8a..4950c5a 100644 --- a/services/rest-source-client.ts +++ b/services/rest-source-client.ts @@ -12,7 +12,10 @@ export class RestSourceClient { private readonly FRONTEND_ENDPOINT = `${publicRuntimeConfig.restSourceFrontendEndpoint}` private readonly SOURCE_TYPE = "Oura" - async getRestSourceUser(accessToken: string, project: any): Promise { + async getRestSourceUser( + accessToken: string, + project: any, + ): Promise { try { const response = await fetch(this.USER_ENDPOINT, { method: "POST", @@ -34,13 +37,14 @@ export class RestSourceClient { console.warn("User already exists:", data.message) return data.user.id } else { - throw new Error(`Failed to create user: ${data.message || response.statusText}`) + throw new Error( + `Failed to create user: ${data.message || response.statusText}`, + ) } } const userDto = await response.json() return userDto.id - } catch (error) { console.error(error) return null @@ -67,7 +71,9 @@ export class RestSourceClient { }) if (!response.ok) { - throw new Error(`Failed to retrieve access token: ${response.statusText}`) + throw new Error( + `Failed to retrieve access token: ${response.statusText}`, + ) } const data = await response.json() @@ -105,7 +111,10 @@ export class RestSourceClient { window.location.href = authUrl } - async getRestSourceAuthLink(accessToken: string, project: any): Promise { + async getRestSourceAuthLink( + accessToken: string, + project: any, + ): Promise { try { const userId = await this.getRestSourceUser(accessToken, project) if (!userId) { @@ -125,7 +134,9 @@ export class RestSourceClient { }) if (!response.ok) { - throw new Error(`Failed to retrieve registration token: ${response.statusText}`) + throw new Error( + `Failed to retrieve registration token: ${response.statusText}`, + ) } const data = await response.json() @@ -134,14 +145,16 @@ export class RestSourceClient { } return `${this.FRONTEND_ENDPOINT}/users:auth?token=${data.token}&secret=${data.secret}` - } catch (error) { console.error(error) return null } } - async redirectToRestSourceAuthLink(accessToken: string, project: any): Promise { + async redirectToRestSourceAuthLink( + accessToken: string, + project: any, + ): Promise { const url = await this.getRestSourceAuthLink(accessToken, project) if (url) { console.log("Redirecting to: ", url)