Skip to content

Commit

Permalink
Temporarily updated any page with real names to be behind VATSIM SSO.
Browse files Browse the repository at this point in the history
  • Loading branch information
beabravedude committed Jan 30, 2025
1 parent b0c6346 commit 01cfb61
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 28 deletions.
19 changes: 18 additions & 1 deletion app/controllers/[cid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@ import prisma from "@/lib/db";
import {notFound} from "next/navigation";
import {Card, CardContent, Grid2, Typography} from "@mui/material";
import ProfileCard from "@/components/Profile/ProfileCard";
import {User} from "next-auth";
import {getServerSession, User} from "next-auth";
import StatisticsTable from "@/components/Statistics/StatisticsTable";
import {getMonthLog} from "@/lib/hours";
import ControllingSessionsTable from "@/components/Statistics/ControllingSessionsTable";
import {getMonth} from "@/lib/date";
import LoginButton from "@/components/Navbar/LoginButton";
import {authOptions} from "@/auth/auth";

export default async function Page(props: { params: Promise<{ cid: string }> }) {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

const params = await props.params;

const {cid} = params;
Expand Down
20 changes: 18 additions & 2 deletions app/controllers/roster/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import {Card, CardContent, Container, Stack, Typography} from "@mui/material";
import RosterSearch from "@/components/Roster/RosterSearch";
import RosterTabs from "@/components/Roster/RosterTabs";
import {Metadata} from "next";
import RosterLegend from "@/components/Roster/RosterLegend";
import {getServerSession} from "next-auth";
import {authOptions} from "@/auth/auth";
import LoginButton from "@/components/Navbar/LoginButton";

export const metadata: Metadata = {
title: 'Roster | vZDC',
Expand All @@ -12,7 +14,21 @@ export const metadata: Metadata = {

export const revalidate = 300;

export default function Layout({children}: { children: React.ReactNode }) {
export default async function Layout({children}: { children: React.ReactNode }) {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

return (
<Container maxWidth="lg">
Expand Down
17 changes: 17 additions & 0 deletions app/controllers/staff/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
} from "@mui/material";
import {getRating} from "@/lib/vatsim";
import {Metadata} from "next";
import {getServerSession} from "next-auth";
import {authOptions} from "@/auth/auth";
import LoginButton from "@/components/Navbar/LoginButton";

export const metadata: Metadata = {
title: 'Staff | vZDC',
Expand All @@ -24,6 +27,20 @@ const VATUSA_FACILITY = process.env.VATUSA_FACILITY;

export default async function Page() {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

const atm = await prisma.user.findFirst({
where: {
staffPositions: {
Expand Down
18 changes: 17 additions & 1 deletion app/controllers/statistics/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {getAllTimeHours} from "@/lib/hours";
import StatisticsTimeSelector from "@/components/Statistics/StatisticsTimeSelector";
import {Metadata} from "next";
import prisma from "@/lib/db";
import {User} from "next-auth";
import {getServerSession, User} from "next-auth";
import {authOptions} from "@/auth/auth";
import LoginButton from "@/components/Navbar/LoginButton";

export const metadata: Metadata = {
title: 'Statistics | vZDC',
Expand All @@ -13,6 +15,20 @@ export const metadata: Metadata = {

export default async function Layout({children}: { children: React.ReactNode }) {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

const allTimeHours = await getAllTimeHours();
const controllers = await prisma.user.findMany({
where: {
Expand Down
39 changes: 21 additions & 18 deletions app/events/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import React from 'react';
import prisma from "@/lib/db";
import {notFound} from "next/navigation";
import {
Box,
Card,
CardContent,
Container,
Grid2,
Stack,
Typography
} from "@mui/material";
import {Box, Card, CardContent, Container, Grid2, Stack, Typography} from "@mui/material";
import Image from "next/image";
import {UTApi} from "uploadthing/server";
import Markdown from "react-markdown";
import Placeholder from "@/public/img/logo_large.png";
import { formatZuluDate } from '@/lib/date';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/auth/auth';
import {formatZuluDate} from '@/lib/date';
import {getServerSession} from 'next-auth';
import {authOptions} from '@/auth/auth';
import EventPositionRequestForm from '@/components/EventPosition/EventPositionRequestForm';
import { User } from '@prisma/client';

const ut = new UTApi();
import {User} from '@prisma/client';
import LoginButton from "@/components/Navbar/LoginButton";

export default async function Page(props: { params: Promise<{ id: string }> }) {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

const params = await props.params;

const {id} = params;
Expand All @@ -38,8 +43,6 @@ export default async function Page(props: { params: Promise<{ id: string }> }) {
notFound();
}

const session = await getServerSession(authOptions);

const imageUrl = event.bannerKey && `https://utfs.io/f/${event.bannerKey}`;

const eventPosition = await prisma.eventPosition.findUnique({
Expand Down
32 changes: 26 additions & 6 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import {getTop3Controllers} from "@/lib/hours";
import HeaderText from "@/components/Hero/HeaderText";
import BackgroundImage from "@/components/Hero/BackgroundImage";
import QuickLinksList from "@/components/Hero/QuickLinksList";
import {getServerSession} from "next-auth";
import {authOptions} from "@/auth/auth";
import LoginButton from "@/components/Navbar/LoginButton";

const headingFont = Roboto({subsets: ['latin'], weight: ['400']});

export default async function Home() {

const session = await getServerSession(authOptions);

const upcomingEvents = await prisma.event.findMany({
where: {
start: {
Expand Down Expand Up @@ -115,7 +120,12 @@ export default async function Home() {
<Card sx={{minHeight: 600,}}>
<CardContent>
<Typography {...headingFont.style} variant="h5" sx={{mb: 1,}}>Online ATC</Typography>
<Stack direction="column" spacing={1} sx={{maxHeight: 600,}}>
{!session && <>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be
logged in to see this information.</Typography>
<LoginButton session={session}/>
</>}
{session && <Stack direction="column" spacing={1} sx={{maxHeight: 600,}}>
{onlineAtc.length > 0 ? onlineAtc.map(position => (
<Card elevation={0} key={position.position + position.log.userId}>
<CardContent>
Expand All @@ -131,7 +141,7 @@ export default async function Home() {
</CardContent>
</Card>
)) : <Typography>No controllers online</Typography>}
</Stack>
</Stack>}
</CardContent>
</Card>
</Grid2>
Expand All @@ -143,7 +153,12 @@ export default async function Home() {
<Card sx={{minHeight: 600,}}>
<CardContent>
<Typography {...headingFont.style} variant="h5" sx={{mb: 1,}}>Top 3 Controllers</Typography>
<Stack direction="column" spacing={1}>
{!session && <>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be
logged in to see this information.</Typography>
<LoginButton session={session}/>
</>}
{session && <Stack direction="column" spacing={1}>
{top3Controllers.map((controller, idx) => (
<Card elevation={0} key={controller.user.cid}>
<CardContent>
Expand All @@ -165,7 +180,7 @@ export default async function Home() {
</CardContent>
</Card>
))}
</Stack>
</Stack>}
</CardContent>
</Card>
</Grid2>
Expand All @@ -177,7 +192,12 @@ export default async function Home() {
<Card sx={{minHeight: 600,}}>
<CardContent>
<Typography {...headingFont.style} variant="h5" sx={{mb: 1,}}>Solo Certifications</Typography>
<Stack direction="column" spacing={1}>
{!session && <>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be
logged in to see this information.</Typography>
<LoginButton session={session}/>
</>}
{session && <Stack direction="column" spacing={1}>
{soloCertifications.length > 0 ? soloCertifications.map(solo => (
<Card elevation={0} key={solo.id}>
<CardContent>
Expand All @@ -191,7 +211,7 @@ export default async function Home() {
</CardContent>
</Card>
)) : <Typography>No active solo certifications</Typography>}
</Stack>
</Stack>}
</CardContent>
</Card>
</Grid2>
Expand Down
19 changes: 19 additions & 0 deletions app/publications/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import {Card, CardContent, IconButton, Typography} from "@mui/material";
import {OpenInNew} from "@mui/icons-material";
import Link from "next/link";
import {Metadata} from "next";
import {getServerSession} from "next-auth";
import {authOptions} from "@/auth/auth";
import LoginButton from "@/components/Navbar/LoginButton";

const ut = new UTApi();

export async function generateMetadata(props: { params: Promise<{ id: string, }> }): Promise<Metadata> {

const params = await props.params;

const file = await prisma.file.findUnique({
Expand All @@ -28,6 +32,21 @@ export async function generateMetadata(props: { params: Promise<{ id: string, }>
}

export default async function Page(props: { params: Promise<{ id: string, }>, }) {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

const params = await props.params;

const file = await prisma.file.findUnique({
Expand Down
17 changes: 17 additions & 0 deletions app/publications/downloads/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import prisma from "@/lib/db";
import {Card, CardContent, Container, Stack, Typography} from "@mui/material";
import FileTable from "@/components/Files/FileTable";
import {Metadata} from "next";
import {getServerSession} from "next-auth";
import {authOptions} from "@/auth/auth";
import LoginButton from "@/components/Navbar/LoginButton";

export const metadata: Metadata = {
title: 'Downloads | vZDC',
Expand All @@ -11,6 +14,20 @@ export const metadata: Metadata = {

export default async function Page() {

const session = await getServerSession(authOptions);

if (!session) {
return <Card>
<CardContent>
<Typography variant="h5">Login Required</Typography>
<Typography color="red" fontWeight="bold" gutterBottom>By order of the A.T.M, you must be logged in to
see this information.</Typography>
<LoginButton session={session}/>
</CardContent>
</Card>;

}

const fileCategories = await prisma.fileCategory.findMany({
include: {
files: {
Expand Down

0 comments on commit 01cfb61

Please sign in to comment.