-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle silent error for dashboard edit mutation (#5022)
* fix: handle silent error for dashboard edit mutation * fix: handle silent error for dashboard edit mutation
- Loading branch information
1 parent
78a897b
commit 4f20955
Showing
2 changed files
with
13 additions
and
24 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,26 +1,20 @@ | ||
import axios from 'api'; | ||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; | ||
import { AxiosError } from 'axios'; | ||
import { ErrorResponse, SuccessResponse } from 'types/api'; | ||
import { PayloadProps, Props } from 'types/api/dashboard/update'; | ||
|
||
const updateDashboard = async ( | ||
props: Props, | ||
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => { | ||
try { | ||
const response = await axios.put(`/dashboards/${props.uuid}`, { | ||
...props.data, | ||
}); | ||
const response = await axios.put(`/dashboards/${props.uuid}`, { | ||
...props.data, | ||
}); | ||
|
||
return { | ||
statusCode: 200, | ||
error: null, | ||
message: response.data.status, | ||
payload: response.data.data, | ||
}; | ||
} catch (error) { | ||
return ErrorResponseHandler(error as AxiosError); | ||
} | ||
return { | ||
statusCode: 200, | ||
error: null, | ||
message: response.data.status, | ||
payload: response.data.data, | ||
}; | ||
}; | ||
|
||
export default updateDashboard; |
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