11import { FC } from "react" ;
2- import { Box } from "@mui/material" ;
2+ import { Box , Skeleton } from "@mui/material" ;
33
44import { Button } from "@atoms" ;
55import {
88 GovernanceActionCardStatePill ,
99 GovernanceActionsDatesBox ,
1010} from "@molecules" ;
11-
1211import { useScreenDimension , useTranslation } from "@hooks" ;
1312import {
1413 encodeCIP129Identifier ,
@@ -23,33 +22,32 @@ type ActionTypeProps = Omit<
2322 | "yesVotes"
2423 | "noVotes"
2524 | "abstainVotes"
26- | "metadataHash"
27- | "url"
2825 | "id"
2926 | "details"
3027 | "rationale"
3128 | "motivation"
3229> & {
3330 onClick ?: ( ) => void ;
3431 inProgress ?: boolean ;
32+ isValidating ?: boolean ;
33+ metadataStatus ?: MetadataValidationStatus ;
3534} ;
3635
37- export const GovernanceActionCard : FC < ActionTypeProps > = ( { ...props } ) => {
38- const {
39- abstract,
40- type,
41- inProgress = false ,
42- expiryDate,
43- expiryEpochNo,
44- onClick,
45- createdDate,
46- createdEpochNo,
47- txHash,
48- index,
49- metadataStatus,
50- metadataValid,
51- title,
52- } = props ;
36+ export const GovernanceActionCard : FC < ActionTypeProps > = ( {
37+ abstract,
38+ type,
39+ inProgress = false ,
40+ expiryDate,
41+ expiryEpochNo,
42+ onClick,
43+ createdDate,
44+ createdEpochNo,
45+ txHash,
46+ index,
47+ title,
48+ isValidating,
49+ metadataStatus,
50+ } ) => {
5351 const { isMobile, screenWidth } = useScreenDimension ( ) ;
5452 const { t } = useTranslation ( ) ;
5553
@@ -71,10 +69,10 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
7169 justifyContent : "space-between" ,
7270 boxShadow : "0px 4px 15px 0px #DDE3F5" ,
7371 borderRadius : "20px" ,
74- backgroundColor : ! metadataValid
72+ backgroundColor : metadataStatus
7573 ? "rgba(251, 235, 235, 0.50)"
7674 : "rgba(255, 255, 255, 0.3)" ,
77- ...( ! metadataValid && {
75+ ...( ! ! metadataStatus && {
7876 border : "1px solid #F6D5D5" ,
7977 } ) ,
8078 ...( inProgress && {
@@ -92,15 +90,17 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
9290 < GovernanceActionCardHeader
9391 title = { title }
9492 isDataMissing = { metadataStatus }
93+ isValidating = { isValidating }
9594 />
96- { ! metadataStatus && (
95+ { ! ! metadataStatus && (
9796 < GovernanceActionCardElement
9897 label = { t ( "govActions.abstract" ) }
9998 text = { abstract }
10099 textVariant = "twoLines"
101100 dataTestId = "governance-action-abstract"
102101 isSliderCard
103102 isMarkdown
103+ isValidating = { isValidating }
104104 />
105105 ) }
106106 < GovernanceActionCardElement
@@ -109,20 +109,23 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
109109 textVariant = "pill"
110110 dataTestId = { `${ getProposalTypeNoEmptySpaces ( type ) } -type` }
111111 isSliderCard
112+ isValidating = { isValidating }
112113 />
113114 < GovernanceActionsDatesBox
114115 createdDate = { createdDate }
115116 expiryDate = { expiryDate }
116117 expiryEpochNo = { expiryEpochNo }
117118 createdEpochNo = { createdEpochNo }
118119 isSliderCard
120+ isValidating = { isValidating }
119121 />
120122 < GovernanceActionCardElement
121123 label = { t ( "govActions.cip129GovernanceActionId" ) }
122124 text = { cip129GovernanceActionId }
123125 dataTestId = { `${ cip129GovernanceActionId } -id` }
124126 isCopyButton
125127 isSliderCard
128+ isValidating = { isValidating }
126129 />
127130 < GovernanceActionCardElement
128131 label = { t ( "govActions.governanceActionId" ) }
@@ -131,6 +134,7 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
131134 isCopyButton
132135 isSliderCard
133136 isSemiTransparent
137+ isValidating = { isValidating }
134138 />
135139 </ Box >
136140 < Box
@@ -142,21 +146,25 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
142146 bgcolor : "white" ,
143147 } }
144148 >
145- < Button
146- onClick = { onClick }
147- variant = { inProgress ? "outlined" : "contained" }
148- size = "large"
149- sx = { {
150- width : "100%" ,
151- } }
152- data-testid = { `govaction-${ govActionId } -view-detail` }
153- >
154- { t (
155- inProgress
156- ? "govActions.viewDetails"
157- : "govActions.viewDetailsAndVote" ,
158- ) }
159- </ Button >
149+ { isValidating ? (
150+ < Skeleton width = "100%" height = "40px" sx = { { borderRadius : "20px" } } />
151+ ) : (
152+ < Button
153+ onClick = { onClick }
154+ variant = { inProgress ? "outlined" : "contained" }
155+ size = "large"
156+ sx = { {
157+ width : "100%" ,
158+ } }
159+ data-testid = { `govaction-${ govActionId } -view-detail` }
160+ >
161+ { t (
162+ inProgress
163+ ? "govActions.viewDetails"
164+ : "govActions.viewDetailsAndVote" ,
165+ ) }
166+ </ Button >
167+ ) }
160168 </ Box >
161169 </ Box >
162170 ) ;
0 commit comments