- added form fetch and post for optional constants for UTMC
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
import { Formik, Form } from "formik";
|
||||
import BearerTypeCard from "./BearerTypeCard";
|
||||
import ChannelCard from "./ChannelCard";
|
||||
import type { BearerTypeFields, FormTypes, OptionalBOF2Constants } from "../../../types/types";
|
||||
import type { BearerTypeFields, FormTypes, OptionalBOF2Constants, OptionalUTMCConstants } from "../../../types/types";
|
||||
import { usePostBearerConfig } from "../hooks/useBearer";
|
||||
import { useDispatcherConfig } from "../hooks/useDispatcherConfig";
|
||||
import { useOptionalConstants } from "../hooks/useOptionalConstants";
|
||||
|
||||
const OutputForms = () => {
|
||||
const { bearerMutation } = usePostBearerConfig();
|
||||
const { dispatcherQuery, dispatcherMutation } = useDispatcherConfig();
|
||||
|
||||
const format = dispatcherQuery?.data?.propFormat?.value;
|
||||
const { optionalConstantsQuery, optionalConstantsMutation } = useOptionalConstants(format?.toLowerCase());
|
||||
const FFID = optionalConstantsQuery?.data?.propFeedIdentifier?.value;
|
||||
const SCID = optionalConstantsQuery?.data?.propSourceIdentifier?.value;
|
||||
const timestampSource = optionalConstantsQuery?.data?.propTimeZoneType?.value;
|
||||
const gpsFormat = optionalConstantsQuery?.data?.propGpsFormat?.value;
|
||||
|
||||
const inititalValues: FormTypes = {
|
||||
format: format ?? "JSON",
|
||||
@@ -22,11 +28,11 @@ const OutputForms = () => {
|
||||
overviewQuality: "HIGH",
|
||||
cropSizeFactor: "3/4",
|
||||
|
||||
// Bof2 -optional constants
|
||||
FFID: "",
|
||||
SCID: "",
|
||||
timestampSource: "UTC",
|
||||
GPSFormat: "Minutes",
|
||||
// optional constants
|
||||
FFID: FFID ?? "",
|
||||
SCID: SCID ?? "",
|
||||
timestampSource: timestampSource ?? "UTC",
|
||||
GPSFormat: gpsFormat ?? "Minutes",
|
||||
|
||||
//BOF2 - optional Lane IDs
|
||||
laneId: "",
|
||||
@@ -56,14 +62,25 @@ const OutputForms = () => {
|
||||
|
||||
if (result?.id) {
|
||||
await bearerMutation.mutateAsync(bearerFields);
|
||||
|
||||
if (values.format === "BOF2") {
|
||||
const optionalBOF2Fields: OptionalBOF2Constants = {
|
||||
format: values.format,
|
||||
FFID: values.FFID,
|
||||
SCID: values.SCID,
|
||||
timestampSource: values.timestampSource,
|
||||
GPSFormat: values.GPSFormat,
|
||||
};
|
||||
console.log("Submit BOF2 optional fields:", optionalBOF2Fields);
|
||||
await optionalConstantsMutation.mutateAsync(optionalBOF2Fields);
|
||||
}
|
||||
if (values.format === "UTMC") {
|
||||
const optionalUTMCFields: OptionalUTMCConstants = {
|
||||
format: values.format,
|
||||
SCID: values.SCID,
|
||||
timestampSource: values.timestampSource,
|
||||
GPSFormat: values.GPSFormat,
|
||||
};
|
||||
await optionalConstantsMutation.mutateAsync(optionalUTMCFields);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user