persist installed. MyAccount in progress
This commit is contained in:
@@ -25,6 +25,7 @@ interface EditDetail {
|
||||
}
|
||||
|
||||
export default defineStore('acctMgmtStore', {
|
||||
persist: true,
|
||||
state: () => ({
|
||||
allUserAccoutList: [] as User[],
|
||||
isAcctMenuOpen: false,
|
||||
@@ -181,6 +182,37 @@ export default defineStore('acctMgmtStore', {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
async editAccountName(userToEdit: string, newName: string): Promise<boolean> {
|
||||
const apiEdit = `/api/users/${userToEdit}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.put(apiEdit, {
|
||||
username: userToEdit,
|
||||
name: newName,
|
||||
is_active: this.currentViewingUser.is_active,
|
||||
});
|
||||
return response.status === 200;
|
||||
} catch (error) {
|
||||
apiError(error, 'Failed to edit name of account.');
|
||||
return false;
|
||||
}
|
||||
},
|
||||
async editAccountPwd(userToEdit: string, newPwd: string): Promise<boolean> {
|
||||
const apiEdit = `/api/users/${userToEdit}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.put(apiEdit, {
|
||||
username: userToEdit,
|
||||
name: this.currentViewingUser.name,
|
||||
password: newPwd,
|
||||
is_active: this.currentViewingUser.is_active,
|
||||
});
|
||||
return response.status === 200;
|
||||
} catch (error) {
|
||||
apiError(error, 'Failed to edit password of account.');
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/** Add a role to the user in database.
|
||||
* @param {string} usernameToEdit
|
||||
* @param {string} roleCode
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createPinia } from 'pinia';
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||
|
||||
const pinia = createPinia();
|
||||
pinia.use(piniaPluginPersistedstate);
|
||||
|
||||
export default pinia;
|
||||
|
||||
Reference in New Issue
Block a user