Skip to content

Commit

Permalink
fix: crash accounts if not selected output (#8204)
Browse files Browse the repository at this point in the history
* fix: crash-accounts-if-not-selected-output

* feat: add a message if there isnt info of accounts

* feat: improve emptyAccounts text

* fix: emptyAccounts text

---------

Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
cpl121 and begonaalvarezd authored Mar 19, 2024
1 parent c5a0f34 commit 0db5de7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import { AccountManagementDetails, AccountManagementList } from '@components'
import { AccountOutput, OutputData } from '@iota/sdk/out/types'
import { isAccountOutput, isImplicitAccountOutput } from '@core/wallet'
import { Text } from '@ui'
import { localize } from '@core/i18n'
$: allAccountOutputs =
$selectedWallet?.walletUnspentOutputs?.filter(
(output) => isAccountOutput(output) || isImplicitAccountOutput(output)
) || []
let selectedOutput =
$selectedWallet.walletUnspentOutputs.find(
$selectedWallet?.walletUnspentOutputs?.find(
(output) => (output.output as AccountOutput)?.accountId === $selectedWallet.mainAccountId
) || allAccountOutputs?.[0]
Expand All @@ -29,18 +31,24 @@
class="w-full h-full flex flex-nowrap p-8 relative flex-1 bg-gray-50 dark:bg-gray-900 space-x-4 justify-center"
>
<div class="flex space-x-4 max-w-7xl justify-center w-full">
{#key $selectedWallet?.id}
{#if features.accountManagement.accountList.enabled}
<AccountManagementList
onAccountClick={handleAccountClick}
allOutputs={allAccountOutputs}
{selectedOutput}
/>
{/if}
{#if features.accountManagement.accountDetails.enabled}
<AccountManagementDetails {selectedOutput} index={setAccountOutputIndex(selectedOutput)} />
{/if}
{/key}
{#if selectedOutput}
{#key $selectedWallet?.id}
{#if features.accountManagement.accountList.enabled}
<AccountManagementList
onAccountClick={handleAccountClick}
allOutputs={allAccountOutputs}
{selectedOutput}
/>
{/if}
{#if features.accountManagement.accountDetails.enabled}
<AccountManagementDetails {selectedOutput} index={setAccountOutputIndex(selectedOutput)} />
{/if}
{/key}
{:else}
<div class="flex flex-col w-full h-full justify-center items-center">
<Text secondary>{localize('views.accountManagement.emptyAccounts')}</Text>
</div>
{/if}
</div>
</account-management-container>
{/if}
3 changes: 2 additions & 1 deletion packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@
"unsetAsPrimary": "Unset as primary"
}
},
"notification": "Activate one account to access the dashboard."
"notification": "Activate one account to access the dashboard.",
"emptyAccounts": "There are no accounts to show, activate one first."
},
"delegation": {
"title": "Delegation",
Expand Down

0 comments on commit 0db5de7

Please sign in to comment.