#334 fixed v-if=isAdmin

This commit is contained in:
Cindy Chang
2024-08-07 16:29:15 +08:00
parent caa1b9cc70
commit 8fa1a7b8b3
3 changed files with 39 additions and 20 deletions

View File

@@ -28,7 +28,7 @@ export default defineStore('acctMgmtStore', {
isAcctMenuOpen: false,
currentViewingUser: {
username: '',
detail: {} as EditDetail,
detail: {},
} as User,
response: {
deleteAccount: null,
@@ -42,13 +42,13 @@ export default defineStore('acctMgmtStore', {
/**
* Set related boolean to true
*/
openAcctMenu(){
openAcctMenu() {
this.isAcctMenuOpen = true;
},
/**
* Set related boolean to false
*/
closeAcctMenu(){
closeAcctMenu() {
this.isAcctMenuOpen = false;
},
toggleIsAcctMenuOpen() {
@@ -59,8 +59,7 @@ export default defineStore('acctMgmtStore', {
* @param {string} username
*/
setCurrentViewingUser(username: string) {
const userFind:User|undefined = this.allUserAccoutList.find(user => user.username === username);
console.log('userFind', userFind);
const userFind: User | undefined = this.allUserAccoutList.find(user => user.username === username);
this.currentViewingUser = userFind || { username: '', detail: {} };
},
/**
@@ -88,7 +87,7 @@ export default defineStore('acctMgmtStore', {
const response = await this.$axios.get(apiGetUserList);
const customizedResponseData = await this.customizeAllUserList(response.data);
this.allUserAccoutList = customizedResponseData;
} catch(error) {
} catch (error) {
apiError(error, 'Failed to get all users.');
}
},
@@ -120,11 +119,11 @@ export default defineStore('acctMgmtStore', {
try {
const response = await this.$axios.post(apiCreateAccount, userToCreate);
if (response.status === 200) {
this.isOneAccountJustCreate = true;
this.isOneAccountJustCreate = true;
this.justCreateUsername = userToCreate.username;
setTimeout(this.resetJustCreateFlag, JUST_CREATE_ACCOUNT_HOT_DURATION_MINS * 1000 * 60);
setTimeout(this.resetJustCreateFlag, JUST_CREATE_ACCOUNT_HOT_DURATION_MINS * 1000 * 60);
}
} catch(error) {
} catch (error) {
apiError(error, 'Failed to add a new account.');
}
},
@@ -139,7 +138,7 @@ export default defineStore('acctMgmtStore', {
try {
const response = await this.$axios.delete(apiDelete);
return response.status === 200;
} catch(error) {
} catch (error) {
apiError(error, 'Failed to delete the account.');
return false;
}
@@ -160,7 +159,7 @@ export default defineStore('acctMgmtStore', {
is_active: editDetail.is_active,
});
return response.status === 200;
} catch(error) {
} catch (error) {
apiError(error, 'Failed to edit the account.');
return false;
}
@@ -175,7 +174,7 @@ export default defineStore('acctMgmtStore', {
try {
const response = await this.$axios.put(apiAddRole);
return response.status === 200;
} catch(error) {
} catch (error) {
apiError(error, 'Failed to add role to the account.');
return false;
}
@@ -190,7 +189,7 @@ export default defineStore('acctMgmtStore', {
try {
const response = await this.$axios.delete(apiDeleteRole);
return response.status === 200;
} catch(error) {
} catch (error) {
apiError(error, 'Failed to delete a role frome the account.');
return false;
}
@@ -209,7 +208,7 @@ export default defineStore('acctMgmtStore', {
detail: response.data,
};
return response.status === 200;
} catch(error) {
} catch (error) {
//不需要跳出錯誤,因為如果是錯誤反而是好事,表示帳號是獨一的
return false;
}
@@ -261,7 +260,7 @@ export default defineStore('acctMgmtStore', {
/**
* Reset isOneAccountJustCreate to false, causing the badge to disappear.
*/
resetJustCreateFlag(){
resetJustCreateFlag() {
this.isOneAccountJustCreate = false;
},
/** Set the value of shouldUpdateList variable.