- 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

@@ -2,15 +2,15 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { CAM_BASE } from "../utils/config";
import type { InitialValuesForm } from "../types/types";
const getSightingAmend = async () => {
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=SightingAmmendA`);
const getSightingAmend = async (cameraId: string) => {
const response = await fetch(`${CAM_BASE}/api/fetch-config?id=SightingAmmend${cameraId}`);
if (!response.ok) throw new Error("Cannot reach sighting amend endpoint");
return response.json();
};
const updateSightingAmend = async (data: InitialValuesForm) => {
const updateSightingAmend = async (data: InitialValuesForm, cameraID: string) => {
const updateSightingAmendPayload = {
id: "SightingAmmendA",
id: `SightingAmmend${cameraID}`,
fields: [
{
property: "propOverviewQuality",
@@ -30,15 +30,15 @@ const updateSightingAmend = async (data: InitialValuesForm) => {
return response.json();
};
export const useSightingAmend = () => {
export const useSightingAmend = (cameraID: string) => {
const sightingAmendQuery = useQuery({
queryKey: ["getSightingAmend"],
queryFn: getSightingAmend,
queryFn: () => getSightingAmend(cameraID),
});
const sightingAmendMutation = useMutation({
mutationKey: ["updateSightingAmend"],
mutationFn: updateSightingAmend,
mutationKey: ["updateSightingAmend", cameraID],
mutationFn: (data: InitialValuesForm) => updateSightingAmend(data, cameraID),
});
return {