mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import type {Organization, SharedViewOrganization} from 'sentry/types';
|
|
import {defined} from 'sentry/utils';
|
|
import type {ApiQueryKey} from 'sentry/utils/queryClient';
|
|
import {useApiQuery} from 'sentry/utils/queryClient';
|
|
|
|
import type {ActionableItemErrors} from './actionableItemsUtils';
|
|
|
|
const actionableItemsQuery = ({
|
|
orgSlug,
|
|
projectSlug,
|
|
eventId,
|
|
}: UseActionableItemsProps): ApiQueryKey => [
|
|
`/projects/${orgSlug}/${projectSlug}/events/${eventId}/actionable-items/`,
|
|
];
|
|
|
|
export interface ActionableItemsResponse {
|
|
errors: ActionableItemErrors[];
|
|
}
|
|
|
|
interface UseActionableItemsProps {
|
|
eventId: string;
|
|
orgSlug: string;
|
|
projectSlug: string;
|
|
}
|
|
|
|
export function useActionableItems(props?: UseActionableItemsProps) {
|
|
return useApiQuery<ActionableItemsResponse>(
|
|
props ? actionableItemsQuery(props) : [''],
|
|
{
|
|
staleTime: Infinity,
|
|
retry: false,
|
|
refetchOnWindowFocus: false,
|
|
notifyOnChangeProps: ['data'],
|
|
enabled: defined(props),
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Check we have all required props
|
|
*/
|
|
export function actionableItemsEnabled({
|
|
eventId,
|
|
organization,
|
|
projectSlug,
|
|
}: {
|
|
eventId?: string;
|
|
organization?: Organization | SharedViewOrganization | null;
|
|
projectSlug?: string;
|
|
}) {
|
|
if (!organization || !organization.features || !projectSlug || !eventId) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|