Compare commits
1 commit
eb4f8f7e53
...
b697199a8b
| Author | SHA1 | Date | |
|---|---|---|---|
| b697199a8b |
2 changed files with 1 additions and 20 deletions
|
|
@ -17,14 +17,9 @@ const expensesAPI = injectService<ExpensesAPI>(SERVICE_TOKENS.EXPENSES_API)
|
||||||
|
|
||||||
const balance = ref<number | null>(null)
|
const balance = ref<number | null>(null)
|
||||||
const balanceCurrency = ref<string>('sats')
|
const balanceCurrency = ref<string>('sats')
|
||||||
const fiatBalances = ref<Record<string, number>>({})
|
|
||||||
const pendingTransactions = ref<Transaction[]>([])
|
const pendingTransactions = ref<Transaction[]>([])
|
||||||
const isLoading = ref(true)
|
const isLoading = ref(true)
|
||||||
|
|
||||||
const fiatBalanceEntries = computed(() =>
|
|
||||||
Object.entries(fiatBalances.value).filter(([, amount]) => Math.abs(amount) > 0.005)
|
|
||||||
)
|
|
||||||
|
|
||||||
const walletKey = computed(() => user.value?.wallets?.[0]?.inkey)
|
const walletKey = computed(() => user.value?.wallets?.[0]?.inkey)
|
||||||
const budgetsEnabled = computed(() => import.meta.env.VITE_LIBRA_BUDGETS_ENABLED === 'true')
|
const budgetsEnabled = computed(() => import.meta.env.VITE_LIBRA_BUDGETS_ENABLED === 'true')
|
||||||
|
|
||||||
|
|
@ -60,7 +55,6 @@ async function loadData() {
|
||||||
|
|
||||||
balance.value = balanceData.balance
|
balance.value = balanceData.balance
|
||||||
balanceCurrency.value = balanceData.currency || 'sats'
|
balanceCurrency.value = balanceData.currency || 'sats'
|
||||||
fiatBalances.value = balanceData.fiat_balances || {}
|
|
||||||
|
|
||||||
// Filter for pending transactions (flag = '!')
|
// Filter for pending transactions (flag = '!')
|
||||||
pendingTransactions.value = txData.entries.filter(tx => tx.flag === '!')
|
pendingTransactions.value = txData.entries.filter(tx => tx.flag === '!')
|
||||||
|
|
@ -118,15 +112,6 @@ function formatFiat(amount: number, currency: string): string {
|
||||||
</span>
|
</span>
|
||||||
<span class="text-lg text-muted-foreground">{{ balanceCurrency }}</span>
|
<span class="text-lg text-muted-foreground">{{ balanceCurrency }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="fiatBalanceEntries.length > 0" class="flex flex-wrap items-center gap-x-3 gap-y-1 pl-7">
|
|
||||||
<span
|
|
||||||
v-for="[currency, amount] in fiatBalanceEntries"
|
|
||||||
:key="currency"
|
|
||||||
class="text-base text-muted-foreground"
|
|
||||||
>
|
|
||||||
{{ formatFiat(Math.abs(amount), currency) }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p class="text-sm" :class="libraOwesUser ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'">
|
<p class="text-sm" :class="libraOwesUser ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'">
|
||||||
{{ libraOwesUser ? t('libra.balance.owedToYou') : t('libra.balance.youOwe') }}
|
{{ libraOwesUser ? t('libra.balance.owedToYou') : t('libra.balance.youOwe') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -245,11 +245,7 @@ export class ExpensesAPI extends BaseService {
|
||||||
/**
|
/**
|
||||||
* Get user's balance with libra
|
* Get user's balance with libra
|
||||||
*/
|
*/
|
||||||
async getUserBalance(walletKey: string): Promise<{
|
async getUserBalance(walletKey: string): Promise<{ balance: number; currency: string }> {
|
||||||
balance: number
|
|
||||||
currency: string
|
|
||||||
fiat_balances?: Record<string, number>
|
|
||||||
}> {
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${this.baseUrl}/libra/api/v1/balance`, {
|
const response = await fetch(`${this.baseUrl}/libra/api/v1/balance`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue