import React from 'react'; import { Text, Dialog } from '@anthropic/ink'; import { saveGlobalConfig } from '../utils/config.js'; import { Select } from './CustomSelect/index.js'; type Props = { customApiKeyTruncated: string; onDone(approved: boolean): void; }; export function ApproveApiKey({ customApiKeyTruncated, onDone }: Props): React.ReactNode { function onChange(value: 'yes' | 'no') { switch (value) { case 'yes': { saveGlobalConfig(current => ({ ...current, customApiKeyResponses: { ...current.customApiKeyResponses, approved: [...(current.customApiKeyResponses?.approved ?? []), customApiKeyTruncated], }, })); onDone(true); break; } case 'no': { saveGlobalConfig(current => ({ ...current, customApiKeyResponses: { ...current.customApiKeyResponses, rejected: [...(current.customApiKeyResponses?.rejected ?? []), customApiKeyTruncated], }, })); onDone(false); break; } } } return ( onChange('no')}> ANTHROPIC_API_KEY : sk-ant-...{customApiKeyTruncated} Do you want to use this API key?