Skip to content

Commit 5084d26

Browse files
committed
[frontend] Fix profile loading
1 parent 0e6ab48 commit 5084d26

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

frontend/src/components/profile/ProfileData.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<template>
2-
<div v-if="profile && reputation" style="display: flex; flex-direction: row; gap: 10px">
3-
<img id="avatar" fetchpriority="high" :src="profile.avatarUrl" />
2+
<div v-if="isReady" style="display: flex; flex-direction: row; gap: 10px">
3+
<img id="avatar" fetchpriority="high" :src="profile!.avatarUrl" />
44
<div style="width: 100%; display: flex; flex-direction: column">
55
<!-- Name -->
6-
<span style="font-weight: bold">Nome:</span> {{ profile.name }}
6+
<span style="font-weight: bold">Nome:</span> {{ profile!.name }}
77
<!-- Username -->
8-
<span style="font-weight: bold">Usuário:</span> {{ profile.username }}
8+
<span style="font-weight: bold">Usuário:</span> {{ profile!.username }}
99
<!-- Name -->
10-
<span style="font-weight: bold">E-mail:</span> {{ profile.email }}
10+
<span style="font-weight: bold">E-mail:</span> {{ profile!.email }}
1111
<!-- Reputation -->
1212
<span style="font-weight: bold">Reputação:</span>
13-
<n-number-animation show-separator :to="reputation" :duration="1000" />
13+
<n-number-animation show-separator :to="reputation!" :duration="1000" />
1414
</div>
1515
</div>
1616
<div v-else>
@@ -28,6 +28,7 @@
2828
<script lang="ts">
2929
import { useMessage, NSkeleton, NNumberAnimation } from 'naive-ui';
3030
import axios from 'axios';
31+
import { ref, type Ref } from 'vue';
3132
3233
import type UserProfile from '@/interface/userProfile';
3334
import type UserProfileResponse from '@/interface/response/user/userProfileResponse';
@@ -39,14 +40,15 @@ export default {
3940
},
4041
setup() {
4142
return {
42-
message: useMessage()
43+
message: useMessage(),
44+
profile: ref(null) as Ref<UserProfile | null>,
45+
reputation: ref(null) as Ref<number | null>
4346
};
4447
},
45-
data() {
46-
return {
47-
profile: null as UserProfile | null,
48-
reputation: null as number | null
49-
};
48+
computed: {
49+
isReady() {
50+
return this.profile != null && this.reputation != null;
51+
}
5052
},
5153
methods: {
5254
fetchProfile() {

0 commit comments

Comments
 (0)