Skip to content

Commit 759c0af

Browse files
committed
Update package lock, fix config path, add loading balance state, create formatted computed prop
1 parent 01cae2e commit 759c0af

4 files changed

Lines changed: 52 additions & 7 deletions

File tree

backend/notification-config-example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"email_templates_dir_path": "../internal/mailservice/templates/notifications",
2+
"email_templates_dir_path": "./internal/mailservice/templates/notifications",
33
"template_types": {
44
"deployment": {
55
"default": {

frontend/kubecloud/package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/kubecloud/src/components/dashboard/ProfileCard.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
<div class="profile-row">
2020
<div class="profile-col">
2121
<label class="profile-label">Balance</label>
22-
<v-text-field :model-value="`$${userStore.netBalance.toFixed(2)}${userStore.pendingBalance > 0 ? ` (+$${userStore.pendingBalance.toFixed(2)} pending)` : ''}`" variant="outlined" class="profile-field compact" color="accent" bg-color="transparent" hide-details="auto" disabled density="compact" />
22+
<v-text-field
23+
:model-value="formattedBalance"
24+
variant="outlined"
25+
class="profile-field compact"
26+
color="accent"
27+
bg-color="transparent"
28+
hide-details="auto"
29+
disabled
30+
density="compact"
31+
/>
2332
</div>
2433
<div class="profile-col">
2534
<label class="profile-label">Verified</label>
@@ -85,13 +94,21 @@
8594
</template>
8695

8796
<script setup lang="ts">
88-
import { ref, watch } from 'vue'
97+
import { ref, watch, computed } from 'vue'
8998
import { storeToRefs } from 'pinia'
9099
import { useUserStore } from '../../stores/user'
91100
import { authService } from '../../utils/authService'
92101
93-
const { user } = storeToRefs(useUserStore())
94102
const userStore = useUserStore()
103+
const { user, netBalance, pendingBalance, isBalanceLoading } = storeToRefs(userStore)
104+
105+
const formattedBalance = computed(() => {
106+
if (isBalanceLoading.value) return 'Loading...'
107+
const balance = netBalance.value || 0
108+
const pending = pendingBalance.value || 0
109+
const base = `$${balance.toFixed(2)}`
110+
return pending > 0 ? `${base} (+$${pending.toFixed(2)} pending)` : base
111+
})
95112
96113
// Change password form data
97114
const passwordFormData = ref({

frontend/kubecloud/src/stores/user.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const useUserStore = defineStore('user',
3737
const error = ref<string | null>(null)
3838
const netBalance = ref(0)
3939
const pendingBalance = ref(0)
40+
const isBalanceLoading = ref(true)
4041
const balanceInterval = ref<ReturnType<typeof setInterval> | null>(null)
4142

4243
// Computed properties
@@ -84,6 +85,7 @@ export const useUserStore = defineStore('user',
8485
user.value = null
8586
token.value = null
8687
error.value = null
88+
isBalanceLoading.value = true
8789
// Clear localStorage
8890
authService.clearTokens()
8991
// Clear notifications and related ephemeral state
@@ -177,9 +179,14 @@ export const useUserStore = defineStore('user',
177179
}
178180

179181
const updateNetBalance = async () => {
180-
const balance = await userService.fetchBalance()
181-
netBalance.value = balance.balance
182-
pendingBalance.value = balance.pending_balance
182+
isBalanceLoading.value = true
183+
try {
184+
const balance = await userService.fetchBalance()
185+
netBalance.value = balance.balance
186+
pendingBalance.value = balance.pending_balance
187+
} finally {
188+
isBalanceLoading.value = false
189+
}
183190
}
184191

185192
return {
@@ -190,6 +197,7 @@ export const useUserStore = defineStore('user',
190197
error,
191198
netBalance,
192199
pendingBalance,
200+
isBalanceLoading,
193201

194202
// Computed
195203
isAdmin,

0 commit comments

Comments
 (0)