import { FlightFormSchema } from "@/util/types"; import { Button, CloseButton, Container, Fieldset, Group, NumberInput, ScrollArea, Text, TextInput, Textarea, } from "@mantine/core"; import { DatePickerInput } from "@mantine/dates"; import { useForm } from "@mantine/form"; import dayjs from "dayjs"; import { HourInput, ZeroHourInput } from "./hour-input"; import TimeInput from "./time-input"; import { ZeroIntInput } from "./int-input"; import ListInput from "./list-input"; import { IconPencil } from "@tabler/icons-react"; import { AxiosError } from "axios"; export default function FlightForm({ onSubmit, isError, error, initialValues, mah, submitButtonLabel, withCancelButton, cancelFunc, }: { onSubmit: (values: FlightFormSchema) => void; isError: boolean; error: AxiosError | null; initialValues?: FlightFormSchema | null; mah?: string; submitButtonLabel?: string; withCancelButton?: boolean; cancelFunc?: () => void; }) { const form = useForm({ initialValues: 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, landings_day: 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: "", }, }); return (
onSubmit(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")} />
{/* Landings */}
{/* Instrument */}
{/* Instruction */}
{/* About the Flight */}