blob: 1d8c5ce0535a1e3402cd7ecf1050464d7f787871 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import '../styles/globals.css';
import NextProgress from "next-progress";
import { ToastContainer, Slide } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import Image from 'next/image';
function MyApp({ Component, pageProps }) {
const router = useRouter();
const [pageLoading, setPageLoading] = useState(false);
useEffect(() => {
const handleStartLoading = () => { setPageLoading(true) };
const handleCompleteLoading = () => { setPageLoading(false) };
router.events.on('routeChangeStart', handleStartLoading);
router.events.on('routeChangeComplete', handleCompleteLoading);
router.events.on('routeChangeError', handleCompleteLoading);
}, [router]);
return (
<>
<ToastContainer
position='top-center'
autoClose={5000}
theme='light'
closeOnClick={false}
transition={Slide}
limit={1}
/>
<NextProgress color="#D7A30A" options={{
showSpinner: false,
}} />
{pageLoading ? (
<div className='h-screen w-screen flex flex-col justify-center items-center'>
<Image src='/images/loading.gif' width={64} height={64} alt='Loading Indoteknik' />
<h1>Loading</h1>
</div>
) : <Component {...pageProps} />}
</>
)
}
export default MyApp
|