Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./globals.scss";

import "react-datepicker/dist/react-datepicker.css";
import { Navigation } from "@/components/Navigation";
import Sidebar from "@/components/Sidebar";
import { Ubuntu } from "next/font/google";
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function Home() {
</div>
<div className="rounded-2xl bg-gray-700 p-3 shadow-md">
{top.length > 0 ? (
<div className="mt-10 flex items-end justify-center gap-8">
<div className="flex items-end justify-center gap-8">
<div className="flex h-24 w-32 flex-col items-center">
<Trophy className="mb-1 size-8 text-gray-400" />
{top[1] ? (
Expand Down
119 changes: 51 additions & 68 deletions app/staffing/page.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
"use client";

import AuthRoute from "@/components/AuthRoute";
import { FormField, FormItem, FormMessage } from "@/components/ui/form";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Response } from "@/models/response";
import { zodResolver } from "@hookform/resolvers/zod";
import { useRouter } from "next/navigation";
import { useContext, useEffect, useState } from "react";
import { Row, Col, FormLabel, FormControl, Button, Spinner } from "react-bootstrap";
import { Form, useForm } from "react-hook-form";
import { useEffect, useState } from "react";
import { Row, Col, Button, Spinner } from "react-bootstrap";
import DatePicker from "react-datepicker";
import { useForm } from "react-hook-form";
import { toast } from "react-toastify";
import { z } from "zod";

import { AuthContext } from "../Providers";


const formSchema = z.object({
cid: z.number().positive(),
fullName: z.string().nonempty(),
email: z.string().email(),
organization: z.string().nonempty(),
estimatedPilots: z.number().positive(),
start: z.date(),
duration: z.string().nonempty(),
});

const generateDurationOptions = () => {
const options = [];
for (let hours = 1; hours <= 12; hours++) {
for (const minutes of [0, 30]) {
const formattedHours = String(hours).padStart(2, "0");
const formattedMinutes = String(minutes).padStart(2, "0");
options.push(`${formattedHours}:${formattedMinutes}`);
}
}
return options;
};

export default function StaffingRequest() {

const authContext = useContext(AuthContext);
const router = useRouter();

const [loading, setLoading] = useState(true);

const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
cid: authContext?.user?.cid ?? 0,
fullName: authContext?.user?.fullName ?? "",
email: authContext?.user?.email ?? "",
organization: "",
estimatedPilots: 0,
start: new Date(),
Expand All @@ -47,6 +59,7 @@ export default function StaffingRequest() {

useEffect(() => {
document.title = "Staffing Request | Memphis ARTCC";
setLoading(false);
}, []);

async function onSubmit(values: z.infer<typeof formSchema>) {
Expand Down Expand Up @@ -82,59 +95,12 @@ export default function StaffingRequest() {
<div className="w-100 text-center text-white">
<div className="flex flex-row justify-center">
<div className="mb-4 text-center text-3xl">
Staffing Request
Staffing Request
</div>
</div>
<div className="rounded-2xl bg-gray-700 p-3 shadow-md">
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<Row>
<Col lg="8">
<FormField
control={form.control}
name="cid"
render={({ field }) => (
<FormItem>
<FormLabel className="text-lg text-white">CID</FormLabel>
<FormControl>
<Input disabled {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</Col>
<Col>
<FormField
control={form.control}
name="fullName"
render={({ field }) => (
<FormItem>
<FormLabel className="text-lg text-white">Name</FormLabel>
<FormControl>
<Input disabled {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</Col>
<Col>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel className="text-lg text-white">Email</FormLabel>
<FormControl>
<Input disabled {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</Col>
</Row>
<Row>
<Col>
<FormField
Expand All @@ -144,7 +110,7 @@ export default function StaffingRequest() {
<FormItem>
<FormLabel className="text-lg text-white">Organization</FormLabel>
<FormControl>
<Input {...field} />
<Input className="text-black" placeholder="Who are you?" {...field} />
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -157,9 +123,9 @@ export default function StaffingRequest() {
name="estimatedPilots"
render={({ field }) => (
<FormItem>
<FormLabel className="text-lg text-white">Organization</FormLabel>
<FormLabel className="text-lg text-white">Estimated Pilots</FormLabel>
<FormControl>
<Input type="number" {...field} />
<Input className="text-black" type="number" {...field} />
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -172,9 +138,15 @@ export default function StaffingRequest() {
name="start"
render={({ field }) => (
<FormItem>
<FormLabel className="text-lg text-white">Start Date & Time</FormLabel>
<FormLabel className="text-lg text-white">Start</FormLabel>
<FormControl>
<Input type="date" {...field} value={field.value.toISOString().split("T")[0]} />
<DatePicker
selected={field.value}
onChange={(date) => form.setValue("start", date as Date)}
showTimeSelect
dateFormat="Pp"
className="w-full rounded-md border p-2 text-black"
/>
</FormControl>
<FormMessage />
</FormItem>
Expand All @@ -187,9 +159,20 @@ export default function StaffingRequest() {
name="duration"
render={({ field }) => (
<FormItem>
<FormLabel className="text-lg text-white">Duration</FormLabel>
<FormLabel className="text-lg text-white">Duration</FormLabel>
<FormControl>
<Input type="number" {...field} />
<Select onValueChange={field.onChange} defaultValue={field.value}>
<SelectTrigger>
<SelectValue placeholder="Select duration" />
</SelectTrigger>
<SelectContent className="!text-black">
{generateDurationOptions().map((duration) => (
<SelectItem key={duration} value={duration}>
{duration}
</SelectItem>
))}
</SelectContent>
</Select>
</FormControl>
<FormMessage />
</FormItem>
Expand Down
12 changes: 6 additions & 6 deletions app/statistics/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,22 @@ export default function StaffingRequest() {
{getUserStatusString(statsEntry.status)}
</TableCell>
<TableCell className="text-lg">
{statsEntry.deliveryHours}
{statsEntry.deliveryHours.toFixed(2)}
</TableCell>
<TableCell className="text-lg">
{statsEntry.groundHours}
{statsEntry.groundHours.toFixed(2)}
</TableCell>
<TableCell className="text-lg">
{statsEntry.towerHours}
{statsEntry.towerHours.toFixed(2)}
</TableCell>
<TableCell className="text-lg">
{statsEntry.traconHours}
{statsEntry.traconHours.toFixed(2)}
</TableCell>
<TableCell className="text-lg">
{statsEntry.centerHours}
{statsEntry.centerHours.toFixed(2)}
</TableCell>
<TableCell className="text-lg">
{statsEntry.totalHours}
{statsEntry.totalHours.toFixed(2)}
</TableCell>
</TableRow>
))}
Expand Down
Loading