'use client' import type { FC } from 'react' import type { ConfigItemType } from './config-item' import { RiAddLine } from '@remixicon/react' import * as React from 'react' import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' import { DataSourceProvider } from '@/models/common' import { cn } from '@/utils/classnames' import ConfigItem from './config-item' import s from './style.module.css' import { DataSourceType } from './types' type Props = { type: DataSourceType provider?: DataSourceProvider isConfigured: boolean onConfigure: () => void readOnly: boolean isSupportList?: boolean configuredList: ConfigItemType[] onRemove: () => void notionActions?: { onChangeAuthorizedPage: () => void } } const Panel: FC = ({ type, provider, isConfigured, onConfigure, readOnly, configuredList, isSupportList, onRemove, notionActions, }) => { const { t } = useTranslation() const isNotion = type === DataSourceType.notion const isWebsite = type === DataSourceType.website const getProviderName = (): string => { if (provider === DataSourceProvider.fireCrawl) return '🔥 Firecrawl' if (provider === DataSourceProvider.waterCrawl) return 'WaterCrawl' return 'Jina Reader' } return (
{t(`dataSource.${type}.title`, { ns: 'common' })}
{isWebsite && (
{t('dataSource.website.with', { ns: 'common' })} {' '} {getProviderName()}
)}
{ !isConfigured && (
{t(`dataSource.${type}.description`, { ns: 'common' })}
) }
{isNotion && ( <> { isConfigured ? ( ) : ( <> {isSupportList && (
{t('dataSource.connect', { ns: 'common' })}
)} ) } )} {isWebsite && !isConfigured && (
{t('dataSource.configure', { ns: 'common' })}
)}
{ isConfigured && ( <>
{isNotion ? t('dataSource.notion.connectedWorkspace', { ns: 'common' }) : t('dataSource.website.configuredCrawlers', { ns: 'common' })}
{ configuredList.map(item => ( )) }
) }
) } export default React.memo(Panel)