1
1
import { Box , Skeleton } from "@mui/material" ;
2
2
import { FC , ReactNode } from "react" ;
3
3
4
- import { LoadingButton , LoadingButtonProps , Typography } from "@atoms" ;
4
+ import { Button , LoadingButton , LoadingButtonProps , Typography } from "@atoms" ;
5
5
import { useScreenDimension , useTranslation } from "@hooks" ;
6
6
import { Card } from "./Card" ;
7
+ import { openInNewTab } from "@/utils" ;
7
8
8
9
export type DashboardActionCardProps = {
9
10
buttons ?: LoadingButtonProps [ ] ;
@@ -12,8 +13,10 @@ export type DashboardActionCardProps = {
12
13
description ?: ReactNode ;
13
14
imageURL ?: string ;
14
15
isLoading ?: boolean ;
16
+ isInProgressOnCard ?: boolean ;
15
17
state ?: "active" | "inProgress" | "default" ;
16
18
title ?: ReactNode ;
19
+ transactionId ?: string ;
17
20
} ;
18
21
19
22
export const DashboardActionCard : FC < DashboardActionCardProps > = ( {
@@ -26,12 +29,17 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
26
29
description,
27
30
imageURL,
28
31
isLoading = false ,
32
+ isInProgressOnCard = true ,
29
33
state = "default" ,
30
34
title,
35
+ transactionId,
31
36
} = props ;
32
37
33
38
const { screenWidth } = useScreenDimension ( ) ;
34
39
40
+ const onClickShowTransaction = ( ) =>
41
+ openInNewTab ( `https://sancho.cexplorer.io/tx/${ transactionId } ` ) ;
42
+
35
43
return (
36
44
< Card
37
45
{ ...( state === "inProgress" && {
@@ -40,10 +48,10 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
40
48
variant : "warning" ,
41
49
} ) }
42
50
sx = { {
51
+ backgroundColor : state === "active" ? "#F0F4FF" : undefined ,
43
52
flex : 1 ,
44
53
display : "flex" ,
45
54
flexDirection : "column" ,
46
- gap : 3 ,
47
55
maxWidth : 524 ,
48
56
} }
49
57
>
@@ -69,11 +77,15 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
69
77
{ title ? (
70
78
< Typography sx = { { mt : 2 } } variant = "title2" >
71
79
{ isLoading ? < Skeleton variant = "rounded" /> : title }
72
- </ Typography >
73
- ) : null }
74
- { state === "inProgress" && ! isLoading ? (
75
- < Typography variant = "title2" fontWeight = { 700 } >
76
- { t ( "inProgress" ) }
80
+ { state === "inProgress" && ! isLoading && isInProgressOnCard ? (
81
+ < Typography
82
+ variant = "title2"
83
+ fontWeight = { 600 }
84
+ sx = { { display : "inline" } }
85
+ >
86
+ { ` ${ t ( "inProgress" ) } ` }
87
+ </ Typography >
88
+ ) : null }
77
89
</ Typography >
78
90
) : null }
79
91
{ description ? (
@@ -93,10 +105,20 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
93
105
) : null }
94
106
</ Box >
95
107
{ children }
108
+ { transactionId && (
109
+ < Button
110
+ onClick = { onClickShowTransaction }
111
+ sx = { { width : "fit-content" , p : 0 } }
112
+ variant = "text"
113
+ >
114
+ { t ( "dashboard.cards.showTransaction" ) }
115
+ </ Button >
116
+ ) }
96
117
< Box
97
118
display = "flex"
98
119
flexDirection = { screenWidth < 640 ? "column" : "row" }
99
- gap = { { xxs : 0 , md : 2 } }
120
+ mt = { 3 }
121
+ gap = { 2 }
100
122
>
101
123
{ isLoading ? (
102
124
< >
@@ -125,6 +147,7 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
125
147
xxs : "100%" ,
126
148
md : "auto" ,
127
149
} ,
150
+ ...buttonProps . sx ,
128
151
} }
129
152
{ ...buttonProps }
130
153
/>
0 commit comments