fixed type errors
This commit is contained in:
@@ -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<
|
||||
|
||||
@@ -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>>;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user