'use client' import type { FC } from 'react' import React, { useState } from 'react' import { DataType, type MetadataItemWithValue } from '../types' import InfoGroup from './info-group' import NoData from './no-data' import Button from '@/app/components/base/button' import { RiEditLine } from '@remixicon/react' import { useTranslation } from 'react-i18next' import Divider from '@/app/components/base/divider' import cn from '@/utils/classnames' const i18nPrefix = 'dataset.metadata.documentMetadata' type Props = { className?: string } const MetadataDocument: FC = ({ className, }) => { const { t } = useTranslation() const [isEdit, setIsEdit] = useState(false) const [list, setList] = useState([ { id: '1', name: 'Doc type', value: 'PDF', type: DataType.string, }, { id: '2', name: 'Title', value: 'PDF', type: DataType.string, }, ]) const [tempList, setTempList] = useState(list) const builtInEnabled = true const builtList = [ { id: '1', name: 'OriginalfileNmae', value: 'Steve Jobs The Man Who Thought Different.pdf', type: DataType.string, }, { id: '2', name: 'Title', value: 'PDF', type: DataType.string, }, ] const hasData = list.length > 0 const documentInfoList = builtList const technicalParams = builtList return (
{(hasData || isEdit) ? (
) : ( )} isEdit={isEdit} contentClassName='mt-5' onChange={(item) => { const newList = tempList.map(i => (i.name === item.name ? item : i)) setTempList(newList) }} onDelete={(item) => { const newList = tempList.filter(i => i.name !== item.name) setTempList(newList) }} onAdd={(payload) => { const newList = [...tempList, payload] setTempList(newList) }} /> {builtInEnabled && ( <> )}
) : ( setIsEdit(true)} /> )} ) } export default React.memo(MetadataDocument)