update single account pinia state

This commit is contained in:
Cindy Chang
2024-06-27 11:39:44 +08:00
parent 21fb6f616a
commit 3fe427fcc3
2 changed files with 16 additions and 4 deletions

View File

@@ -225,5 +225,16 @@ export default defineStore('acctMgmtStore', {
setShouldUpdateList(shouldUpdateBoolean) {
this.shouldUpdateList = shouldUpdateBoolean;
},
/** Only update one single account in the pinia state.
* @param {object} userDataToReplace
*/
updateSingleAccountPiniaState(userDataToReplace){
const userIndex = this.allUserAccoutList.findIndex(user => user.username === userDataToReplace.username);
if (userIndex !== -1) {
this.allUserAccoutList[userIndex] = { ...this.allUserAccoutList[userIndex], ...userDataToReplace };
} else {
// Error handling here.
}
}
},
})