balibabu
commited on
Commit
·
f0b5f2b
1
Parent(s):
436c3b5
fix: Bulk disable the chunk, the UI still shows they are enabled #1236 (#1534)
Browse files### What problem does this PR solve?
fix: Bulk disable the chunk, the UI still shows they are enabled #1236
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx
CHANGED
@@ -3,7 +3,7 @@ import { IChunk } from '@/interfaces/database/knowledge';
|
|
3 |
import { Card, Checkbox, CheckboxProps, Flex, Popover, Switch } from 'antd';
|
4 |
import classNames from 'classnames';
|
5 |
import DOMPurify from 'dompurify';
|
6 |
-
import { useState } from 'react';
|
7 |
|
8 |
import { ChunkTextMode } from '../../constant';
|
9 |
import styles from './index.less';
|
@@ -30,7 +30,7 @@ const ChunkCard = ({
|
|
30 |
textMode,
|
31 |
}: IProps) => {
|
32 |
const available = Number(item.available_int);
|
33 |
-
const [enabled, setEnabled] = useState(
|
34 |
|
35 |
const onChange = (checked: boolean) => {
|
36 |
setEnabled(checked);
|
@@ -49,6 +49,10 @@ const ChunkCard = ({
|
|
49 |
clickChunkCard(item.chunk_id);
|
50 |
};
|
51 |
|
|
|
|
|
|
|
|
|
52 |
return (
|
53 |
<Card
|
54 |
className={classNames(styles.chunkCard, {
|
|
|
3 |
import { Card, Checkbox, CheckboxProps, Flex, Popover, Switch } from 'antd';
|
4 |
import classNames from 'classnames';
|
5 |
import DOMPurify from 'dompurify';
|
6 |
+
import { useEffect, useState } from 'react';
|
7 |
|
8 |
import { ChunkTextMode } from '../../constant';
|
9 |
import styles from './index.less';
|
|
|
30 |
textMode,
|
31 |
}: IProps) => {
|
32 |
const available = Number(item.available_int);
|
33 |
+
const [enabled, setEnabled] = useState(false);
|
34 |
|
35 |
const onChange = (checked: boolean) => {
|
36 |
setEnabled(checked);
|
|
|
49 |
clickChunkCard(item.chunk_id);
|
50 |
};
|
51 |
|
52 |
+
useEffect(() => {
|
53 |
+
setEnabled(available === 1);
|
54 |
+
}, [available]);
|
55 |
+
|
56 |
return (
|
57 |
<Card
|
58 |
className={classNames(styles.chunkCard, {
|