- updated to retrieve and set BOF2 data

This commit is contained in:
2025-11-04 11:05:40 +00:00
parent 538b623ac6
commit ca625673e9
4 changed files with 39 additions and 12 deletions

View File

@@ -67,7 +67,7 @@ export const useUpdateBackOfficeConfig = () => {
onError: (error) => toast.error(error.message),
onSuccess: (data) => {
if (data) {
toast.success("Settings successfully updated");
toast.success("Settings successfully updated", { id: "dispatchSettings" });
}
},
});

View File

@@ -33,7 +33,6 @@ const updateDispatcherConfig = async (data: BearerTypeFieldType) => {
};
const updateBackOfficeDispatcher = async (data: OptionalBOF2Constants) => {
console.log(data);
const bof2ContantsPayload = {
id: "Dispatcher-bof2-constants",
fields: [
@@ -63,6 +62,12 @@ const updateBackOfficeDispatcher = async (data: OptionalBOF2Constants) => {
return response.json();
};
const getBof2DispatcherData = async () => {
const response = await fetch(`http://100.118.196.113:8080/api/fetch-config?id=Dispatcher-bof2-constants`);
if (!response.ok) throw new Error("Cannot get BOF2 dispatcher config");
return response.json();
};
export const useCameraOutput = () => {
const dispatcherQuery = useQuery({
queryKey: ["dispatcher"],
@@ -75,7 +80,7 @@ export const useCameraOutput = () => {
onError: (error) => toast.error(error.message),
onSuccess: (data) => {
if (data) {
toast.success("Settings successfully updated");
toast.success("Settings successfully updated", { id: "dispatchSettings" });
}
},
});
@@ -83,6 +88,11 @@ export const useCameraOutput = () => {
const backOfficeDispatcherMutation = useMutation({
mutationKey: ["backofficedDispatcher"],
mutationFn: updateBackOfficeDispatcher,
onSuccess: (data) => {
if (data) {
toast.success("Settings successfully updated", { id: "dispatchSettings" });
}
},
});
useEffect(() => {
@@ -95,3 +105,12 @@ export const useCameraOutput = () => {
backOfficeDispatcherMutation,
};
};
export const useGetDispatcherConfig = () => {
const bof2ConstantsQuery = useQuery({
queryKey: ["getBof2DispatcherData"],
queryFn: getBof2DispatcherData,
});
return { bof2ConstantsQuery };
};