Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 3af144d

Browse files
praveen5959praveen5959
andauthored
fix: missing query in API call on dashboard page (#362)
--------- Co-authored-by: praveen5959 <[email protected]>
1 parent 292e1ce commit 3af144d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/hooks/useDashboards.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import {
1212
UpdateDashboardType,
1313
} from '@/@types/parseable/api/dashboards';
1414
import { useSearchParams } from 'react-router-dom';
15+
import { sanitiseSqlString } from '@/utils/sanitiseSqlString';
1516

1617
const { setDashboards, setTileData, selectDashboard } = dashboardsStoreReducers;
1718

1819
export const useDashboardsQuery = (opts: { updateTimeRange?: (dashboard: Dashboard) => void }) => {
1920
const [activeDashboard, setDashboardsStore] = useDashboardsStore((store) => store.activeDashboard);
20-
const [searchParams] = useSearchParams()
21+
const [searchParams] = useSearchParams();
2122

2223
const {
2324
isError: fetchDashaboardsError,
@@ -156,10 +157,10 @@ export const useTileQuery = (opts: {
156157
const [, setDashboardsStore] = useDashboardsStore((_store) => null);
157158
const { query, startTime, endTime, tileId, enabled = true } = opts;
158159
const { isLoading, isFetching, isError, refetch } = useQuery(
159-
[tileId, query, startTime, endTime],
160+
[tileId, startTime, endTime],
160161
() =>
161162
getQueryData({
162-
query,
163+
query: sanitiseSqlString(query, false, 100),
163164
startTime,
164165
endTime,
165166
}),
@@ -169,6 +170,9 @@ export const useTileQuery = (opts: {
169170
if (tileId) {
170171
setDashboardsStore((store) => setTileData(store, tileId, tileData));
171172
}
173+
if (opts.onSuccess) {
174+
opts.onSuccess(tileData);
175+
}
172176
},
173177
onError: (error: AxiosError) => {
174178
if (isAxiosError(error) && error.response) {

src/pages/Dashboards/CreateTileForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ const Query = (props: { form: TileFormType; onChangeValue: (key: string, value:
328328

329329
const { refetch, isLoading } = useTileQuery({
330330
onSuccess: onFetchTileSuccess,
331-
query: '', // Initial query (will be updated in refetch)
331+
query,
332332
startTime: timeRange.startTime,
333333
endTime: timeRange.endTime,
334334
enabled: false,

0 commit comments

Comments
 (0)