Skip to content

Commit

Permalink
refactor(alert-component): move the error property to the ErrorAlert …
Browse files Browse the repository at this point in the history
…component
  • Loading branch information
AXeL-dev committed Oct 8, 2022
1 parent 44f7b60 commit 2efda49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/ui/components/shared/Alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import CloseIcon from '@mui/icons-material/Close';
export interface AlertProps {
open?: boolean;
children?: React.ReactNode;
error?: any;
severity?: AlertColor;
closable?: boolean;
syncOpen?: boolean;
Expand All @@ -16,13 +15,12 @@ export interface AlertProps {
export function Alert(props: AlertProps) {
const {
open: openProp = true,
error,
children,
severity = 'error',
closable,
syncOpen,
onClose,
} = props;
const children = props.children || error?.data?.error.message || error?.error;
const [open, setOpen] = useState(openProp);

useEffect(() => {
Expand Down
4 changes: 3 additions & 1 deletion src/ui/components/shared/ErrorAlert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ enum Error {
INVALID_API_KEY = 'API key not valid. Please pass a valid API key.',
}

interface ErrorAlertProps extends AlertProps {}
interface ErrorAlertProps extends AlertProps {
error?: any;
}

export function ErrorAlert(props: ErrorAlertProps) {
const { error, ...rest } = props;
Expand Down

0 comments on commit 2efda49

Please sign in to comment.