mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-17 18:28:42 +00:00
Co-authored-by: yaoyifan-yyf <yaoyifan.yyf@antgroup.com> Co-authored-by: alan.cl <alan.cl@antgroup.com> Co-authored-by: iterminatorheart <123625928+iterminatorheart@users.noreply.github.com> Co-authored-by: VLADIMIR KOBZEV <vladimir.kobzev@improvado.io> Co-authored-by: Aries-ckt <916701291@qq.com> Co-authored-by: xiandu.wl <xiandu.wl@antgroup.com>
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
import React, { createContext, useContext } from 'react';
|
|
import { useEvaluationList } from '../hooks/useEvaluationList';
|
|
|
|
interface EvaluationContextType {
|
|
refresh: () => void;
|
|
data: any;
|
|
loading: boolean;
|
|
getModelsEvaluation: (page?: number, pageSize?: number) => void;
|
|
}
|
|
|
|
const EvaluationContext = createContext<EvaluationContextType | undefined>(undefined);
|
|
|
|
interface EvaluationProviderProps {
|
|
children: React.ReactNode;
|
|
filterValue?: string;
|
|
type?: string;
|
|
}
|
|
|
|
export const EvaluationProvider: React.FC<EvaluationProviderProps> = ({ children, filterValue = '', type = 'all' }) => {
|
|
const { data, loading, getModelsEvaluation, refresh } = useEvaluationList({
|
|
filterValue,
|
|
type,
|
|
});
|
|
|
|
return (
|
|
<EvaluationContext.Provider
|
|
value={{
|
|
refresh,
|
|
data,
|
|
loading,
|
|
getModelsEvaluation,
|
|
}}
|
|
>
|
|
{children}
|
|
</EvaluationContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useEvaluation = () => {
|
|
const context = useContext(EvaluationContext);
|
|
if (context === undefined) {
|
|
throw new Error('useEvaluation must be used within an EvaluationProvider');
|
|
}
|
|
return context;
|
|
};
|