import { observer } from "mobx-react-lite"; // ui import { TOAST_TYPE, setToast } from "@plane/ui"; // components import { GitHubSignInButton, GoogleSignInButton } from "@/components/account"; // hooks import { useApplication } from "@/hooks/store"; // services import { AuthService } from "@/services/auth.service"; type Props = { handleSignInRedirection: () => Promise; type: "sign_in" | "sign_up"; }; // services const authService = new AuthService(); export const OAuthOptions: React.FC = observer((props) => { const { handleSignInRedirection, type } = props; // mobx store const { config: { envConfig }, } = useApplication(); // derived values const areBothOAuthEnabled = envConfig?.google_client_id && envConfig?.github_client_id; const handleGoogleSignIn = async ({ clientId, credential }: any) => { try { if (clientId && credential) { const socialAuthPayload = { medium: "google", credential, clientId, }; const response = await authService.socialAuth(socialAuthPayload); if (response) handleSignInRedirection(); } else throw Error("Can't find credentials"); } catch (err: any) { setToast({ type: TOAST_TYPE.ERROR, title: "Error signing in!", message: err?.error || "Something went wrong. Please try again later or contact the support team.", }); } }; const handleGitHubSignIn = async (credential: string) => { try { if (envConfig && envConfig.github_client_id && credential) { const socialAuthPayload = { medium: "github", credential, clientId: envConfig.github_client_id, }; const response = await authService.socialAuth(socialAuthPayload); if (response) handleSignInRedirection(); } else throw Error("Can't find credentials"); } catch (err: any) { setToast({ type: TOAST_TYPE.ERROR, title: "Error signing in!", message: err?.error || "Something went wrong. Please try again later or contact the support team.", }); } }; return ( <>

Or continue with


{envConfig?.google_client_id && (
)} {envConfig?.github_client_id && ( )}
); });