-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSuccessModal.tsx
92 lines (87 loc) · 2.89 KB
/
SuccessModal.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import React from "react"
import {
ModalBody,
ModalCloseButton,
ModalFooter,
ModalHeader,
VStack,
Text,
} from "@chakra-ui/react"
import { LoadingSpinnerSuccessIcon } from "#/assets/icons"
import { useActionFlowTokenAmount, useActionFlowTxHash } from "#/hooks"
import CurrencyBalanceWithConversion from "#/components/shared/CurrencyBalanceWithConversion"
import { ACTION_FLOW_TYPES, ActionFlowType } from "#/types"
import { activitiesUtils } from "#/utils"
import { Alert, AlertIcon, AlertDescription } from "#/components/shared/Alert"
import BlockExplorerLink from "../shared/BlockExplorerLink"
type SuccessModalProps = {
type: ActionFlowType
}
export default function SuccessModal({ type }: SuccessModalProps) {
const tokenAmount = useActionFlowTokenAmount()
const txHash = useActionFlowTxHash()
// TODO: We should use one type for flow and activity
const activityType = type === ACTION_FLOW_TYPES.STAKE ? "deposit" : "withdraw"
return (
<>
<ModalCloseButton />
<ModalHeader textAlign="center" pt={{ sm: 16 }}>
{ACTION_FLOW_TYPES.UNSTAKE === type
? "Withdrawal initiated!"
: "Deposit received!"}
</ModalHeader>
<ModalBody gap={10}>
<VStack gap={4}>
<LoadingSpinnerSuccessIcon boxSize={14} />
{tokenAmount && (
<VStack spacing={0} mb={9}>
<CurrencyBalanceWithConversion
from={{
currency: tokenAmount.currency,
amount: tokenAmount.amount.toString(),
size: "4xl",
fontWeight: "semibold",
}}
to={{
currency: "usd",
size: "md",
fontWeight: "medium",
}}
/>
</VStack>
)}
{ACTION_FLOW_TYPES.UNSTAKE === type && (
<Text size="md">
Funds will arrive in your wallet once the withdrawal is complete.
Track progress in your dashboard.
</Text>
)}
{ACTION_FLOW_TYPES.STAKE === type && txHash && (
<BlockExplorerLink
id={txHash}
type="transaction"
chain="bitcoin"
text="View on Mempool"
/>
)}
</VStack>
</ModalBody>
<ModalFooter pt={2}>
<Alert variant="elevated">
<AlertIcon status="loading" />
<AlertDescription>
<Text size="sm">You can close this window.</Text>
<Text size="sm">The process will continue in the background.</Text>
<Text size="sm" color="#7D6A4B">
Estimated duration ~{" "}
{activitiesUtils.getEstimatedDuration(
tokenAmount?.amount ?? 0n,
activityType,
)}
</Text>
</AlertDescription>
</Alert>
</ModalFooter>
</>
)
}