|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import styles from "./styles/Animation.module.css" |
| 4 | +import { MouseEvent, useState, Dispatch, SetStateAction } from 'react' |
| 5 | +import { Silkscreen } from 'next/font/google'; |
| 6 | + |
| 7 | + |
| 8 | +const silkScreen = Silkscreen({ |
| 9 | + subsets: ["latin"], |
| 10 | + style: "normal", |
| 11 | + weight: '400' |
| 12 | +}) |
| 13 | + |
| 14 | + |
| 15 | +export default function Loading({ setTriggerLoading }: { setTriggerLoading: Dispatch<SetStateAction<boolean>> }) { |
| 16 | + const [loadingBar, setLoadingBar] = useState(false); |
| 17 | + const [allowAccess, setAllowAccess] = useState(false); |
| 18 | + const [error, setError] = useState(false); |
| 19 | + |
| 20 | + const handleLoadClick = async (e: MouseEvent) => { |
| 21 | + e.preventDefault(); |
| 22 | + setLoadingBar(true) |
| 23 | + setTimeout(() => setAllowAccess(true), 3000); // wait 8 seconds to do something |
| 24 | + setTimeout(() => setError(true), 4000); // wait 8 seconds to do something |
| 25 | + setTimeout(() => setTriggerLoading(false), 5000) |
| 26 | + } |
| 27 | + |
| 28 | + return ( |
| 29 | + <div style={silkScreen.style} className='flex flex-col items-center justify-center h-screen w-full'> |
| 30 | + {!error ? |
| 31 | + <> |
| 32 | + <div> |
| 33 | + <button onClick={(e) => handleLoadClick(e)} className={allowAccess ? "py-4 px-8 bg-green-500 mb-8" : "py-4 px-8 bg-red-600 mb-8"}>Secure Connection</button> |
| 34 | + </div> |
| 35 | + <div className='inline-block mb-8'> |
| 36 | + <p className={styles.typed}>Welcome to AuthHacks. Secure connection to continue.</p> |
| 37 | + </div> |
| 38 | + {loadingBar && |
| 39 | + <div className="absolute mt-[27vh] w-7/12"> |
| 40 | + <div className={styles.loading}></div> |
| 41 | + <p className={allowAccess ? "mt-4 text-sm text-green-400" : "mt-4 text-sm text-red-500"}>Loading</p> |
| 42 | + </div> |
| 43 | + } |
| 44 | + </> |
| 45 | + : |
| 46 | + <> |
| 47 | + <p className="text-6xl max-w-full">Rebooting...</p> |
| 48 | + </> |
| 49 | + } |
| 50 | + </div> |
| 51 | + ) |
| 52 | +} |
0 commit comments