update sign-in page

This commit is contained in:
AykutSarac 2023-02-11 20:16:32 +03:00
parent e450041d71
commit f950028455
No known key found for this signature in database
2 changed files with 10 additions and 12 deletions

View File

@ -1,22 +1,20 @@
import React from "react"; import React from "react";
import { altogic } from "src/api/altogic"; import Link from "next/link";
import { Button } from "src/components/Button"; import { Button } from "src/components/Button";
import { Modal, ModalProps } from "src/components/Modal"; import { Modal, ModalProps } from "src/components/Modal";
export const LoginModal: React.FC<ModalProps> = ({ setVisible, visible }) => { export const LoginModal: React.FC<ModalProps> = ({ setVisible, visible }) => {
const onSignIn = () => {
altogic.auth.signInWithProvider("google");
};
return ( return (
<Modal visible={visible} setVisible={setVisible}> <Modal visible={visible} setVisible={setVisible}>
<Modal.Header>Login</Modal.Header> <Modal.Header>Login</Modal.Header>
<Modal.Content> <Modal.Content>
<h2>Welcome Back!</h2> <h2>Welcome Back!</h2>
<p>Login to unlock full potential of JSON Crack!</p> <p>Login to unlock full potential of JSON Crack!</p>
<Button onClick={onSignIn} status="SECONDARY" block> <Link href="/sign-in">
Sign In <Button onClick={() => setVisible(false)} status="SECONDARY" block>
</Button> Sign In
</Button>
</Link>
</Modal.Content> </Modal.Content>
<Modal.Controls setVisible={setVisible} /> <Modal.Controls setVisible={setVisible} />
</Modal> </Modal>

View File

@ -31,13 +31,13 @@ const StyledLoginButtons = styled.div`
const SignIn = () => { const SignIn = () => {
const { isReady, replace } = useRouter(); const { isReady, replace } = useRouter();
const tokenAuth = useUser(state => state.tokenAuth); const checkSession = useUser(state => state.checkSession);
const isAuthenticated = useUser(state => state.isAuthenticated); const isAuthenticated = useUser(state => state.isAuthenticated);
React.useEffect(() => { React.useEffect(() => {
if (isAuthenticated) replace("/editor"); if (!isReady) checkSession();
if (isReady) tokenAuth(); if (isAuthenticated) replace("/editor");
}, [tokenAuth, isReady, isAuthenticated, replace]); }, [isReady, isAuthenticated, replace, checkSession]);
const handleLoginClick = (provider: "github" | "google") => { const handleLoginClick = (provider: "github" | "google") => {
altogic.auth.signInWithProvider(provider); altogic.auth.signInWithProvider(provider);