responsive name

This commit is contained in:
Cindy Chang
2024-08-29 14:41:41 +08:00
parent 1883818b8b
commit 3a44b74bbc
3 changed files with 8 additions and 20 deletions

View File

@@ -190,6 +190,7 @@ export default defineStore('acctMgmtStore', {
username: userToEdit,
name: newName,
is_active: this.currentViewingUser.is_active,
is_admin: this.currentViewingUser.is_admin,
});
return response.status === 200;
} catch (error) {
@@ -206,6 +207,7 @@ export default defineStore('acctMgmtStore', {
name: this.currentViewingUser.name,
password: newPwd,
is_active: this.currentViewingUser.is_active,
is_admin: this.currentViewingUser.is_admin,
});
return response.status === 200;
} catch (error) {
@@ -249,13 +251,10 @@ export default defineStore('acctMgmtStore', {
*/
async getUserDetail(uniqueUsername: string): Promise<boolean> {
const apiUserDetail = `/api/users/${uniqueUsername}`;
try {
const response = await this.$axios.get(apiUserDetail);
this.currentViewingUser = {
...this.currentViewingUser,
detail: response.data,
};
this.currentViewingUser = response.data;
this.currentViewingUser.is_admin = response.data.roles.some(role => role.code === 'admin');
return response.status === 200;
} catch (error) {
//不需要跳出錯誤,因為如果是錯誤反而是好事,表示帳號是獨一的