MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / handleRequest

Function handleRequest

frontend/src/components/actions/index.tsx:138–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 setOpenDrawer(true)
137 }
138 const handleRequest = async () => {
139
140 if (!schema) {
141 setTipSchema(true)
142 return
143 }
144 let schemaStr = schema
145 try {
146 if (schema.endsWith(',')) {
147 schemaStr = schema.slice(0, -1)
148 } else {
149 schemaStr = schema
150 }
151 JSON.parse(schemaStr)
152 } catch (e) {
153 toast.error(`${t('projectToolsActionInvalidSchema')}`)
154 return
155 }
156 const commonData: commonDataType = {
157 openapi_schema: JSON.parse(schemaStr),
158 authentication: {
159 type: radioValue,
160 content: undefined,
161 secret: undefined
162 }
163 };
164 if (radioValue === 'custom') {
165 if (commonData.authentication) {
166 commonData.authentication.content = { [custom]: Authentication };
167 }
168 } else {
169 if (radioValue === 'none') {
170 (commonData.authentication as any).type = 'none'
171 } else {
172 if (commonData.authentication) {
173 commonData.authentication.secret = Authentication;
174 }
175 }
176 }
177 try {
178 if (actionId) {
179 (actionDrawerRef.current as any).getResetButtonState() && (commonData.authentication = undefined)
180 await updateActions(actionId, commonData);
181 } else {
182 await createActions(commonData);
183 }
184 const limit1: number = limit || 20
185 dispatch(fetchActionData(limit1) as any);
186 setUpdatePrevButton(true)
187 } catch (error) {
188 console.error(error);
189 const apiError = error as ApiErrorResponse;
190 const messageError: string = apiError.response.data.error.message;
191 toast.error(messageError)
192 }
193
194 setOpenDrawer(false)
195 }

Callers 1

ActionsFunction · 0.70

Calls 3

updateActionsFunction · 0.90
createActionsFunction · 0.90
fetchActionDataFunction · 0.90

Tested by

no test coverage detected