doc-type-form.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { StepChangeParams } from '@/types/knowledge';
  2. import { Card } from 'antd';
  3. import { useTranslation } from 'react-i18next';
  4. import DocIcon from './doc-icon';
  5. type IProps = {
  6. handleStepChange: (params: StepChangeParams) => void;
  7. };
  8. export default function DocTypeForm(props: IProps) {
  9. const { t } = useTranslation();
  10. const { handleStepChange } = props;
  11. const docTypeList = [
  12. {
  13. type: 'TEXT',
  14. title: t('Text'),
  15. subTitle: t('Fill your raw text'),
  16. iconType: 'TEXT',
  17. },
  18. {
  19. type: 'URL',
  20. title: t('URL'),
  21. subTitle: t('Fetch_the_content_of_a_URL'),
  22. iconType: 'WEBPAGE',
  23. },
  24. {
  25. type: 'DOCUMENT',
  26. title: t('Document'),
  27. subTitle: t('Upload_a_document'),
  28. iconType: 'DOCUMENT',
  29. },
  30. {
  31. type: 'YUQUEURL',
  32. title: t('yuque'),
  33. subTitle: t('Get_yuque_document'),
  34. iconType: 'YUQUEURL',
  35. },
  36. ];
  37. return (
  38. <>
  39. {docTypeList.map((type, index) => (
  40. <Card
  41. key={index}
  42. className='mt-4 mb-4 cursor-pointer'
  43. onClick={() => {
  44. handleStepChange({ label: 'forward', docType: type.type });
  45. }}
  46. >
  47. <div className='font-semibold'>
  48. <DocIcon type={type.iconType} />
  49. {type.title}
  50. </div>
  51. <div>{type.subTitle}</div>
  52. </Card>
  53. ))}
  54. </>
  55. );
  56. }