-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "build: migrate to SDK-V2 (#200)"
This reverts commit adb346c.
- Loading branch information
Showing
16 changed files
with
102 additions
and
106 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./useLogin"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as microsoftTeams from "@microsoft/teams-js"; | ||
import { useCallback, useState } from "react"; | ||
|
||
interface UseLoginParams { | ||
onSuccess: (code?: string) => Promise<void>; | ||
} | ||
|
||
type UseLoginResult = [ | ||
() => void, | ||
{ | ||
loginError?: string; | ||
} | ||
] | ||
|
||
const errorToText = (error?: string): string => { | ||
switch (error) { | ||
case "CancelledByUser": | ||
case "access_denied": | ||
return "You need to authorize Microsoft Teams app to connect your Zeplin projects and styleguides."; | ||
default: | ||
return "Authorization failed due to an API related connectivity issue. Please retry logging in."; | ||
} | ||
}; | ||
|
||
export const useLogin = ({ onSuccess }: UseLoginParams): UseLoginResult => { | ||
const [loginError, setError] = useState<string|undefined>(); | ||
|
||
const login = useCallback( | ||
() => microsoftTeams.authentication.authenticate({ | ||
height: 476, | ||
successCallback: onSuccess, | ||
failureCallback: value => setError(errorToText(value)), | ||
url: "/api/auth/authorize" | ||
}), | ||
[] | ||
); | ||
|
||
return [login, { loginError }]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.