mirror of
https://github.com/langgenius/dify.git
synced 2025-07-21 08:32:17 +00:00
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
![]() |
'use client'
|
||
|
import type { FC } from 'react'
|
||
|
import React, { useCallback, useState } from 'react'
|
||
|
import { useTranslation } from 'react-i18next'
|
||
|
import Input from './input'
|
||
|
import Button from '@/app/components/base/button'
|
||
|
|
||
|
const I18N_PREFIX = 'datasetCreation.stepOne.website'
|
||
|
|
||
|
type Props = {
|
||
|
isRunning: boolean
|
||
|
onRun: (url: string) => void
|
||
|
}
|
||
|
|
||
|
const UrlInput: FC<Props> = ({
|
||
|
isRunning,
|
||
|
onRun,
|
||
|
}) => {
|
||
|
const { t } = useTranslation()
|
||
|
const [url, setUrl] = useState('')
|
||
|
const handleUrlChange = useCallback((url: string | number) => {
|
||
|
setUrl(url as string)
|
||
|
}, [])
|
||
|
const handleOnRun = useCallback(() => {
|
||
|
if (isRunning)
|
||
|
return
|
||
|
onRun(url)
|
||
|
}, [isRunning, onRun, url])
|
||
|
|
||
|
return (
|
||
|
<div className='flex items-center justify-between'>
|
||
|
<Input
|
||
|
value={url}
|
||
|
onChange={handleUrlChange}
|
||
|
placeholder='https://docs.dify.ai'
|
||
|
/>
|
||
|
<Button
|
||
|
type='primary'
|
||
|
onClick={handleOnRun}
|
||
|
className='ml-2 !h-8 text-[13px] font-medium'
|
||
|
loading={isRunning}
|
||
|
>
|
||
|
{!isRunning ? t(`${I18N_PREFIX}.run`) : ''}
|
||
|
</Button>
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
export default React.memo(UrlInput)
|