fix:login flow
This commit is contained in:
parent
e6994c1f8c
commit
80f0fa6c0b
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
import { Input } from "@heroui/input";
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { EyeFilledIcon, EyeSlashFilledIcon } from "../icons";
|
||||
import { Button } from "@heroui/button";
|
||||
import Link from "next/link";
|
||||
|
|
@ -26,6 +26,7 @@ import PasswordChecklist from "react-password-checklist";
|
|||
import { Image, InputOtp } from "@heroui/react";
|
||||
|
||||
export default function Login() {
|
||||
const accessToken = Cookies.get("access_token");
|
||||
const router = useRouter();
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const [isVisibleSetup, setIsVisibleSetup] = useState([false, false]);
|
||||
|
|
@ -47,6 +48,12 @@ export default function Login() {
|
|||
const [checkUsernameValue, setCheckUsernameValue] = useState("");
|
||||
const MySwal = withReactContent(Swal);
|
||||
|
||||
useEffect(() => {
|
||||
if (accessToken) {
|
||||
router.push("/admin/dashboard");
|
||||
}
|
||||
}, []);
|
||||
|
||||
const setValUsername = (e: any) => {
|
||||
const uname = e.replaceAll(/[^\w.-]/g, "");
|
||||
setUsername(uname.toLowerCase());
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ import { useEffect, useState } from "react";
|
|||
import Image from "next/image";
|
||||
import { error, success } from "@/config/swal";
|
||||
import { subscription } from "@/services/subscribe";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
export default function FooterNew(props: { margin?: boolean }) {
|
||||
const [emailValue, setEmailValue] = useState("");
|
||||
const accessToken = Cookies.get("access_token");
|
||||
|
||||
const doSubscribe = async () => {
|
||||
const isValidEmail = (email: string): boolean => {
|
||||
|
|
@ -208,7 +210,7 @@ export default function FooterNew(props: { margin?: boolean }) {
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<Link href={`/auth`}>
|
||||
<Link href={accessToken ? "/admin/dashboard" : `/auth`}>
|
||||
<Button className="mt-1 bg-[#BE0106] text-white">
|
||||
<p className="text-xs">Kontributor Wilayah</p>
|
||||
</Button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue