@@ -37,6 +37,8 @@ export type DatasetContextType = {
|
||||
setEditedDataset: (data?: EditResourceInfoFormType) => void;
|
||||
onDelDataset: (id: string) => Promise<void>;
|
||||
onUpdateDataset: (data: DatasetUpdateBody) => Promise<void>;
|
||||
searchKey: string;
|
||||
setSearchKey: React.Dispatch<React.SetStateAction<string>>;
|
||||
};
|
||||
|
||||
export const DatasetsContext = createContext<DatasetContextType>({
|
||||
@@ -57,7 +59,11 @@ export const DatasetsContext = createContext<DatasetContextType>({
|
||||
onUpdateDataset: function (_data: DatasetUpdateBody): Promise<void> {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
myDatasets: []
|
||||
myDatasets: [],
|
||||
searchKey: '',
|
||||
setSearchKey: function (value: React.SetStateAction<string>): void {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
});
|
||||
|
||||
function DatasetContextProvider({ children }: { children: React.ReactNode }) {
|
||||
@@ -65,7 +71,7 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
|
||||
const { commonT } = useI18n();
|
||||
const { t } = useTranslation();
|
||||
const [moveDatasetId, setMoveDatasetId] = useState<string>();
|
||||
|
||||
const [searchKey, setSearchKey] = useState('');
|
||||
const { parentId = null } = router.query as { parentId?: string | null };
|
||||
|
||||
const {
|
||||
@@ -75,11 +81,12 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
|
||||
} = useRequest2(
|
||||
() =>
|
||||
getDatasets({
|
||||
searchKey,
|
||||
parentId
|
||||
}),
|
||||
{
|
||||
manual: false,
|
||||
refreshDeps: [parentId]
|
||||
refreshDeps: [parentId, searchKey]
|
||||
}
|
||||
);
|
||||
|
||||
@@ -145,7 +152,9 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
|
||||
onDelDataset,
|
||||
onUpdateDataset,
|
||||
myDatasets,
|
||||
loadMyDatasets
|
||||
loadMyDatasets,
|
||||
searchKey,
|
||||
setSearchKey
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user