2025-09-12 08:21:52 +01:00
|
|
|
import { useState, type ReactNode } from "react";
|
2025-08-29 10:07:59 +01:00
|
|
|
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,
|
2025-09-12 08:21:52 +01:00
|
|
|
// effectiveSelected,
|
|
|
|
|
setSelectedSighting,
|
|
|
|
|
selectedSighting,
|
2025-08-29 10:07:59 +01:00
|
|
|
mostRecent,
|
|
|
|
|
} = useSightingFeed(url);
|
2025-09-12 08:21:52 +01:00
|
|
|
const [isSightingModalOpen, setSightingModalOpen] = useState(false);
|
2025-09-12 13:28:14 +01:00
|
|
|
|
2025-08-29 10:07:59 +01:00
|
|
|
return (
|
|
|
|
|
<SightingFeedContext.Provider
|
|
|
|
|
value={{
|
|
|
|
|
sightings,
|
|
|
|
|
selectedRef,
|
|
|
|
|
setSelectedRef,
|
2025-09-12 08:21:52 +01:00
|
|
|
setSelectedSighting,
|
|
|
|
|
selectedSighting,
|
|
|
|
|
setSightingModalOpen,
|
|
|
|
|
isSightingModalOpen,
|
|
|
|
|
// effectiveSelected,
|
2025-08-29 10:07:59 +01:00
|
|
|
mostRecent,
|
|
|
|
|
side,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</SightingFeedContext.Provider>
|
|
|
|
|
);
|
|
|
|
|
};
|