'use client'

import { useState } from "react";
import LogUserPage from "./log_user_page";
import LoginPageDashboard from "./login_das";
import toast from "react-hot-toast";

export default function AuthPage() {
   const [valid, setValid] = useState(false)

   function cekPassword(pass: string) {
      if (pass == "wibuSekali") {
         toast.success("Selamat datang di dashboard developer!")
         setTimeout(() => {
            setValid(true)
         }, 2000);
      } else {
         setValid(false)
         toast.error("Password salah")
      }
   }

   if (valid) return <LogUserPage />

   return <LoginPageDashboard onSubmit={(val) => { cekPassword(val) }} />
}