feat: implement branded splash screen loading states for user and agent layouts
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import Image from 'next/image';
|
||||||
import { Footer } from '@/components/layout/Footer';
|
import { Footer } from '@/components/layout/Footer';
|
||||||
import { CommonHeader } from '@/components/layout/CommonHeader';
|
import { CommonHeader } from '@/components/layout/CommonHeader';
|
||||||
import { PresenceProvider } from '@/components/providers/presence-provider';
|
import { PresenceProvider } from '@/components/providers/presence-provider';
|
||||||
@@ -33,8 +34,17 @@ export default function AgentLayout({
|
|||||||
|
|
||||||
if (status === 'loading' || !session) {
|
if (status === 'loading' || !session) {
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-white flex items-center justify-center">
|
<div
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]"></div>
|
className="min-h-screen flex flex-col items-center justify-center"
|
||||||
|
style={{ background: 'linear-gradient(to bottom, #c4d9d4, #f0f5fc)' }}
|
||||||
|
>
|
||||||
|
<Image src="/assets/images/splash-house.png" alt="" width={150} height={108} priority />
|
||||||
|
<div className="mt-[35px]">
|
||||||
|
<Image src="/assets/images/splash-logo.png" alt="RE-Quest" width={264} height={55} priority />
|
||||||
|
</div>
|
||||||
|
<div className="mt-8">
|
||||||
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/app/(agent)/loading.tsx
Normal file
32
src/app/(agent)/loading.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
|
export default function AgentLoading() {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="min-h-screen flex flex-col items-center justify-center"
|
||||||
|
style={{
|
||||||
|
background: 'linear-gradient(to bottom, #c4d9d4, #f0f5fc)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
src="/assets/images/splash-house.png"
|
||||||
|
alt="House illustration"
|
||||||
|
width={150}
|
||||||
|
height={108}
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
<div className="mt-[35px]">
|
||||||
|
<Image
|
||||||
|
src="/assets/images/splash-logo.png"
|
||||||
|
alt="RE-Quest logo"
|
||||||
|
width={264}
|
||||||
|
height={55}
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mt-8">
|
||||||
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import { useRouter, usePathname } from 'next/navigation';
|
import { useRouter, usePathname } from 'next/navigation';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import Image from 'next/image';
|
||||||
import { Footer } from '@/components/layout/Footer';
|
import { Footer } from '@/components/layout/Footer';
|
||||||
import { CommonHeader } from '@/components/layout/CommonHeader';
|
import { CommonHeader } from '@/components/layout/CommonHeader';
|
||||||
import { PresenceProvider } from '@/components/providers/presence-provider';
|
import { PresenceProvider } from '@/components/providers/presence-provider';
|
||||||
@@ -58,22 +59,29 @@ export default function UserLayout({
|
|||||||
}
|
}
|
||||||
}, [session, status, router, pathname, isPublic]);
|
}, [session, status, router, pathname, isPublic]);
|
||||||
|
|
||||||
|
const splashLoading = (
|
||||||
|
<div
|
||||||
|
className="min-h-screen flex flex-col items-center justify-center"
|
||||||
|
style={{ background: 'linear-gradient(to bottom, #c4d9d4, #f0f5fc)' }}
|
||||||
|
>
|
||||||
|
<Image src="/assets/images/splash-house.png" alt="" width={150} height={108} priority />
|
||||||
|
<div className="mt-[35px]">
|
||||||
|
<Image src="/assets/images/splash-logo.png" alt="RE-Quest" width={264} height={55} priority />
|
||||||
|
</div>
|
||||||
|
<div className="mt-8">
|
||||||
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
// Show loading only for protected pages while checking auth
|
// Show loading only for protected pages while checking auth
|
||||||
if (status === 'loading' && !isPublic) {
|
if (status === 'loading' && !isPublic) {
|
||||||
return (
|
return splashLoading;
|
||||||
<div className="min-h-screen bg-white flex items-center justify-center">
|
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]"></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect protected pages if not logged in
|
// Redirect protected pages if not logged in
|
||||||
if (!session && !isPublic) {
|
if (!session && !isPublic) {
|
||||||
return (
|
return splashLoading;
|
||||||
<div className="min-h-screen bg-white flex items-center justify-center">
|
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]"></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
32
src/app/(user)/loading.tsx
Normal file
32
src/app/(user)/loading.tsx
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import Image from 'next/image';
|
||||||
|
|
||||||
|
export default function UserLoading() {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="min-h-screen flex flex-col items-center justify-center"
|
||||||
|
style={{
|
||||||
|
background: 'linear-gradient(to bottom, #c4d9d4, #f0f5fc)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
src="/assets/images/splash-house.png"
|
||||||
|
alt="House illustration"
|
||||||
|
width={150}
|
||||||
|
height={108}
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
<div className="mt-[35px]">
|
||||||
|
<Image
|
||||||
|
src="/assets/images/splash-logo.png"
|
||||||
|
alt="RE-Quest logo"
|
||||||
|
width={264}
|
||||||
|
height={55}
|
||||||
|
priority
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mt-8">
|
||||||
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user