Files
edr-platform/apps/edr-freight-web/portal/src/hooks/usePublications.ts
2026-09-04 14:43:17 +03:00

26 lines
880 B
TypeScript

import type { PublicationSummary } from "@edr/types";
import { useQuery } from "@tanstack/react-query";
import { URL_CONSTANTS } from "@/constants/URLS";
import type { ApiResponse } from "@/types/apiResponse";
import { client } from "@/utils/api";
import { unwrap } from "@/utils/endpoint";
/**
* The public /publications library — PDFs, Markdown write-ups and PowerPoint
* decks about the platform. Unauthenticated, same as `usePortalContent`; the
* shared axios client only attaches a token when the cookie exists.
*/
export function usePublications() {
return useQuery({
queryKey: ["publications"],
queryFn: async (): Promise<PublicationSummary[]> => {
const response = await client.get<ApiResponse<PublicationSummary[]>>(
URL_CONSTANTS.PUBLICATIONS.PUBLIC,
);
return unwrap(response.data);
},
staleTime: 5 * 60_000,
});
}