Skip to content

Instantly share code, notes, and snippets.

@jtomchak
Created April 13, 2022 17:28
Show Gist options
  • Save jtomchak/df5ca4098da8dfdb5aeecdbe29287481 to your computer and use it in GitHub Desktop.
Save jtomchak/df5ca4098da8dfdb5aeecdbe29287481 to your computer and use it in GitHub Desktop.
DocuSign Snippet
export const useEnvelopeDetailsQuery = (query?: QueryParams) => {
const fetchEnvelopeWithCredentials =
useFetchWithCredentials<EnvelopeResponse>();
const { queryString } = serializeQueryParams(query);
const { data: envelopeResponse, isLoading } = useQuery<
EnvelopeResponse,
ErrorDetails
>(
['envelopeDetails', queryString],
() =>
fetchEnvelopeWithCredentials(
`${apis.API_URL}/envelopes/details?${queryString}`,
),
{ initialData },
);
const envelope = envelopeResponse?.data!;
const isEnvelopeDetailsLoading = isLoading || envelope === null;
const isEnvelopeEmpty = envelope === undefined;
return {
envelope,
isEnvelopeDetailsLoading,
isEnvelopeEmpty,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment