Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 48x 48x 48x 227x 227x 227x 681x | import {
Alert as MuiAlert,
AlertProps as MuiAlertProps,
styled,
} from "@mui/material";
import { grpcErrorStrings, ObscureGrpcErrorMessages } from "appConstants";
import React from "react";
const StyledAlert = styled(MuiAlert)(({ theme }) => ({
marginBottom: theme.spacing(2),
}));
interface AlertProps extends MuiAlertProps {
severity: MuiAlertProps["severity"];
children: string;
}
export default function Alert({
className,
children,
...otherProps
}: AlertProps) {
const oldErrorKey = Object.keys(grpcErrorStrings).find(
(oldError): oldError is ObscureGrpcErrorMessages =>
children.includes(oldError)
);
return (
<StyledAlert {...otherProps} className={className}>
{
// Search for the error in the ugly grpc error object keys
// Replace it with the nice error if found
oldErrorKey ? grpcErrorStrings[oldErrorKey] : children
}
</StyledAlert>
);
}
|