secret-key-button.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use client'
  2. import { useState } from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import { RiKey2Line } from '@remixicon/react'
  5. import Button from '@/app/components/base/button'
  6. import SecretKeyModal from '@/app/components/develop/secret-key/secret-key-modal'
  7. type ISecretKeyButtonProps = {
  8. className?: string
  9. appId?: string
  10. textCls?: string
  11. }
  12. const SecretKeyButton = ({ className, appId, textCls }: ISecretKeyButtonProps) => {
  13. const [isVisible, setVisible] = useState(false)
  14. const { t } = useTranslation()
  15. return (
  16. <>
  17. <Button
  18. className={`px-3 ${className}`}
  19. onClick={() => setVisible(true)}
  20. size='small'
  21. variant='ghost'
  22. >
  23. <div className={'flex items-center justify-center w-3.5 h-3.5'}>
  24. <RiKey2Line className='w-3.5 h-3.5 text-text-tertiary' />
  25. </div>
  26. <div className={`text-text-tertiary system-xs-medium px-[3px] ${textCls}`}>{t('appApi.apiKey')}</div>
  27. </Button>
  28. <SecretKeyModal isShow={isVisible} onClose={() => setVisible(false)} appId={appId} />
  29. </>
  30. )
  31. }
  32. export default SecretKeyButton