mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 04:48:18 +00:00
26 lines
880 B
TypeScript
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,
|
|
});
|
|
}
|