"use client"; import Link from "next/link"; import { useEffect } from "react"; import { useQueryClient } from "@tanstack/react-query"; import { Clock, MapPin } from "lucide-react"; import { useRecentParcels } from "@/lib/site-finder-api"; const MAX_SHOWN = 5; export function RecentParcels() { const queryClient = useQueryClient(); const { data: parcels, isLoading } = useRecentParcels(); // The visit is written to localStorage in page.handleParcelOpen, but the // QueryClient survives client-side navigation and useRecentParcels has a 60s // staleTime, so returning to /site-finder otherwise shows a stale snapshot // without the just-opened parcel. Invalidate on mount to refetch the latest // localStorage state (the component re-mounts on each return to the page). useEffect(() => { void queryClient.invalidateQueries({ queryKey: ["recent-parcels"] }); }, [queryClient]); if (isLoading) { return (
История просмотров пуста