-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathUpdateNotification.tsx
55 lines (52 loc) · 1.25 KB
/
UpdateNotification.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Id, toast } from "react-toastify";
import { getNetwork, getWeb3Instance } from "@/services/web3.service";
import { CheckMark } from "../../icons/IconsComponent";
const toastMarkUp = (message: string, receipt: string, explorer: string) => (
<>
<span className="mr-2 font-normal text-base">{message}</span>
<a
href={`${explorer}tx/${receipt}`}
target="_blank"
className="text-white font-medium underline"
>
View
</a>
</>
);
const UpdateNotification = (
message: string,
loadingToast: Id,
isError: boolean,
receipt?: string,
chainId?: number
) => {
if (isError) {
toast.update(loadingToast, {
render: message,
type: "warning",
isLoading: false,
autoClose: 3000,
theme: "light",
});
} else {
toast.update(loadingToast, {
render: toastMarkUp(
message,
receipt || "",
getWeb3Instance(getNetwork(chainId)).explorer
),
type: "success",
style: {
boxShadow: "0px 3px 6px #00000026",
background: "black",
color: "#D0CFCF",
},
icon: <CheckMark />,
isLoading: false,
autoClose: 10000,
closeButton: true,
theme: "colored",
});
}
}
export default UpdateNotification;