From dcb6ce3c2abed4fd6fbff82a0646d5b7b93d127e Mon Sep 17 00:00:00 2001 From: april Date: Fri, 5 Jan 2024 15:05:01 -0600 Subject: [PATCH] Move flight creation form to separate file --- web/app/routes/logbook.flights.$id/route.tsx | 1 - web/app/routes/logbook.flights.new/route.tsx | 328 +------------------ web/app/ui/form/flight-form.tsx | 298 +++++++++++++++++ 3 files changed, 305 insertions(+), 322 deletions(-) create mode 100644 web/app/ui/form/flight-form.tsx diff --git a/web/app/routes/logbook.flights.$id/route.tsx b/web/app/routes/logbook.flights.$id/route.tsx index 539fe76..d6961e9 100644 --- a/web/app/routes/logbook.flights.$id/route.tsx +++ b/web/app/routes/logbook.flights.$id/route.tsx @@ -17,7 +17,6 @@ import { Button, } from "@mantine/core"; import { useDisclosure } from "@mantine/hooks"; -import { modals } from "@mantine/modals"; import { useNavigate, useParams } from "@remix-run/react"; import { IconPencil, IconTrash } from "@tabler/icons-react"; import { useMutation, useQuery } from "@tanstack/react-query"; diff --git a/web/app/routes/logbook.flights.new/route.tsx b/web/app/routes/logbook.flights.new/route.tsx index 452c829..18531f0 100644 --- a/web/app/routes/logbook.flights.new/route.tsx +++ b/web/app/routes/logbook.flights.new/route.tsx @@ -1,82 +1,12 @@ -import { - Button, - CloseButton, - Container, - Fieldset, - Group, - NumberInput, - ScrollArea, - Stack, - Text, - TextInput, - Textarea, - Title, -} from "@mantine/core"; -import { useForm } from "@mantine/form"; -import { DatePickerInput } from "@mantine/dates"; -import dayjs from "dayjs"; -import { IconPencil } from "@tabler/icons-react"; -import TimeInput from "@/ui/form/time-input"; +import { Container, Stack, Title } from "@mantine/core"; import { FlightFormSchema, flightCreateHelper } from "@/util/types"; -import { HourInput, ZeroHourInput } from "@/ui/form/hour-input"; -import { ZeroIntInput } from "@/ui/form/int-input"; -import ListInput from "@/ui/form/list-input"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useApi } from "@/util/api"; import { useNavigate } from "@remix-run/react"; import { AxiosError } from "axios"; +import FlightForm from "@/ui/form/flight-form"; export default function NewFlight() { - const form = useForm({ - initialValues: { - date: dayjs(), - aircraft: "", - waypoint_from: "", - waypoint_to: "", - route: "", - - hobbs_start: null, - hobbs_end: null, - tach_start: null, - tach_end: null, - - time_start: null, - time_off: null, - time_down: null, - time_stop: null, - - time_total: 0.0, - time_pic: 0.0, - time_sic: 0.0, - time_night: 0.0, - time_solo: 0.0, - - time_xc: 0.0, - dist_xc: 0.0, - - takeoffs_day: 0, - landings_day: 0, - takeoffs_night: 0, - landings_night: 0, - - time_instrument: 0.0, - time_sim_instrument: 0.0, - holds_instrument: 0, - - dual_given: 0.0, - dual_recvd: 0.0, - time_sim: 0.0, - time_ground: 0.0, - - tags: [], - - pax: [], - crew: [], - - comments: "", - }, - }); - const navigate = useNavigate(); const queryClient = useQueryClient(); @@ -105,255 +35,11 @@ export default function NewFlight() { New Flight -
createFlight.mutate(values))}> - - - {/* Date and Aircraft */} - -
- - - - -
- - {/* Route */} - -
- - - - - -
- - {/* Times */} - -
- - - - - - - - -
- - {/* Start/Stop */} - -
- - - - - - - - -
- - {/* Hours */} - -
- - - - - - - - - -
- - {/* Cross-Country */} - -
- - - form.setFieldValue("dist_xc", 0)} - style={{ - display: - form.getTransformedValues().dist_xc == 0 - ? "none" - : undefined, - }} - /> - } - {...form.getInputProps("dist_xc")} - /> - -
- - {/* Takeoffs and Landings */} - -
- - - - - - - - -
- - {/* Instrument */} - -
- - - - - -
- - {/* Instruction */} - -
- - - - - - -
- - {/* About the Flight */} - -
- - - - - -