import { Card, GetProps, styled, Text, XStack } from "tamagui"; import Icons from "./icons"; const AlertFrame = styled(Card, { px: "$4", py: "$3", bordered: true, variants: { variant: { default: {}, error: { backgroundColor: "$red2", borderColor: "$red5", }, }, } as const, }); const icons: Record = { error: "alert-circle-outline", }; type AlertProps = GetProps; const Alert = ({ children, variant = "default", ...props }: AlertProps) => { return ( {icons[variant] != null && ( )} {children} ); }; type ErrorAlert = AlertProps & { error?: unknown | null; }; export const ErrorAlert = ({ error, ...props }: ErrorAlert) => { if (!error) { return null; } const message = (error as any)?.message || "Something went wrong"; return ( {message} ); }; export default Alert;