Add CodeErrorDataTypeAPI and ResponseErrorTypeAPI to types/api

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-06 14:47:25 -03:00
commit 1d9aed286a
2 changed files with 16 additions and 1 deletions

View file

@ -26,6 +26,7 @@ import { useDarkStore } from "../../stores/darkStore";
import useFlowStore from "../../stores/flowStore";
import { codeAreaModalPropsType } from "../../types/components";
import BaseModal from "../baseModal";
import { CodeErrorDataTypeAPI } from "../../types/api";
export default function CodeAreaModal({
value,
@ -50,7 +51,7 @@ export default function CodeAreaModal({
const setSuccessData = useAlertStore((state) => state.setSuccessData);
const setErrorData = useAlertStore((state) => state.setErrorData);
const [error, setError] = useState<{
detail: { error: string | undefined; traceback: string | undefined };
detail: CodeErrorDataTypeAPI;
} | null>(null);
useEffect(() => {

View file

@ -159,3 +159,17 @@ export type VertexDataTypeAPI = {
timedelta?: number;
duration?: string;
};
export type CodeErrorDataTypeAPI = {
error: string | undefined;
traceback: string | undefined;
};
// the error above is inside this error.response.data.detail.error
// which comes from a request to the API
// to type the error we need to know the structure of the object
// error that has a response, that has a data, that has a detail, that has an error
export type ResponseErrorTypeAPI = {
response: { data: { detail: CodeErrorDataTypeAPI } };
};