forked from SigNoz/signoz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: all dashboard is migrated to useQuery and action is removed (Si…
…gNoz#3384) * feat: all dashboard is migrated to useQuery and action is removed * chore: delete functionality is updated --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
- Loading branch information
1 parent
dfd94f6
commit 41f7a79
Showing
10 changed files
with
101 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
import axios from 'api'; | ||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; | ||
import { AxiosError } from 'axios'; | ||
import { ErrorResponse, SuccessResponse } from 'types/api'; | ||
import { PayloadProps } from 'types/api/dashboard/getAll'; | ||
import { ApiResponse } from 'types/api'; | ||
import { Dashboard } from 'types/api/dashboard/getAll'; | ||
|
||
const getAll = async (): Promise< | ||
SuccessResponse<PayloadProps> | ErrorResponse | ||
> => { | ||
try { | ||
const response = await axios.get('/dashboards'); | ||
|
||
return { | ||
statusCode: 200, | ||
error: null, | ||
message: response.data.message, | ||
payload: response.data.data, | ||
}; | ||
} catch (error) { | ||
return ErrorResponseHandler(error as AxiosError); | ||
} | ||
}; | ||
|
||
export default getAll; | ||
export const getAllDashboardList = (): Promise<Dashboard[]> => | ||
axios | ||
.get<ApiResponse<Dashboard[]>>('/dashboards') | ||
.then((res) => res.data.data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,10 @@ | ||
import getAll from 'api/dashboard/getAll'; | ||
import { getAllDashboardList } from 'api/dashboard/getAll'; | ||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; | ||
import { useQuery, UseQueryResult } from 'react-query'; | ||
import { ErrorResponse, SuccessResponse } from 'types/api'; | ||
import { PayloadProps } from 'types/api/dashboard/getAll'; | ||
import { Dashboard } from 'types/api/dashboard/getAll'; | ||
|
||
export const useGetAllDashboard = (): DashboardProps => | ||
useQuery({ | ||
queryFn: getAll, | ||
export const useGetAllDashboard = (): UseQueryResult<Dashboard[], unknown> => | ||
useQuery<Dashboard[]>({ | ||
queryFn: getAllDashboardList, | ||
queryKey: REACT_QUERY_KEY.GET_ALL_DASHBOARDS, | ||
}); | ||
|
||
type DashboardProps = UseQueryResult< | ||
SuccessResponse<PayloadProps> | ErrorResponse, | ||
unknown | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.