-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: component code validation (#3470)
* removed post custom component update * Added post validade component code mutation * Used post validade code mutation on component code * removed unused console log * used validate component code on generic node code validation
- Loading branch information
1 parent
16b8b43
commit f0ca3c8
Showing
6 changed files
with
95 additions
and
89 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
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
50 changes: 50 additions & 0 deletions
50
src/frontend/src/controllers/API/queries/nodes/use-post-validate-component-code.ts
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
APIClassType, | ||
CustomComponentRequest, | ||
ResponseErrorTypeAPI, | ||
useMutationFunctionType, | ||
} from "@/types/api"; | ||
import { UseMutationResult } from "@tanstack/react-query"; | ||
import { api } from "../../api"; | ||
import { getURL } from "../../helpers/constants"; | ||
import { UseRequestProcessor } from "../../services/request-processor"; | ||
|
||
interface IPostValidateComponentCode { | ||
code: string; | ||
frontend_node: APIClassType; | ||
} | ||
|
||
export const usePostValidateComponentCode: useMutationFunctionType< | ||
undefined, | ||
IPostValidateComponentCode, | ||
CustomComponentRequest, | ||
ResponseErrorTypeAPI | ||
> = (options?) => { | ||
const { mutate } = UseRequestProcessor(); | ||
|
||
const postValidateComponentCodeFn = async ( | ||
payload: IPostValidateComponentCode, | ||
): Promise<CustomComponentRequest> => { | ||
const response = await api.post<CustomComponentRequest>( | ||
getURL("CUSTOM_COMPONENT"), | ||
{ | ||
code: payload.code, | ||
frontend_node: payload.frontend_node, | ||
}, | ||
); | ||
|
||
return response.data; | ||
}; | ||
|
||
const mutation: UseMutationResult< | ||
CustomComponentRequest, | ||
ResponseErrorTypeAPI, | ||
IPostValidateComponentCode | ||
> = mutate( | ||
["usePostValidateComponentCode"], | ||
postValidateComponentCodeFn, | ||
options, | ||
); | ||
|
||
return mutation; | ||
}; |
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 was deleted.
Oops, something went wrong.