### What problem does this PR solve? fix: fetch user by @tanstack/react-query #1306 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -8,12 +8,9 @@ import {
|
||||
useSaveTenantInfo,
|
||||
useSelectLlmOptionsByModelType,
|
||||
} from '@/hooks/llm-hooks';
|
||||
import {
|
||||
useFetchTenantInfo,
|
||||
useSelectTenantInfo,
|
||||
} from '@/hooks/user-setting-hooks';
|
||||
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { ApiKeyPostBody } from '../interface';
|
||||
|
||||
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
||||
@@ -63,7 +60,7 @@ export const useSubmitApiKey = () => {
|
||||
};
|
||||
|
||||
export const useSubmitSystemModelSetting = () => {
|
||||
const systemSetting = useSelectTenantInfo();
|
||||
const { data: systemSetting } = useFetchTenantInfo();
|
||||
const { saveTenantInfo: saveSystemModelSetting, loading } =
|
||||
useSaveTenantInfo();
|
||||
const {
|
||||
@@ -98,16 +95,9 @@ export const useSubmitSystemModelSetting = () => {
|
||||
};
|
||||
};
|
||||
|
||||
export const useFetchSystemModelSettingOnMount = (visible: boolean) => {
|
||||
const systemSetting = useSelectTenantInfo();
|
||||
export const useFetchSystemModelSettingOnMount = () => {
|
||||
const { data: systemSetting } = useFetchTenantInfo();
|
||||
const allOptions = useSelectLlmOptionsByModelType();
|
||||
const fetchTenantInfo = useFetchTenantInfo();
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
fetchTenantInfo();
|
||||
}
|
||||
}, [fetchTenantInfo, visible]);
|
||||
|
||||
return { systemSetting, allOptions };
|
||||
};
|
||||
|
||||
@@ -264,12 +264,14 @@ const UserSettingModel = () => {
|
||||
onOk={onApiKeySavingOk}
|
||||
llmFactory={llmFactory}
|
||||
></ApiKeyModal>
|
||||
<SystemModelSettingModal
|
||||
visible={systemSettingVisible}
|
||||
onOk={onSystemSettingSavingOk}
|
||||
hideModal={hideSystemSettingModal}
|
||||
loading={saveSystemModelSettingLoading}
|
||||
></SystemModelSettingModal>
|
||||
{systemSettingVisible && (
|
||||
<SystemModelSettingModal
|
||||
visible={systemSettingVisible}
|
||||
onOk={onSystemSettingSavingOk}
|
||||
hideModal={hideSystemSettingModal}
|
||||
loading={saveSystemModelSettingLoading}
|
||||
></SystemModelSettingModal>
|
||||
)}
|
||||
<OllamaModal
|
||||
visible={llmAddingVisible}
|
||||
hideModal={hideLlmAddingModal}
|
||||
|
||||
@@ -21,7 +21,7 @@ const SystemModelSettingModal = ({
|
||||
}: IProps) => {
|
||||
const [form] = Form.useForm();
|
||||
const { systemSetting: initialValues, allOptions } =
|
||||
useFetchSystemModelSettingOnMount(visible);
|
||||
useFetchSystemModelSettingOnMount();
|
||||
const { t } = useTranslate('setting');
|
||||
|
||||
const handleOk = async () => {
|
||||
|
||||
Reference in New Issue
Block a user