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 { formatValue, playSound, showConfetti } from '$lib/utils';
|
||||||
import { volumeSettings } from '$lib/stores/volume-settings';
|
import { volumeSettings } from '$lib/stores/volume-settings';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { fetchPortfolioSummary } from '$lib/stores/portfolio-data';
|
||||||
|
|
||||||
interface CoinflipResult {
|
interface CoinflipResult {
|
||||||
won: boolean;
|
won: boolean;
|
||||||
|
|
@ -318,13 +319,11 @@
|
||||||
volumeSettings.load();
|
volumeSettings.load();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/portfolio/summary');
|
const data = await fetchPortfolioSummary();
|
||||||
if (!response.ok) {
|
if (data) {
|
||||||
throw new Error('Failed to fetch portfolio summary');
|
balance = data.baseCurrencyBalance;
|
||||||
|
onBalanceUpdate?.(data.baseCurrencyBalance);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
|
||||||
balance = data.baseCurrencyBalance;
|
|
||||||
onBalanceUpdate?.(data.baseCurrencyBalance);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch balance:', error);
|
console.error('Failed to fetch balance:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
import { formatValue, playSound, showConfetti, showSchoolPrideCannons } from '$lib/utils';
|
import { formatValue, playSound, showConfetti, showSchoolPrideCannons } from '$lib/utils';
|
||||||
import { volumeSettings } from '$lib/stores/volume-settings';
|
import { volumeSettings } from '$lib/stores/volume-settings';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { fetchPortfolioSummary } from '$lib/stores/portfolio-data';
|
||||||
|
|
||||||
interface DiceResult {
|
interface DiceResult {
|
||||||
won: boolean;
|
won: boolean;
|
||||||
|
|
@ -228,13 +229,11 @@
|
||||||
volumeSettings.load();
|
volumeSettings.load();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/portfolio/summary');
|
const data = await fetchPortfolioSummary();
|
||||||
if (!response.ok) {
|
if (data) {
|
||||||
throw new Error('Failed to fetch portfolio summary');
|
balance = data.baseCurrencyBalance;
|
||||||
|
onBalanceUpdate?.(data.baseCurrencyBalance);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
|
||||||
balance = data.baseCurrencyBalance;
|
|
||||||
onBalanceUpdate?.(data.baseCurrencyBalance);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch balance:', error);
|
console.error('Failed to fetch balance:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import { ModeWatcher } from 'mode-watcher';
|
import { ModeWatcher } from 'mode-watcher';
|
||||||
import { Info } from 'lucide-svelte';
|
import { Info } from 'lucide-svelte';
|
||||||
|
import { fetchPortfolioSummary } from '$lib/stores/portfolio-data';
|
||||||
|
|
||||||
interface MinesResult {
|
interface MinesResult {
|
||||||
won: boolean;
|
won: boolean;
|
||||||
|
|
@ -285,13 +286,11 @@
|
||||||
volumeSettings.load();
|
volumeSettings.load();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/portfolio/summary');
|
const data = await fetchPortfolioSummary();
|
||||||
if (!response.ok) {
|
if (data) {
|
||||||
throw new Error('Failed to fetch portfolio summary');
|
balance = data.baseCurrencyBalance;
|
||||||
|
onBalanceUpdate?.(data.baseCurrencyBalance);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
|
||||||
balance = data.baseCurrencyBalance;
|
|
||||||
onBalanceUpdate?.(data.baseCurrencyBalance);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch balance:', error);
|
console.error('Failed to fetch balance:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
import { formatValue, playSound, showConfetti, showSchoolPrideCannons } from '$lib/utils';
|
import { formatValue, playSound, showConfetti, showSchoolPrideCannons } from '$lib/utils';
|
||||||
import { volumeSettings } from '$lib/stores/volume-settings';
|
import { volumeSettings } from '$lib/stores/volume-settings';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { fetchPortfolioSummary } from '$lib/stores/portfolio-data';
|
||||||
|
|
||||||
interface SlotsResult {
|
interface SlotsResult {
|
||||||
won: boolean;
|
won: boolean;
|
||||||
|
|
@ -216,13 +217,11 @@
|
||||||
volumeSettings.load();
|
volumeSettings.load();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/portfolio/summary');
|
const data = await fetchPortfolioSummary();
|
||||||
if (!response.ok) {
|
if (data) {
|
||||||
throw new Error('Failed to fetch portfolio summary');
|
balance = data.baseCurrencyBalance;
|
||||||
|
onBalanceUpdate?.(data.baseCurrencyBalance);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
|
||||||
balance = data.baseCurrencyBalance;
|
|
||||||
onBalanceUpdate?.(data.baseCurrencyBalance);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to fetch balance:', error);
|
console.error('Failed to fetch balance:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue