index.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use client'
  2. import React from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import EmbeddingProcess from '../embedding-process'
  5. import s from './index.module.css'
  6. import cn from '@/utils/classnames'
  7. import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
  8. import type { FullDocumentDetail, createDocumentResponse } from '@/models/datasets'
  9. type StepThreeProps = {
  10. datasetId?: string
  11. datasetName?: string
  12. indexingType?: string
  13. creationCache?: createDocumentResponse
  14. }
  15. const StepThree = ({ datasetId, datasetName, indexingType, creationCache }: StepThreeProps) => {
  16. const { t } = useTranslation()
  17. const media = useBreakpoints()
  18. const isMobile = media === MediaType.mobile
  19. return (
  20. <div className='flex w-full h-full'>
  21. <div className={'h-full w-full overflow-y-scroll px-6 sm:px-16'}>
  22. <div className='max-w-[636px]'>
  23. {!datasetId && (
  24. <>
  25. <div className={s.creationInfo}>
  26. <div className={s.title}>{t('datasetCreation.stepThree.creationTitle')}</div>
  27. <div className={s.content}>{t('datasetCreation.stepThree.creationContent')}</div>
  28. <div className={s.label}>{t('datasetCreation.stepThree.label')}</div>
  29. <div className={s.datasetName}>{datasetName || creationCache?.dataset?.name}</div>
  30. </div>
  31. <div className={s.dividerLine} />
  32. </>
  33. )}
  34. {datasetId && (
  35. <div className={s.creationInfo}>
  36. <div className={s.title}>{t('datasetCreation.stepThree.additionTitle')}</div>
  37. <div className={s.content}>{`${t('datasetCreation.stepThree.additionP1')} ${datasetName || creationCache?.dataset?.name} ${t('datasetCreation.stepThree.additionP2')}`}</div>
  38. </div>
  39. )}
  40. <EmbeddingProcess
  41. datasetId={datasetId || creationCache?.dataset?.id || ''}
  42. batchId={creationCache?.batch || ''}
  43. documents={creationCache?.documents as FullDocumentDetail[]}
  44. indexingType={indexingType || creationCache?.dataset?.indexing_technique}
  45. />
  46. </div>
  47. </div>
  48. {!isMobile && <div className={cn(s.sideTip)}>
  49. <div className={s.tipCard}>
  50. <span className={s.icon} />
  51. <div className={s.title}>{t('datasetCreation.stepThree.sideTipTitle')}</div>
  52. <div className={s.content}>{t('datasetCreation.stepThree.sideTipContent')}</div>
  53. </div>
  54. </div>}
  55. </div>
  56. )
  57. }
  58. export default StepThree