Skip to content

Commit

Permalink
fix: missing query in API call on dashboard page (#362)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: praveen5959 <[email protected]>
  • Loading branch information
praveen5959 and praveen5959 authored Nov 9, 2024
1 parent 292e1ce commit 3af144d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/hooks/useDashboards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import {
UpdateDashboardType,
} from '@/@types/parseable/api/dashboards';
import { useSearchParams } from 'react-router-dom';
import { sanitiseSqlString } from '@/utils/sanitiseSqlString';

const { setDashboards, setTileData, selectDashboard } = dashboardsStoreReducers;

export const useDashboardsQuery = (opts: { updateTimeRange?: (dashboard: Dashboard) => void }) => {
const [activeDashboard, setDashboardsStore] = useDashboardsStore((store) => store.activeDashboard);
const [searchParams] = useSearchParams()
const [searchParams] = useSearchParams();

const {
isError: fetchDashaboardsError,
Expand Down Expand Up @@ -156,10 +157,10 @@ export const useTileQuery = (opts: {
const [, setDashboardsStore] = useDashboardsStore((_store) => null);
const { query, startTime, endTime, tileId, enabled = true } = opts;
const { isLoading, isFetching, isError, refetch } = useQuery(
[tileId, query, startTime, endTime],
[tileId, startTime, endTime],
() =>
getQueryData({
query,
query: sanitiseSqlString(query, false, 100),
startTime,
endTime,
}),
Expand All @@ -169,6 +170,9 @@ export const useTileQuery = (opts: {
if (tileId) {
setDashboardsStore((store) => setTileData(store, tileId, tileData));
}
if (opts.onSuccess) {
opts.onSuccess(tileData);
}
},
onError: (error: AxiosError) => {
if (isAxiosError(error) && error.response) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboards/CreateTileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const Query = (props: { form: TileFormType; onChangeValue: (key: string, value:

const { refetch, isLoading } = useTileQuery({
onSuccess: onFetchTileSuccess,
query: '', // Initial query (will be updated in refetch)
query,
startTime: timeRange.startTime,
endTime: timeRange.endTime,
enabled: false,
Expand Down

0 comments on commit 3af144d

Please sign in to comment.