mirror of
https://github.com/langgenius/dify.git
synced 2026-04-26 21:55:58 +08:00
41 lines
877 B
TypeScript
41 lines
877 B
TypeScript
import {
|
|
memo,
|
|
useState,
|
|
} from 'react'
|
|
import Button from '@/app/components/base/button'
|
|
import type { ButtonProps } from '@/app/components/base/button'
|
|
import ApiKeyModal from './api-key-modal'
|
|
|
|
type AddApiKeyButtonProps = {
|
|
buttonVariant?: ButtonProps['variant']
|
|
buttonText?: string
|
|
}
|
|
const AddApiKeyButton = ({
|
|
buttonVariant = 'secondary-accent',
|
|
buttonText = 'use api key',
|
|
}: AddApiKeyButtonProps) => {
|
|
const [isApiKeyModalOpen, setIsApiKeyModalOpen] = useState(false)
|
|
|
|
return (
|
|
<>
|
|
<Button
|
|
className='grow'
|
|
variant={buttonVariant}
|
|
onClick={() => setIsApiKeyModalOpen(true)}
|
|
>
|
|
{buttonText}
|
|
</Button>
|
|
{
|
|
isApiKeyModalOpen && (
|
|
<ApiKeyModal
|
|
onClose={() => setIsApiKeyModalOpen(false)}
|
|
/>
|
|
)
|
|
}
|
|
</>
|
|
|
|
)
|
|
}
|
|
|
|
export default memo(AddApiKeyButton)
|