Fix validation and spacing in new flight form
This commit is contained in:
parent
29c6c49b3e
commit
325730a9da
@ -60,6 +60,11 @@ export default function FlightForm({
|
||||
cancelFunc?: () => void;
|
||||
autofillHobbs?: boolean;
|
||||
}) {
|
||||
const validate_time = (value) => {
|
||||
if (value > 2359) return "Time must be between 0000 and 2359";
|
||||
if (value % 100 > 59) return "Minutes must not exceed 59";
|
||||
};
|
||||
|
||||
const form = useForm<FlightFormSchema>({
|
||||
initialValues: initialValues ?? {
|
||||
date: dayjs(),
|
||||
@ -106,6 +111,14 @@ export default function FlightForm({
|
||||
|
||||
images: [],
|
||||
},
|
||||
validate: {
|
||||
aircraft: (value) =>
|
||||
value?.length ?? 0 > 0 ? null : "Please select an aircraft",
|
||||
time_start: (value) => validate_time(value),
|
||||
time_off: (value) => validate_time(value),
|
||||
time_down: (value) => validate_time(value),
|
||||
time_stop: (value) => validate_time(value),
|
||||
},
|
||||
});
|
||||
|
||||
const [aircraftOpened, { open: openAircraft, close: closeAircraft }] =
|
||||
@ -498,6 +511,7 @@ export default function FlightForm({
|
||||
/>
|
||||
<ImageUpload
|
||||
form={form}
|
||||
mt="md"
|
||||
field="images"
|
||||
label="Images"
|
||||
placeholder="Upload Images"
|
||||
|
@ -9,6 +9,7 @@ export default function ImageUpload({
|
||||
field,
|
||||
label = "",
|
||||
placeholder = "",
|
||||
mt = "",
|
||||
}: {
|
||||
form: UseFormReturnType<
|
||||
FlightFormSchema,
|
||||
@ -17,6 +18,7 @@ export default function ImageUpload({
|
||||
field: string;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
mt?: string;
|
||||
}) {
|
||||
const ValueComponent: FileInputProps["valueComponent"] = ({ value }) => {
|
||||
if (value === null) {
|
||||
@ -41,6 +43,7 @@ export default function ImageUpload({
|
||||
label={label}
|
||||
placeholder={placeholder}
|
||||
multiple
|
||||
mt={mt}
|
||||
accept="image/*"
|
||||
valueComponent={ValueComponent}
|
||||
rightSectionPointerEvents="none"
|
||||
|
Loading…
x
Reference in New Issue
Block a user