[+] Auto redirect
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { login } from '../logic/sdk';
|
||||
import {isLoggedIn, login} from '../logic/sdk';
|
||||
|
||||
export default function Login() {
|
||||
|
||||
@@ -9,6 +9,12 @@ export default function Login() {
|
||||
const [password, setPassword] = useState("");
|
||||
const [err, setErr] = useState("")
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoggedIn()) {
|
||||
navigate("/courses");
|
||||
}
|
||||
}, []);
|
||||
|
||||
function submitLogin() {
|
||||
try {
|
||||
login(username, password)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import {possibleLangs, signup} from '../logic/sdk';
|
||||
import {isLoggedIn, possibleLangs, signup} from '../logic/sdk';
|
||||
import Progress from "../components/Progress";
|
||||
import DuoWriting from "../assets/img/duo-writing.png";
|
||||
import ChatBox from "../components/ChatBox";
|
||||
@@ -21,6 +21,12 @@ export default function Signup() {
|
||||
_setStage(stage)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoggedIn()) {
|
||||
navigate("/courses");
|
||||
}
|
||||
}, []);
|
||||
|
||||
function submitSignup() {
|
||||
try {
|
||||
if (password !== confirmPassword) {
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
import DuoSplash from "../assets/img/duo-splash.png";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import {isLoggedIn} from "../logic/sdk";
|
||||
import {useEffect} from "react";
|
||||
|
||||
export default function Welcome()
|
||||
{
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoggedIn()) {
|
||||
navigate("/courses");
|
||||
}
|
||||
}, []);
|
||||
|
||||
return <div className="flex flex-col h-screen justify-center">
|
||||
<div className="flex flex-col p-5 gap-5 items-center">
|
||||
<img src={DuoSplash} alt="Duolingo Logo"></img>
|
||||
|
||||
Reference in New Issue
Block a user