import { Dispatch, SetStateAction } from 'react';
import { UseQueryResult } from 'react-query';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
import { SuccessResponse, Warning } from 'types/api';
import { Dashboard, Widgets } from 'types/api/dashboard/getAll';
import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';

import { timePreferance } from './RightContainer/timeItems';

export interface NewWidgetProps {
	dashboardId: string;
	dashboardData: Dashboard | undefined;
	selectedGraph: PANEL_TYPES;
	enableDrillDown?: boolean;
}

export interface WidgetGraphProps {
	selectedLogFields: Widgets['selectedLogFields'];
	setSelectedLogFields?: Dispatch<SetStateAction<Widgets['selectedLogFields']>>;
	selectedTracesFields: Widgets['selectedTracesFields'];
	setSelectedTracesFields?: Dispatch<
		SetStateAction<Widgets['selectedTracesFields']>
	>;
	selectedWidget: Widgets;
	selectedGraph: PANEL_TYPES;
	selectedTime: timePreferance;
	requestData: GetQueryResultsProps;
	setRequestData: Dispatch<SetStateAction<GetQueryResultsProps>>;
	isLoadingPanelData: boolean;
	setQueryResponse?: Dispatch<
		SetStateAction<
			UseQueryResult<SuccessResponse<MetricRangePayloadProps, unknown>, Error>
		>
	>;
	enableDrillDown?: boolean;
	dashboardData: Dashboard | undefined;
	isNewPanel?: boolean;
}

export type WidgetGraphContainerProps = {
	queryResponse: UseQueryResult<
		SuccessResponse<MetricRangePayloadProps, unknown> & {
			warning?: Warning;
		},
		Error
	>;
	setRequestData: Dispatch<SetStateAction<GetQueryResultsProps>>;
	selectedGraph: PANEL_TYPES;
	selectedWidget: Widgets;
	isLoadingPanelData: boolean;
	enableDrillDown?: boolean;
	isCancelled?: boolean;
};
