KnowledgeBaseInfo.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import Input from '@/app/components/base/input'
  4. type KnowledgeBaseInfoProps = {
  5. name: string
  6. description?: string
  7. onChange: (data: { name?: string; description?: string }) => void
  8. }
  9. const KnowledgeBaseInfo: React.FC<KnowledgeBaseInfoProps> = ({ name, description, onChange }) => {
  10. const { t } = useTranslation()
  11. const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
  12. onChange({ name: e.target.value })
  13. }
  14. const handleDescriptionChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
  15. onChange({ description: e.target.value })
  16. }
  17. return (
  18. <form className='flex flex-col gap-4 self-stretch'>
  19. <div className='flex flex-col gap-4 self-stretch'>
  20. <div className='flex flex-col gap-1 self-stretch'>
  21. <div className='flex flex-col justify-center self-stretch'>
  22. <label className='text-text-secondary system-sm-semibold'>{t('dataset.externalKnowledgeName')}</label>
  23. </div>
  24. <Input
  25. value={name}
  26. onChange={handleNameChange}
  27. placeholder={t('dataset.externalKnowledgeNamePlaceholder') ?? ''}
  28. />
  29. </div>
  30. <div className='flex flex-col gap-1 self-stretch'>
  31. <div className='flex flex-col justify-center self-stretch'>
  32. <label className='text-text-secondary system-sm-semibold'>{t('dataset.externalKnowledgeDescription')}</label>
  33. </div>
  34. <div className='flex flex-col gap-1 self-stretch'>
  35. <textarea
  36. value={description}
  37. onChange={ e => handleDescriptionChange(e)}
  38. placeholder={t('dataset.externalKnowledgeDescriptionPlaceholder') ?? ''}
  39. className={`flex h-20 py-2 p-3 self-stretch items-start rounded-lg bg-components-input-bg-normal ${description ? 'text-components-input-text-filled' : 'text-components-input-text-placeholder'} system-sm-regular`}
  40. />
  41. </div>
  42. </div>
  43. </div>
  44. </form>
  45. )
  46. }
  47. export default KnowledgeBaseInfo