balibabu
commited on
Commit
·
91751af
1
Parent(s):
d98ee8e
fix: Error on chat api,<BadRequestKeyError '400: Bad Request'> #1918 (#1923)
Browse files### What problem does this PR solve?
fix: Error on chat api,<BadRequestKeyError '400: Bad Request'> #1918
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
web/src/components/api-service/hooks.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import {
|
2 |
useCreateNextToken,
|
3 |
-
useFetchNextStats,
|
4 |
useFetchTokenList,
|
5 |
useRemoveNextToken,
|
6 |
} from '@/hooks/chat-hooks';
|
@@ -10,6 +9,7 @@ import {
|
|
10 |
useTranslate,
|
11 |
} from '@/hooks/common-hooks';
|
12 |
import { IStats } from '@/interfaces/database/chat';
|
|
|
13 |
import { message } from 'antd';
|
14 |
import { useCallback } from 'react';
|
15 |
|
@@ -46,7 +46,9 @@ type ChartStatsType = {
|
|
46 |
};
|
47 |
|
48 |
export const useSelectChartStatsList = (): ChartStatsType => {
|
49 |
-
const
|
|
|
|
|
50 |
|
51 |
return Object.keys(stats).reduce((pre, cur) => {
|
52 |
const item = stats[cur as keyof IStats];
|
|
|
1 |
import {
|
2 |
useCreateNextToken,
|
|
|
3 |
useFetchTokenList,
|
4 |
useRemoveNextToken,
|
5 |
} from '@/hooks/chat-hooks';
|
|
|
9 |
useTranslate,
|
10 |
} from '@/hooks/common-hooks';
|
11 |
import { IStats } from '@/interfaces/database/chat';
|
12 |
+
import { useQueryClient } from '@tanstack/react-query';
|
13 |
import { message } from 'antd';
|
14 |
import { useCallback } from 'react';
|
15 |
|
|
|
46 |
};
|
47 |
|
48 |
export const useSelectChartStatsList = (): ChartStatsType => {
|
49 |
+
const queryClient = useQueryClient();
|
50 |
+
const data = queryClient.getQueriesData({ queryKey: ['fetchStats'] });
|
51 |
+
const stats: IStats = data[0][1] as IStats;
|
52 |
|
53 |
return Object.keys(stats).reduce((pre, cur) => {
|
54 |
const item = stats[cur as keyof IStats];
|
web/src/hooks/chat-hooks.ts
CHANGED
@@ -260,8 +260,8 @@ const getDay = (date?: Dayjs) => date?.format('YYYY-MM-DD');
|
|
260 |
|
261 |
export const useFetchNextStats = () => {
|
262 |
const [pickerValue, setPickerValue] = useState<RangeValue>([
|
263 |
-
dayjs(),
|
264 |
dayjs().subtract(7, 'day'),
|
|
|
265 |
]);
|
266 |
const { data, isFetching: loading } = useQuery<IStats>({
|
267 |
queryKey: ['fetchStats', pickerValue],
|
|
|
260 |
|
261 |
export const useFetchNextStats = () => {
|
262 |
const [pickerValue, setPickerValue] = useState<RangeValue>([
|
|
|
263 |
dayjs().subtract(7, 'day'),
|
264 |
+
dayjs(),
|
265 |
]);
|
266 |
const { data, isFetching: loading } = useQuery<IStats>({
|
267 |
queryKey: ['fetchStats', pickerValue],
|