@@ -6,7 +6,7 @@ import { displayAsCcd } from 'wallet-common-helpers';
66import { AccountInfoType , Ratio } from '@concordium/web-sdk' ;
77import { absoluteRoutes , relativeRoutes } from '@popup/popupX/constants/routes' ;
88import Img from '@popup/shared/Img' ;
9- import { WalletCredential } from '@shared/storage/types' ;
9+ import { ConfirmedCredential , CreationStatus , WalletCredential } from '@shared/storage/types' ;
1010import { useAccountInfo } from '@popup/shared/AccountInfoListenerContext' ;
1111import { useFlattenedAccountTokens } from '@popup/pages/Account/Tokens/utils' ;
1212import { getMetadataUnique } from '@shared/utils/token-helpers' ;
@@ -112,25 +112,26 @@ function TokenItem({ thumbnail, symbol, balance, balanceBase, staked, microCcdPe
112112 ) ;
113113}
114114
115- type MainPageProps = { credential : WalletCredential } ;
115+ type MainPageConfirmedAccountProps = { credential : ConfirmedCredential } ;
116116
117- function MainPage ( { credential } : MainPageProps ) {
117+ function MainPageConfirmedAccount ( { credential } : MainPageConfirmedAccountProps ) {
118118 const { t } = useTranslation ( 'x' , { keyPrefix : 'mainPage' } ) ;
119119
120120 const nav = useNavigate ( ) ;
121121 const navToSend = ( ) => nav ( relativeRoutes . home . send . path ) ;
122122 const navToReceive = ( ) => nav ( relativeRoutes . home . receive . path ) ;
123123 const navToTransactionLog = ( ) =>
124124 nav ( relativeRoutes . home . transactionLog . path . replace ( ':account' , credential . address ) ) ;
125- const navToTokenDetails = ( contractIndex : string ) => {
126- return nav ( absoluteRoutes . home . token . details . path . replace ( ':contractIndex' , contractIndex ) ) ;
127- } ;
125+ const navToTokenDetails = ( contractIndex : string ) =>
126+ nav ( absoluteRoutes . home . token . details . path . replace ( ':contractIndex' , contractIndex ) ) ;
127+
128128 const navToManageToken = ( ) => nav ( relativeRoutes . home . manageTokenList . path ) ;
129129
130130 const chainParameters = useBlockChainParameters ( ) ;
131131 const microCcdPerEur = chainParameters ?. microGTUPerEuro ;
132132 const accountInfo = useAccountInfo ( credential ) ;
133133 const tokens = useAccountFungibleTokens ( credential ) ;
134+
134135 if ( accountInfo === undefined ) {
135136 return < > Loading</ > ;
136137 }
@@ -141,19 +142,14 @@ function MainPage({ credential }: MainPageProps) {
141142 < Page className = "main-page-x" >
142143 < Balance credential = { credential } />
143144 < div className = "main-page-x__action-buttons" >
144- < Button . IconTile
145- icon = { < Arrow /> }
146- label = { t ( 'receive' ) }
147- onClick = { ( ) => navToReceive ( ) }
148- className = "receive"
149- />
150- < Button . IconTile icon = { < Arrow /> } label = { t ( 'send' ) } onClick = { ( ) => navToSend ( ) } className = "send" />
151- < Button . IconTile icon = { < FileText /> } label = { t ( 'transactions' ) } onClick = { ( ) => navToTransactionLog ( ) } />
145+ < Button . IconTile icon = { < Arrow /> } label = { t ( 'receive' ) } onClick = { navToReceive } className = "receive" />
146+ < Button . IconTile icon = { < Arrow /> } label = { t ( 'send' ) } onClick = { navToSend } className = "send" />
147+ < Button . IconTile icon = { < FileText /> } label = { t ( 'transactions' ) } onClick = { navToTransactionLog } />
152148 </ div >
153149 < div className = "main-page-x__tokens" >
154150 < div className = "main-page-x__tokens-list" >
155151 < TokenItem
156- onClick = { ( ) => nav ( ` ${ absoluteRoutes . home . token . ccd . path } ` ) }
152+ onClick = { ( ) => nav ( absoluteRoutes . home . token . ccd . path ) }
157153 thumbnail = { < ConcordiumLogo /> }
158154 symbol = "CCD"
159155 staked = { isStaked }
@@ -177,11 +173,56 @@ function MainPage({ credential }: MainPageProps) {
177173 }
178174 />
179175 ) ) }
180- < Button . IconText onClick = { ( ) => navToManageToken ( ) } icon = { < Gear /> } label = { t ( 'manageTokenList' ) } />
176+ < Button . IconText onClick = { navToManageToken } icon = { < Gear /> } label = { t ( 'manageTokenList' ) } />
181177 </ div >
182178 </ div >
183179 </ Page >
184180 ) ;
185181}
186182
183+ function MainPagePendingAccount ( ) {
184+ const { t } = useTranslation ( 'x' , { keyPrefix : 'mainPage' } ) ;
185+ const nav = useNavigate ( ) ;
186+ return (
187+ < Page className = "main-page-x" >
188+ < div className = "main-page-x__balance" >
189+ < Text . HeadingLarge > { t ( 'pendingAccount' ) } </ Text . HeadingLarge >
190+ < Text . Capture > { t ( 'pendingSubText' ) } </ Text . Capture >
191+ </ div >
192+ < div className = "main-page-x__action-buttons" >
193+ < Button . IconTile icon = { < Arrow /> } label = { t ( 'receive' ) } disabled className = "receive" />
194+ < Button . IconTile icon = { < Arrow /> } label = { t ( 'send' ) } disabled className = "send" />
195+ < Button . IconTile icon = { < FileText /> } label = { t ( 'transactions' ) } disabled />
196+ </ div >
197+ < div className = "main-page-x__tokens" >
198+ < div className = "main-page-x__tokens-list" >
199+ < TokenItem
200+ onClick = { ( ) => nav ( absoluteRoutes . home . token . ccd . path ) }
201+ thumbnail = { < ConcordiumLogo /> }
202+ symbol = "CCD"
203+ balance = { displayAsCcd ( 0n , false ) }
204+ balanceBase = { 0n }
205+ />
206+ < Button . IconText disabled icon = { < Gear /> } label = { t ( 'manageTokenList' ) } />
207+ </ div >
208+ </ div >
209+ </ Page >
210+ ) ;
211+ }
212+
213+ type MainPageProps = { credential : WalletCredential } ;
214+
215+ function MainPage ( { credential } : MainPageProps ) {
216+ switch ( credential . status ) {
217+ case CreationStatus . Confirmed :
218+ return < MainPageConfirmedAccount credential = { credential } /> ;
219+ case CreationStatus . Pending :
220+ return < MainPagePendingAccount /> ;
221+ case CreationStatus . Rejected :
222+ return < > Account Creation was rejected</ > ;
223+ default :
224+ throw new Error ( `Unexpected status for credential: ${ credential . status } ` ) ;
225+ }
226+ }
227+
187228export default withSelectedCredential ( MainPage ) ;
0 commit comments