You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-data.tsx 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use client'
  2. import type { FC } from 'react'
  3. import React from 'react'
  4. import { useTranslation } from 'react-i18next'
  5. import s from './index.module.css'
  6. import { Icon3Dots } from '@/app/components/base/icons/src/vender/line/others'
  7. import Button from '@/app/components/base/button'
  8. import { DataSourceProvider } from '@/models/common'
  9. import { ENABLE_WEBSITE_FIRECRAWL, ENABLE_WEBSITE_JINAREADER, ENABLE_WEBSITE_WATERCRAWL } from '@/config'
  10. const I18N_PREFIX = 'datasetCreation.stepOne.website'
  11. type Props = {
  12. onConfig: () => void
  13. provider: DataSourceProvider
  14. }
  15. const NoData: FC<Props> = ({
  16. onConfig,
  17. }) => {
  18. const { t } = useTranslation()
  19. const providerConfig = {
  20. [DataSourceProvider.jinaReader]: ENABLE_WEBSITE_JINAREADER ? {
  21. emoji: <span className={s.jinaLogo} />,
  22. title: t(`${I18N_PREFIX}.jinaReaderNotConfigured`),
  23. description: t(`${I18N_PREFIX}.jinaReaderNotConfiguredDescription`),
  24. } : null,
  25. [DataSourceProvider.fireCrawl]: ENABLE_WEBSITE_FIRECRAWL ? {
  26. emoji: '🔥',
  27. title: t(`${I18N_PREFIX}.fireCrawlNotConfigured`),
  28. description: t(`${I18N_PREFIX}.fireCrawlNotConfiguredDescription`),
  29. } : null,
  30. [DataSourceProvider.waterCrawl]: ENABLE_WEBSITE_WATERCRAWL ? {
  31. emoji: '💧',
  32. title: t(`${I18N_PREFIX}.waterCrawlNotConfigured`),
  33. description: t(`${I18N_PREFIX}.waterCrawlNotConfiguredDescription`),
  34. } : null,
  35. }
  36. const currentProvider = Object.values(providerConfig).find(provider => provider !== null) || providerConfig[DataSourceProvider.jinaReader]
  37. if (!currentProvider) return null
  38. return (
  39. <>
  40. <div className='mt-4 max-w-[640px] rounded-2xl bg-workflow-process-bg p-6'>
  41. <div className='flex h-12 w-12 items-center justify-center rounded-[10px] border-[0.5px]
  42. border-components-card-border bg-components-card-bg shadow-lg shadow-shadow-shadow-5 backdrop-blur-[5px]'>
  43. {currentProvider.emoji}
  44. </div>
  45. <div className='mb-1 mt-2 flex flex-col gap-y-1 pb-3 pt-1'>
  46. <span className='system-md-semibold text-text-secondary'>
  47. {currentProvider.title}
  48. <Icon3Dots className='relative -left-1.5 -top-2.5 inline' />
  49. </span>
  50. <div className='system-sm-regular text-text-tertiary'>
  51. {currentProvider.description}
  52. </div>
  53. </div>
  54. <Button variant='primary' onClick={onConfig}>
  55. {t(`${I18N_PREFIX}.configure`)}
  56. </Button>
  57. </div>
  58. </>
  59. )
  60. }
  61. export default React.memo(NoData)