zzz / frontend /src /hooks /use-github-auth-url.ts
ar08's picture
Upload 1040 files
246d201 verified
raw
history blame
719 Bytes
import React from "react";
import { generateGitHubAuthUrl } from "#/utils/generate-github-auth-url";
import { GetConfigResponse } from "#/api/open-hands.types";
interface UseGitHubAuthUrlConfig {
gitHubToken: string | null;
appMode: GetConfigResponse["APP_MODE"] | null;
gitHubClientId: GetConfigResponse["GITHUB_CLIENT_ID"] | null;
}
export const useGitHubAuthUrl = (config: UseGitHubAuthUrlConfig) =>
React.useMemo(() => {
if (config.appMode === "saas" && !config.gitHubToken)
return generateGitHubAuthUrl(
config.gitHubClientId || "",
new URL(window.location.href),
);
return null;
}, [config.gitHubToken, config.appMode, config.gitHubClientId]);