fixed type errors

This commit is contained in:
2025-09-16 14:20:38 +01:00
parent c506c395e6
commit b98e3ed85d
21 changed files with 161 additions and 130 deletions

View File

@@ -1,10 +1,10 @@
import { createContext, useContext } from "react";
import type { AlertState, AlertPayload, ActionType } from "../types/types";
import type { AlertState, AlertPayload } from "../types/types";
type AlertHitContextValueType = {
state: AlertState;
action: AlertPayload;
disptach: (action: ActionType) => AlertState;
action?: AlertPayload;
dispatch: React.Dispatch<AlertPayload>;
};
export const AlertHitContext = createContext<

View File

@@ -1,8 +1,8 @@
import { createContext, useContext, type SetStateAction } from "react";
import type { NPEDCameraConfig, NPEDUser } from "../types/types";
import type { NPEDUser } from "../types/types";
type UserContextValue = {
user: NPEDCameraConfig | null;
user: NPEDUser | null;
setUser: React.Dispatch<SetStateAction<NPEDUser | null>>;
};

View File

@@ -1,17 +1,15 @@
import { createContext, useContext } from "react";
import type { SightingType, SightingWidgetType } from "../types/types";
import type { SightingType } from "../types/types";
type SightingFeedContextType = {
sightings: (SightingWidgetType | null | undefined)[];
sightings: (SightingType | null | undefined)[];
selectedRef: number | null;
setSelectedRef: (ref: number | null) => void;
// effectiveSelected: SightingWidgetType | null;
mostRecent: SightingWidgetType | null;
// effectiveSelected: SightingType | null;
mostRecent: SightingType | null;
side: string;
selectedSighting: SightingType | null;
setSelectedSighting: (
sighting: SightingType | SightingWidgetType | null
) => void;
setSelectedSighting: (sighting: SightingType | SightingType | null) => void;
setSightingModalOpen: (isSightingModalOpen: boolean) => void;
isSightingModalOpen: boolean;
};

View File

@@ -7,10 +7,10 @@ type AlertHitProviderTypeProps = {
};
export const AlertHitProvider = ({ children }: AlertHitProviderTypeProps) => {
const [state, disptach] = useReducer(reducer, initalState);
const [state, dispatch] = useReducer(reducer, initalState);
return (
<AlertHitContext.Provider value={{ state, disptach }}>
<AlertHitContext.Provider value={{ state, dispatch }}>
{children}
</AlertHitContext.Provider>
);

View File

@@ -8,18 +8,20 @@ export const initalState = {
export function reducer(state: AlertState, action: AlertPayload) {
switch (action.type) {
case "ADD": {
const alreadyExists = state.allAlerts.some(
(alertItem) => alertItem.vrm === action.payload.vrm
);
if (alreadyExists) {
return { ...state };
} else {
if (action.payload && "vrm" in action.payload) {
const alreadyExists = state.allAlerts.some(
(alertItem) => alertItem.vrm === action.payload.vrm
);
if (alreadyExists) {
return state;
}
return {
...state,
alertList: [...state.allAlerts, action.payload],
allAlerts: [...state.allAlerts, action.payload],
alertList: [...state.allAlerts, action.payload],
};
}
return state;
}
case "SEARCH": {