()
| 323 | } |
| 324 | |
| 325 | const saveTool = async () => { |
| 326 | try { |
| 327 | const saveResp = await toolsApi.updateTool(toolId, { |
| 328 | name: toolName, |
| 329 | description: toolDesc, |
| 330 | schema: JSON.stringify(toolSchema), |
| 331 | func: toolFunc, |
| 332 | iconSrc: toolIcon |
| 333 | }) |
| 334 | if (saveResp.data) { |
| 335 | enqueueSnackbar({ |
| 336 | message: 'Tool saved', |
| 337 | options: { |
| 338 | key: new Date().getTime() + Math.random(), |
| 339 | variant: 'success', |
| 340 | action: (key) => ( |
| 341 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 342 | <IconX /> |
| 343 | </Button> |
| 344 | ) |
| 345 | } |
| 346 | }) |
| 347 | onConfirm(saveResp.data.id) |
| 348 | } |
| 349 | } catch (error) { |
| 350 | enqueueSnackbar({ |
| 351 | message: `Failed to save Tool: ${ |
| 352 | typeof error.response.data === 'object' ? error.response.data.message : error.response.data |
| 353 | }`, |
| 354 | options: { |
| 355 | key: new Date().getTime() + Math.random(), |
| 356 | variant: 'error', |
| 357 | persist: true, |
| 358 | action: (key) => ( |
| 359 | <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}> |
| 360 | <IconX /> |
| 361 | </Button> |
| 362 | ) |
| 363 | } |
| 364 | }) |
| 365 | onCancel() |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | const deleteTool = async () => { |
| 370 | const confirmPayload = { |
no test coverage detected