- implement user settings reset functionality with modal confirmation

and bug fixes regarding lane IDs to sighting endpoints
This commit is contained in:
2026-01-07 09:39:46 +00:00
parent f046ae6dfc
commit f9188bb46f
13 changed files with 186 additions and 140 deletions

View File

@@ -78,7 +78,11 @@ const updateBOF2LaneId = async (data: OptionalBOF2LaneIDs) => {
},
{
property: "propLaneID2",
value: data?.LID2,
value: data?.LID1,
},
{
property: "propLaneID3",
value: data?.LID1,
},
],
};
@@ -91,8 +95,8 @@ const updateBOF2LaneId = async (data: OptionalBOF2LaneIDs) => {
return response.json();
};
const getBOF2LaneId = async () => {
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=SightingAmmendA-lane-ids`);
const getBOF2LaneId = async (cameraID: string) => {
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=SightingAmmend${cameraID}-lane-ids`);
if (!response.ok) throw new Error("Canot get Lane Ids");
return response.json();
};
@@ -124,16 +128,6 @@ export const useCameraOutput = () => {
},
});
const bof2LandMutation = useMutation({
mutationKey: ["updateBOF2LaneId"],
mutationFn: updateBOF2LaneId,
});
const laneIdQuery = useQuery({
queryKey: ["getBOF2LaneId"],
queryFn: getBOF2LaneId,
});
useEffect(() => {
if (dispatcherQuery.isError) toast.error(dispatcherQuery.error.message);
}, [dispatcherQuery?.error?.message, dispatcherQuery.isError]);
@@ -142,8 +136,6 @@ export const useCameraOutput = () => {
dispatcherQuery,
dispatcherMutation,
backOfficeDispatcherMutation,
bof2LandMutation,
laneIdQuery,
};
};
@@ -155,3 +147,17 @@ export const useGetDispatcherConfig = () => {
return { bof2ConstantsQuery };
};
export const useLaneIds = (cameraID: string) => {
const laneIdQuery = useQuery({
queryKey: ["getBOF2LaneId", cameraID],
queryFn: () => getBOF2LaneId(cameraID),
});
const laneIdMutation = useMutation({
mutationKey: ["updateBOF2LaneId", cameraID],
mutationFn: (data: OptionalBOF2LaneIDs) => updateBOF2LaneId(data),
});
return { laneIdQuery, laneIdMutation };
};