Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 72x | import { useGetItem } from "@/api"; import { useLayoutEffect, useState } from "react"; export type DetailsSidebarLink = { id: string; href: string; displayName: string; }; export const useDetailsSidebarLinks = (dataId: string): DetailsSidebarLink[] => { const { data } = useGetItem(dataId); const [sideBarLinks, setSideBarLinks] = useState<DetailsSidebarLink[]>([]); useLayoutEffect(() => { const ids = [ { id: "package_details", label: "Package Details" }, { id: "package_activity", label: "Package Activity" }, { id: "administrative_package_changes", label: "Administrative Package Changes", }, ]; // Check if dataId is not undefined before proceeding if (data?._id) { const links = ids .filter(({ id }) => document.getElementById(id) !== null) .map((link) => ({ id: link.id, href: `#${link.id}`, displayName: link.label, })); setSideBarLinks(links); } else { setSideBarLinks([]); } }, [dataId, data]); return sideBarLinks; }; |