import React from 'react'; import { ButtonProps, Button } from "@chakra-ui/react"; import { useErrorHandler, useProvider } from "@strata-foundation/react"; import { useAsyncCallback } from "react-async-hook"; export type AsyncButtonProps = { children: React.ReactNode; action: () => Promise | undefined; } & ButtonProps; export const AsyncButton = ({ action, children, ...props }: AsyncButtonProps) => { const { awaitingApproval } = useProvider(); const { execute, loading, error } = useAsyncCallback(action); const { handleErrors } = useErrorHandler(); handleErrors(error); return ( ); };