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

@@ -0,0 +1,17 @@
import { useState, type ReactNode } from "react";
import type { NPEDUser } from "../../types/types";
import { NPEDUserContext } from "../NPEDUserContext";
type NPEDUserProviderType = {
children: ReactNode;
};
export const NPEDUserProvider = ({ children }: NPEDUserProviderType) => {
const [user, setUser] = useState<NPEDUser | null>(null);
return (
<NPEDUserContext.Provider value={{ user, setUser }}>
{children}
</NPEDUserContext.Provider>
);
};

View File

@@ -0,0 +1,42 @@
import type { ReactNode } from "react";
import { useSightingFeed } from "../../hooks/useSightingFeed";
import { SightingFeedContext } from "../SightingFeedContext";
type SightingFeedProviderProps = {
url: string;
children: ReactNode;
side: string;
};
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>
);
};