'use client' import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import { RiErrorWarningFill, RiLoader2Line, } from '@remixicon/react' import cn from '@/utils/classnames' import { FilePlus02 } from '@/app/components/base/icons/src/vender/line/files' import { CheckCircle } from '@/app/components/base/icons/src/vender/solid/general' import Popover from '@/app/components/base/popover' export type ISegmentAddProps = { importStatus: ProcessStatus | string | undefined clearProcessStatus: () => void showNewSegmentModal: () => void showBatchModal: () => void } export enum ProcessStatus { WAITING = 'waiting', PROCESSING = 'processing', COMPLETED = 'completed', ERROR = 'error', } const SegmentAdd: FC = ({ importStatus, clearProcessStatus, showNewSegmentModal, showBatchModal, }) => { const { t } = useTranslation() if (importStatus) { return ( <> {(importStatus === ProcessStatus.WAITING || importStatus === ProcessStatus.PROCESSING) && (
{importStatus === ProcessStatus.WAITING &&
} {importStatus === ProcessStatus.PROCESSING &&
} {t('datasetDocuments.list.batchModal.processing')}
)} {importStatus === ProcessStatus.COMPLETED && (
{t('datasetDocuments.list.batchModal.completed')} {t('datasetDocuments.list.batchModal.ok')}
)} {importStatus === ProcessStatus.ERROR && (
{t('datasetDocuments.list.batchModal.error')} {t('datasetDocuments.list.batchModal.ok')}
)} ) } return (
{t('datasetDocuments.list.action.add')}
{t('datasetDocuments.list.action.batchAdd')}
} btnElement={
{t('datasetDocuments.list.action.addButton')}
} btnClassName={open => cn('mr-2 !py-[6px] !text-[13px] !leading-[18px] hover:bg-gray-50 border border-gray-200 hover:border-gray-300 hover:shadow-[0_1px_2px_rgba(16,24,40,0.05)]', open ? '!bg-gray-100 !shadow-none' : '!bg-transparent')} className='!w-[132px] h-fit !z-20 !translate-x-0 !left-0' /> ) } export default React.memo(SegmentAdd)