Skip to content

Commit 90e5d2d

Browse files
committed
refactor(adminjoinview.vue): optimize commitBy display
1 parent 859fcf0 commit 90e5d2d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/views/AdminJoinView.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
</button>
8080
</div>
8181
<p v-else class="mt-2 text-amber-600">
82-
已由 {{ application.commitBy }} 於 {{ dateParsedApprovalAt }} 簽署 {{ application.commitState ? '許可' : '否決' }}
82+
已由 {{ commitBy }} 於 {{ dateParsedCommitAt }} 簽署 {{ application.commitState ? '許可' : '否決' }}
8383
</p>
8484
</div>
8585
</div>
@@ -105,13 +105,21 @@ export default {
105105
ready: false,
106106
query: null,
107107
status: null,
108+
commitBy: null,
108109
application: {}
109110
}),
110111
methods: {
111112
dateToHuman(timestamp) {
112113
const userTimezone = dayjs.tz.guess();
113114
return dayjs.tz(timestamp, userTimezone).format("llll");
114115
},
116+
async getUserNickname(commitBy) {
117+
const xhr = await this.$axios.get(`https://web-tech.tw/recv/sara/users/${commitBy}`);
118+
if (xhr.status !== 200) {
119+
return commitBy;
120+
}
121+
return xhr?.data?.profile?.nickname || commitBy;
122+
},
115123
async submit() {
116124
this.status = '';
117125
if (!this.query) {
@@ -122,6 +130,11 @@ export default {
122130
try {
123131
const xhr = await this.$axios.get("applications", options);
124132
this.application = xhr.data;
133+
const {commitBy} = this.application;
134+
if (commitBy) {
135+
this.commitBy = await this.getUserNickname(commitBy);
136+
return;
137+
}
125138
this.status = "";
126139
} catch (e) {
127140
this.application = {};
@@ -172,7 +185,7 @@ export default {
172185
createdAt,
173186
);
174187
},
175-
dateParsedApprovalAt() {
188+
dateParsedCommitAt() {
176189
const {
177190
commitAt,
178191
} = this.application;

0 commit comments

Comments
 (0)