Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

750 B
Raw Blame
import { useCallback, useState } from 'react';

interface UseCloseSetupConfirmProps {
	/** True once closing would lose a pending setup, i.e. a setup command exists. */
	shouldConfirm: boolean;
	onClose: () => void;
}

interface UseCloseSetupConfirm {
	isConfirmOpen: boolean;
	setIsConfirmOpen: (open: boolean) => void;
	requestClose: () => void;
}

export function useCloseSetupConfirm({
	shouldConfirm,
	onClose,
}: UseCloseSetupConfirmProps): UseCloseSetupConfirm {
	const [isConfirmOpen, setIsConfirmOpen] = useState(false);

	const requestClose = useCallback((): void => {
		if (shouldConfirm) {
			setIsConfirmOpen(true);
			return;
		}
		onClose();
	}, [shouldConfirm, onClose]);

	return { isConfirmOpen, setIsConfirmOpen, requestClose };
}