updated NPED code

This commit is contained in:
2025-08-29 10:07:59 +01:00
parent 5ededd8e05
commit d2b8827987
16 changed files with 285 additions and 150 deletions

View File

@@ -1,6 +1,5 @@
import { createContext, useContext, type ReactNode } from "react";
import { createContext, useContext } from "react";
import type { SightingWidgetType } from "../types/types";
import { useSightingFeed } from "../hooks/useSightingFeed";
type SightingFeedContextType = {
sightings: (SightingWidgetType | null | undefined)[];
@@ -13,50 +12,10 @@ type SightingFeedContextType = {
noSighting: boolean;
};
type SightingFeedProviderProps = {
url: string;
children: ReactNode;
side: string;
};
export const SightingFeedContext = createContext<
SightingFeedContextType | undefined
>(undefined);
const SightingFeedContext = createContext<SightingFeedContextType | undefined>(
undefined
);
export const SightingFeedProvider = ({
children,
url,
side,
}: SightingFeedProviderProps) => {
const {
sightings,
selectedRef,
setSelectedRef,
effectiveSelected,
mostRecent,
isPending,
noSighting,
} = useSightingFeed(url);
return (
<SightingFeedContext.Provider
value={{
sightings,
selectedRef,
setSelectedRef,
effectiveSelected,
mostRecent,
side,
isPending,
noSighting,
}}
>
{children}
</SightingFeedContext.Provider>
);
};
// eslint-disable-next-line react-refresh/only-export-components
export const useSightingFeedContext = () => {
const ctx = useContext(SightingFeedContext);
if (!ctx)