use existing function for fetching portfolio
This commit is contained in:
parent
789fc7cc69
commit
df10f0c7ba
4 changed files with 24 additions and 28 deletions
|
|
@ -164,6 +164,7 @@
|
|||
import { formatValue, playSound, showConfetti } from '$lib/utils';
|
||||
import { volumeSettings } from '$lib/stores/volume-settings';
|
||||
import { onMount } from 'svelte';
|
||||
import { fetchPortfolioSummary } from '$lib/stores/portfolio-data';
|
||||
|
||||
interface CoinflipResult {
|
||||
won: boolean;
|
||||
|
|
@ -316,15 +317,13 @@
|
|||
|
||||
onMount(async () => {
|
||||
volumeSettings.load();
|
||||
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/portfolio/summary');
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch portfolio summary');
|
||||
const data = await fetchPortfolioSummary();
|
||||
if (data) {
|
||||
balance = data.baseCurrencyBalance;
|
||||
onBalanceUpdate?.(data.baseCurrencyBalance);
|
||||
}
|
||||
const data = await response.json();
|
||||
balance = data.baseCurrencyBalance;
|
||||
onBalanceUpdate?.(data.baseCurrencyBalance);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch balance:', error);
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue