diff --git a/web-app/src/components/collapse/CollapseActive.vue b/web-app/src/components/collapse/CollapseActive.vue index 9e7cbd6..db8e27a 100644 --- a/web-app/src/components/collapse/CollapseActive.vue +++ b/web-app/src/components/collapse/CollapseActive.vue @@ -35,7 +35,11 @@
-
+
+ {{ error }} + Retry +
+
Tax Paid
{{ taxPaidGes ?? '...' }} $KRK
@@ -46,7 +50,7 @@
Total
-
{{ total.toFixed(5) }} $KRK
+
{{ taxPaidGes !== undefined && profit !== undefined ? total.toFixed(5) : '...' }} $KRK
@@ -117,6 +121,7 @@ const taxDue = ref(0n); const taxPaidGes = ref(); const profit = ref(); const loading = ref(false); +const error = ref(null); const tag = computed(() => { // Compare by index instead of decimal to avoid floating-point issues @@ -214,14 +219,24 @@ async function unstakePosition() { } async function loadActivePositionData() { - //loadTaxDue - taxDue.value = await getTaxDue(props.id); - taxPaidGes.value = weiToNumber(taxDue.value + props.position.taxPaid); + loading.value = true; + error.value = null; + try { + //loadTaxDue + taxDue.value = await getTaxDue(props.id); + taxPaidGes.value = weiToNumber(taxDue.value + props.position.taxPaid); - //loadTotalSupply + //loadTotalSupply - // Calculate issuance earned using kraiken-lib profit calculation - profit.value = calculateActivePositionProfit(props.position.totalSupplyInit, statCollection.kraikenTotalSupply, props.position.share); + // Calculate issuance earned using kraiken-lib profit calculation + profit.value = calculateActivePositionProfit(props.position.totalSupplyInit, statCollection.kraikenTotalSupply, props.position.share); + } catch (err) { + // eslint-disable-next-line no-console + console.error('Failed to load active position data:', err); + error.value = 'Failed to load position data.'; + } finally { + loading.value = false; + } } onMounted(() => { @@ -317,6 +332,14 @@ onMounted(() => { &.profit-stats-total border-top: 2px solid var(--color-font) padding-top: 2px + .collapsed-body--error + display: flex + flex-wrap: wrap + align-items: center + gap: 8px + color: #f87171 + font-size: 13px + margin-bottom: 8px .collapsed-body--actions .collapse-menu-open display: flex