mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
update sign-in page
This commit is contained in:
parent
e450041d71
commit
f950028455
@ -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>
|
||||||
|
@ -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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user