import React, { useEffect, useState } from 'react';
import { Button, ConfirmModal } from '@grafana/ui';
type Props = {
isRaw: boolean;
onChange: (newIsRaw: boolean) => void;
};
export const QueryEditorModeSwitcher = ({ isRaw, onChange }: Props): JSX.Element => {
const [isModalOpen, setModalOpen] = useState(false);
useEffect(() => {
// if the isRaw changes, we hide the modal
setModalOpen(false);
}, [isRaw]);
if (isRaw) {
return (
<>
{
onChange(false);
}}
onDismiss={() => {
setModalOpen(false);
}}
/>
>
);
} else {
return (
);
}
};