- updated to retrieve and set BOF2 data
This commit is contained in:
@@ -30,7 +30,6 @@ const BearerTypeFields = ({ options }: BearerTypeFieldsProps) => {
|
||||
<FormGroup>
|
||||
<div className="flex flex-col space-y-4">
|
||||
<FormToggle name="enabled" label="Enabled" />
|
||||
<FormToggle name="verbose" label="Verbose" />
|
||||
</div>
|
||||
</FormGroup>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Form, Formik } from "formik";
|
||||
import BearerTypeCard from "../BearerType/BearerTypeCard";
|
||||
import ChannelCard from "../Channel1-JSON/ChannelCard";
|
||||
import { useCameraOutput } from "../../../hooks/useCameraOutput";
|
||||
import { useCameraOutput, useGetDispatcherConfig } from "../../../hooks/useCameraOutput";
|
||||
import type {
|
||||
BearerTypeFieldType,
|
||||
InitialValuesForm,
|
||||
@@ -11,23 +11,29 @@ import type {
|
||||
import { cleanArray } from "../../../utils/utils";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useUpdateBackOfficeConfig } from "../../../hooks/useBackOfficeConfig";
|
||||
import { useState } from "react";
|
||||
|
||||
const SettingForms = () => {
|
||||
const qc = useQueryClient();
|
||||
const [formErrors, setFormErrors] = useState<InitialValuesFormErrors | null>(null);
|
||||
const { dispatcherQuery, dispatcherMutation, backOfficeDispatcherMutation } = useCameraOutput();
|
||||
const { backOfficeMutation } = useUpdateBackOfficeConfig();
|
||||
const { bof2ConstantsQuery } = useGetDispatcherConfig();
|
||||
|
||||
const format = dispatcherQuery?.data?.propFormat?.value;
|
||||
const rawOptions = dispatcherQuery?.data?.propFormat?.accepted;
|
||||
const enabled = dispatcherQuery?.data?.propEnabled?.value;
|
||||
const verbose = dispatcherQuery?.data?.propVerbose?.value;
|
||||
|
||||
const FFID = bof2ConstantsQuery?.data?.propFeedIdentifier?.value;
|
||||
const SCID = bof2ConstantsQuery?.data?.propSourceIdentifier?.value;
|
||||
const GPSFormat = bof2ConstantsQuery?.data?.propGpsFormat?.value;
|
||||
const timestampSource = bof2ConstantsQuery?.data?.propTimeZoneType?.value;
|
||||
|
||||
const options = cleanArray(rawOptions);
|
||||
|
||||
const initialValues: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants = {
|
||||
format: format ?? "JSON",
|
||||
enabled: enabled === "true",
|
||||
verbose: verbose === "true",
|
||||
backOfficeURL: "",
|
||||
username: "",
|
||||
password: "",
|
||||
@@ -35,10 +41,10 @@ const SettingForms = () => {
|
||||
readTimeoutSeconds: Number(15),
|
||||
|
||||
// Bof2 - optional constants
|
||||
FFID: "",
|
||||
SCID: "",
|
||||
timestampSource: "",
|
||||
GPSFormat: "",
|
||||
FFID: FFID ?? "",
|
||||
SCID: SCID ?? "",
|
||||
timestampSource: timestampSource ?? "",
|
||||
GPSFormat: GPSFormat ?? "",
|
||||
};
|
||||
|
||||
const validateValues = (values: InitialValuesForm): InitialValuesFormErrors => {
|
||||
@@ -47,7 +53,6 @@ const SettingForms = () => {
|
||||
const url = values.backOfficeURL?.trim();
|
||||
const username = values.username?.trim();
|
||||
const password = values.password?.trim();
|
||||
|
||||
if (!url) {
|
||||
errors.backOfficeURL = "Required";
|
||||
}
|
||||
@@ -68,10 +73,14 @@ const SettingForms = () => {
|
||||
} else if (connect < 0) {
|
||||
errors.connectTimeoutSeconds = "Must be ≥ 0";
|
||||
}
|
||||
setFormErrors(errors);
|
||||
return errors;
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: BearerTypeFieldType & InitialValuesForm & OptionalBOF2Constants) => {
|
||||
if (formErrors && Object.entries(formErrors).length > 0) {
|
||||
return;
|
||||
}
|
||||
const dispatcherData = {
|
||||
format: values.format,
|
||||
enabled: values.enabled,
|
||||
|
||||
Reference in New Issue
Block a user