feat: del dat confirm
This commit is contained in:
parent
3a49efd46d
commit
90f5f84bd8
@ -37,6 +37,9 @@
|
|||||||
"Input": "Input",
|
"Input": "Input",
|
||||||
"Output": "Output"
|
"Output": "Output"
|
||||||
},
|
},
|
||||||
|
"dataset": {
|
||||||
|
"Confirm to delete the data": "Confirm to delete the data?"
|
||||||
|
},
|
||||||
"file": {
|
"file": {
|
||||||
"Click to download CSV template": "Click to download CSV template",
|
"Click to download CSV template": "Click to download CSV template",
|
||||||
"Drag and drop": "Drag and drop files here, or click",
|
"Drag and drop": "Drag and drop files here, or click",
|
||||||
|
|||||||
@ -37,6 +37,9 @@
|
|||||||
"Input": "输入",
|
"Input": "输入",
|
||||||
"Output": "输出"
|
"Output": "输出"
|
||||||
},
|
},
|
||||||
|
"dataset": {
|
||||||
|
"Confirm to delete the data": "确认删除该数据?"
|
||||||
|
},
|
||||||
"file": {
|
"file": {
|
||||||
"Click to download CSV template": "点击下载 CSV 模板",
|
"Click to download CSV template": "点击下载 CSV 模板",
|
||||||
"Drag and drop": "拖拽文件至此,或点击",
|
"Drag and drop": "拖拽文件至此,或点击",
|
||||||
|
|||||||
@ -16,15 +16,21 @@ import Papa from 'papaparse';
|
|||||||
import InputModal, { FormData as InputDataType } from './InputDataModal';
|
import InputModal, { FormData as InputDataType } from './InputDataModal';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { getErrText } from '@/utils/tools';
|
import { getErrText } from '@/utils/tools';
|
||||||
|
import { useConfirm } from '@/hooks/useConfirm';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import MyIcon from '@/components/Icon';
|
import MyIcon from '@/components/Icon';
|
||||||
import MyTooltip from '@/components/MyTooltip';
|
import MyTooltip from '@/components/MyTooltip';
|
||||||
|
|
||||||
const DataCard = ({ kbId }: { kbId: string }) => {
|
const DataCard = ({ kbId }: { kbId: string }) => {
|
||||||
const BoxRef = useRef<HTMLDivElement>(null);
|
const BoxRef = useRef<HTMLDivElement>(null);
|
||||||
const lastSearch = useRef('');
|
const lastSearch = useRef('');
|
||||||
|
const { t } = useTranslation();
|
||||||
const [searchText, setSearchText] = useState('');
|
const [searchText, setSearchText] = useState('');
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [isDeleting, setIsDeleting] = useState(false);
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
|
const { openConfirm, ConfirmModal } = useConfirm({
|
||||||
|
content: t('dataset.Confirm to delete the data')
|
||||||
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: kbDataList,
|
data: kbDataList,
|
||||||
@ -225,19 +231,21 @@ const DataCard = ({ kbId }: { kbId: string }) => {
|
|||||||
borderRadius={'md'}
|
borderRadius={'md'}
|
||||||
_hover={{ color: 'red.600' }}
|
_hover={{ color: 'red.600' }}
|
||||||
isLoading={isDeleting}
|
isLoading={isDeleting}
|
||||||
onClick={async (e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
try {
|
openConfirm(async () => {
|
||||||
setIsDeleting(true);
|
try {
|
||||||
await delOneKbDataByDataId(item.id);
|
setIsDeleting(true);
|
||||||
refetchData(pageNum);
|
await delOneKbDataByDataId(item.id);
|
||||||
} catch (error) {
|
refetchData(pageNum);
|
||||||
toast({
|
} catch (error) {
|
||||||
title: getErrText(error),
|
toast({
|
||||||
status: 'error'
|
title: getErrText(error),
|
||||||
});
|
status: 'error'
|
||||||
}
|
});
|
||||||
setIsDeleting(false);
|
}
|
||||||
|
setIsDeleting(false);
|
||||||
|
})();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
@ -267,6 +275,7 @@ const DataCard = ({ kbId }: { kbId: string }) => {
|
|||||||
onSuccess={() => refetchData()}
|
onSuccess={() => refetchData()}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
<ConfirmModal />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user