import { Button, CircularProgress, makeStyles, Typography, } from "@material-ui/core"; import { ReactChild } from "react"; const useStyles = makeStyles((theme) => ({ root: { position: "relative", }, button: { marginTop: theme.spacing(2), textTransform: "none", width: "100%", }, loader: { position: "absolute", bottom: 0, left: "50%", marginLeft: -12, marginBottom: 6, }, error: { marginTop: theme.spacing(1), textAlign: "center", }, })); export default function ButtonWithLoader({ disabled, onClick, showLoader, error, children, className, }: { disabled?: boolean; onClick: () => void; showLoader?: boolean; error?: string; children: ReactChild; className?: string; }) { const classes = useStyles(); return ( <>
{showLoader ? ( ) : null}
{error ? ( {error} ) : null} ); }