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 | import { useQuery } from "react-query";
import { customInstance } from "@services/api";
import { LEGAL_DOC_KEYS } from "./keys";
import type { DocumentVersion } from "../types";
/**
* Reads an acquirer's published Terms-of-Service / Privacy-Policy content from
* the public (unauthenticated) endpoint.
*
* Contract (givesync-api): `GET /legal-documents/public/{merchantID}/{type}`,
* where `merchantID` is the acquirer account id. The backend decides nothing
* about which acquirer to serve — the caller chooses it. Only `privacy_policy`
* and `terms_of_service` are public; agreement types return 404. There is no
* `variant` concept on this endpoint.
*/
export const usePublicLegalDocument = (
merchantID?: number | string,
type?: string,
options?: { enabled?: boolean },
) =>
useQuery<DocumentVersion>(
[LEGAL_DOC_KEYS.public, merchantID, type],
() =>
customInstance({
url: `/legal-documents/public/${merchantID}/${type}`,
method: "GET",
}),
{
enabled: (options?.enabled ?? true) && !!merchantID && !!type,
retry: false,
refetchOnWindowFocus: false,
},
);
|