import { IconDefinition } from "@fortawesome/fontawesome-svg-core"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Button, ButtonProps, Text } from "@mantine/core"; import { FunctionComponent, PropsWithChildren, useCallback, useState, } from "react"; type ToolboxButtonProps = Omit< ButtonProps<"button">, "color" | "variant" | "leftIcon" > & { icon: IconDefinition; children: string; }; const ToolboxButton: FunctionComponent = ({ icon, children, ...props }) => { return ( ); }; type ToolboxMutateButtonProps Promise> = { promise: T; onSuccess?: (item: R) => void; } & Omit; export function ToolboxMutateButton Promise>( props: PropsWithChildren> ): JSX.Element { const { promise, onSuccess, ...button } = props; const [loading, setLoading] = useState(false); const click = useCallback(() => { setLoading(true); promise().then((val) => { setLoading(false); onSuccess && onSuccess(val); }); }, [onSuccess, promise]); return ( ); } export default ToolboxButton;