import { useMemo } from 'react'; import { SelectableValue } from '@grafana/data'; import { EditorField } from '@grafana/plugin-ui'; import { Select } from '@grafana/ui'; export interface Props { onChange: (accountId?: string) => void; accountOptions: Array>; accountId?: string; } export const ALL_ACCOUNTS_OPTION = { label: 'All', value: 'all', description: 'Target all linked accounts', }; export function Account({ accountId, onChange, accountOptions }: Props) { const selectedAccountExistsInOptions = useMemo( () => accountOptions.find((a) => { if (a.options) { const matchingTemplateVar = a.options.find((tempVar: SelectableValue) => { return tempVar.value === accountId; }); return matchingTemplateVar; } return a.value === accountId; }), [accountOptions, accountId] ); if (accountOptions.length === 0) { return null; } return (