'use client' import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import cn from 'classnames' import type { Credential } from '@/app/components/tools/types' import Drawer from '@/app/components/base/drawer-plus' import Button from '@/app/components/base/button' import Radio from '@/app/components/base/radio/ui' import { AuthType } from '@/app/components/tools/types' type Props = { credential: Credential onChange: (credential: Credential) => void onHide: () => void } const keyClassNames = 'py-2 leading-5 text-sm font-medium text-gray-900' type ItemProps = { text: string value: AuthType isChecked: boolean onClick: (value: AuthType) => void } const SelectItem: FC = ({ text, value, isChecked, onClick }) => { return (
onClick(value)} >
{text}
) } const ConfigCredential: FC = ({ credential, onChange, onHide, }) => { const { t } = useTranslation() const [tempCredential, setTempCredential] = React.useState(credential) return (
{t('tools.createTool.authMethod.type')}
setTempCredential({ ...tempCredential, auth_type: value })} /> setTempCredential({ ...tempCredential, auth_type: value })} />
{tempCredential.auth_type === AuthType.apiKey && ( <>
{t('tools.createTool.authMethod.key')}
setTempCredential({ ...tempCredential, api_key_header: e.target.value })} className='w-full h-10 px-3 text-sm font-normal bg-gray-100 rounded-lg grow' placeholder={t('tools.createTool.authMethod.types.apiKeyPlaceholder')!} />
{t('tools.createTool.authMethod.value')}
setTempCredential({ ...tempCredential, api_key_value: e.target.value })} className='w-full h-10 px-3 text-sm font-normal bg-gray-100 rounded-lg grow' placeholder={t('tools.createTool.authMethod.types.apiValuePlaceholder')!} />
)}
} /> ) } export default React.memo(ConfigCredential)