useAutofixSetup.tsx 867 B

123456789101112131415161718192021222324252627282930313233
  1. import {useApiQuery, type UseApiQueryOptions} from 'sentry/utils/queryClient';
  2. import type RequestError from 'sentry/utils/requestError/requestError';
  3. export type AutofixSetupResponse = {
  4. genAIConsent: {
  5. ok: boolean;
  6. };
  7. integration: {
  8. ok: boolean;
  9. reason: string | null;
  10. };
  11. subprocessorConsent: {
  12. ok: boolean;
  13. };
  14. };
  15. export function useAutofixSetup(
  16. {groupId}: {groupId: string},
  17. options: Omit<UseApiQueryOptions<AutofixSetupResponse, RequestError>, 'staleTime'> = {}
  18. ) {
  19. const queryData = useApiQuery<AutofixSetupResponse>(
  20. [`/issues/${groupId}/autofix/setup/`],
  21. {enabled: Boolean(groupId), staleTime: 0, retry: false, ...options}
  22. );
  23. return {
  24. ...queryData,
  25. hasSuccessfulSetup: Boolean(
  26. // TODO: Add other checks here when we can actually configure them
  27. queryData.data?.integration.ok
  28. ),
  29. };
  30. }