@@ -1,14 +1,11 @@
import React from "react";
-import { useRouter } from "next/router";
+import { altogic } from "src/api/altogic";
import { Button } from "src/components/Button";
import { Modal, ModalProps } from "src/components/Modal";
export const LoginModal: React.FC<ModalProps> = ({ setVisible, visible }) => {
- const { replace } = useRouter();
-
const onSignIn = () => {
- replace("/sign-in");
- setVisible(false);
+ altogic.auth.signInWithProvider("google");
};
return (
@@ -35,8 +35,8 @@ const SignIn = () => {
const isAuthenticated = useUser(state => state.isAuthenticated);
React.useEffect(() => {
- if (isReady) tokenAuth();
if (isAuthenticated) replace("/editor");
+ if (isReady) tokenAuth();
}, [tokenAuth, isReady, isAuthenticated, replace]);
const handleLoginClick = (provider: "github" | "google") => {