* Remove kyb/kyc, update stripe * Knip cleanup, improve stripe init * Update dependencies * Remove unused campaign * eslint * unused * Update dependencies * Missing a focuslock here * Add a spinner to wait for the page to reload * Update stripe again * format * Update dependencies again * update * Update lock * Nightly * Recover file * format * update * Run install
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { useToast } from "@chakra-ui/react";
|
|
import { useErrorHandler } from "contexts/error-handler";
|
|
import { useCallback } from "react";
|
|
import { useInvalidateContractQuery } from "thirdweb/react";
|
|
|
|
export function useTxNotifications(
|
|
successMessage: string,
|
|
errorMessage: string,
|
|
contract?: any,
|
|
) {
|
|
const toast = useToast();
|
|
const { onError } = useErrorHandler();
|
|
const invalidateContractQuery = useInvalidateContractQuery();
|
|
|
|
const onSuccess = useCallback(() => {
|
|
toast({
|
|
position: "bottom",
|
|
variant: "solid",
|
|
title: "Success",
|
|
description: successMessage,
|
|
status: "success",
|
|
duration: 5000,
|
|
isClosable: true,
|
|
});
|
|
if (contract) {
|
|
invalidateContractQuery({
|
|
chainId: contract.chainId,
|
|
contractAddress: contract.getAddress(),
|
|
});
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [successMessage]);
|
|
|
|
const _onError = useCallback(
|
|
(error: unknown) => {
|
|
onError(error, errorMessage);
|
|
},
|
|
[errorMessage, onError],
|
|
);
|
|
|
|
return { onSuccess, onError: _onError };
|
|
}
|