-
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from kreneskyp/agent_editor_errors_mvp
Agent editor errors mvp
- Loading branch information
Showing
4 changed files
with
57 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Box, List, ListItem, Text } from "@chakra-ui/react"; | ||
import React from "react"; | ||
|
||
export const APIErrorList = ({ error }) => { | ||
const extractErrors = (axiosError) => { | ||
return axiosError.response.data.detail | ||
.map((error) => { | ||
if (error.loc && error.msg) { | ||
let field = error.loc[1]; | ||
return `'${field}' field is ${error.msg}.`; | ||
} | ||
return null; | ||
}) | ||
.filter((message) => message); // Filter out any null values | ||
}; | ||
|
||
const errorMessages = extractErrors(error); | ||
|
||
return ( | ||
<Box> | ||
<Text mb={2}>Failed to save the agent due to the following errors:</Text> | ||
<List spacing={1}> | ||
{errorMessages.map((msg, index) => ( | ||
<ListItem key={index}>- {msg}</ListItem> | ||
))} | ||
</List> | ||
</Box> | ||
); | ||
}; |
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,13 @@ | ||
import React from "react"; | ||
import { Text } from "@chakra-ui/react"; | ||
import { useColorMode } from "@chakra-ui/color-mode"; | ||
|
||
export const RequiredAsterisk = () => { | ||
const { colorMode } = useColorMode(); | ||
const color = colorMode === "light" ? "red.500" : "red.200"; | ||
return ( | ||
<Text as="span" color={color}> | ||
* | ||
</Text> | ||
); | ||
}; |