import React from 'react'; import { useTranslation } from 'react-i18next'; import { useSelector } from 'react-redux'; import userService from '../api/services/userService'; import Input from '../components/Input'; import { ActiveState } from '../models/misc'; import { selectToken } from '../preferences/preferenceSlice'; import { AvailableToolType } from './types'; import WrapperModal from './WrapperModal'; interface ConfigToolModalProps { modalState: ActiveState; setModalState: (state: ActiveState) => void; tool: AvailableToolType | null; getUserTools: () => void; } export default function ConfigToolModal({ modalState, setModalState, tool, getUserTools, }: ConfigToolModalProps) { const { t } = useTranslation(); const token = useSelector(selectToken); const [authKey, setAuthKey] = React.useState(''); const handleAddTool = (tool: AvailableToolType) => { userService .createTool( { name: tool.name, displayName: tool.displayName, description: tool.description, config: { token: authKey }, actions: tool.actions, status: true, }, token, ) .then(() => { setModalState('INACTIVE'); getUserTools(); }); }; // Only render when modal is active if (modalState !== 'ACTIVE') return null; return ( setModalState('INACTIVE')}>

{t('modals.configTool.title')}

{t('modals.configTool.type')}:{' '} {tool?.name}

setAuthKey(e.target.value)} borderVariant="thin" placeholder={t('modals.configTool.apiKeyPlaceholder')} labelBgClassName="bg-white dark:bg-charleston-green-2" />
); }