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