Skip to content

Commit 055f627

Browse files
committed
Add ACARS not logged in message
1 parent 3104ad0 commit 055f627

1 file changed

Lines changed: 43 additions & 8 deletions

File tree

src/pages/ACARS.tsx

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default function ACARS() {
3737
const [messages, setMessages] = useState<AcarsMessage[]>([]);
3838
const [activeSessions, setActiveSessions] = useState<OverviewSession[]>([]);
3939
const [error, setError] = useState<string | null>(null);
40+
const [isAuthError, setIsAuthError] = useState(false);
4041
const [pdcRequested, setPdcRequested] = useState(false);
4142
const [sessionAccessId, setSessionAccessId] = useState<string | null>(null);
4243

@@ -102,6 +103,10 @@ export default function ACARS() {
102103
);
103104

104105
if (!flightResponse.ok) {
106+
if (flightResponse.status === 401) {
107+
setIsAuthError(true);
108+
throw new Error('Authentication required');
109+
}
105110
throw new Error('Failed to load flight data');
106111
}
107112

@@ -419,14 +424,44 @@ export default function ACARS() {
419424
<div className="min-h-screen bg-gray-950 text-white">
420425
<Navbar />
421426
<div className="flex items-center justify-center h-screen">
422-
<div className="text-center">
423-
<h1 className="text-2xl font-bold text-red-500 mb-4">
424-
Access Denied
425-
</h1>
426-
<p className="text-gray-400 mb-6">{error}</p>
427-
<Button onClick={() => navigate('/')}>
428-
Return Home
429-
</Button>
427+
<div className="text-center max-w-md px-4">
428+
{isAuthError ? (
429+
<>
430+
<h1 className="text-3xl font-bold text-blue-500 mb-4">
431+
Sign In Required
432+
</h1>
433+
<p className="text-gray-300 mb-2 text-lg">
434+
To use ACARS you have to sign in!
435+
</p>
436+
<p className="text-green-400 mb-6 text-sm">
437+
Don't worry your flight plan was still submitted, but you will not be able to use ACARS until you sign in.
438+
</p>
439+
<div className="flex gap-3 justify-center">
440+
<Button
441+
onClick={() => window.location.href = `${import.meta.env.VITE_SERVER_URL}/api/auth/discord`}
442+
className="bg-blue-600 hover:bg-blue-700"
443+
>
444+
Sign In with Discord
445+
</Button>
446+
<Button
447+
onClick={() => navigate('/')}
448+
variant="outline"
449+
>
450+
Return Home
451+
</Button>
452+
</div>
453+
</>
454+
) : (
455+
<>
456+
<h1 className="text-2xl font-bold text-red-500 mb-4">
457+
Access Denied
458+
</h1>
459+
<p className="text-gray-400 mb-6">{error}</p>
460+
<Button onClick={() => navigate('/')}>
461+
Return Home
462+
</Button>
463+
</>
464+
)}
430465
</div>
431466
</div>
432467
</div>

0 commit comments

Comments
 (0)