delete account and later on modal closing effect.
This commit is contained in:
@@ -7,7 +7,10 @@ export default defineStore('acctMgmtStore', {
|
||||
isAcctMenuOpen: false,
|
||||
currentViewingUser: {
|
||||
detail: null,
|
||||
}
|
||||
},
|
||||
response: {
|
||||
deleteAccount: null,
|
||||
},
|
||||
}),
|
||||
getters: {
|
||||
},
|
||||
@@ -92,6 +95,26 @@ export default defineStore('acctMgmtStore', {
|
||||
apiError(error, 'Failed to add a new account.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Delete an account from database.
|
||||
* @param {string} userToDelete this value is unique in database.
|
||||
* @returns the result of whether the deletion is success or not.
|
||||
*/
|
||||
async deleteAccount(userToDelete) {
|
||||
const apiDelete = `/api/users/${userToDelete}`;
|
||||
|
||||
try{
|
||||
const response = await this.$axios.delete(apiDelete);
|
||||
if(response.status === 200) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch(error) {
|
||||
console.log('error', error, error.status, error.code);
|
||||
apiError(error, 'Failed to delete the account.');
|
||||
return false;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Get user detail by unique username.
|
||||
* @param {string} uniqueUsername
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { MODAL_ACCT_INFO, } from '@/constants/constants.js';
|
||||
import { delaySecond } from "@/utils/timeUtil.js";
|
||||
|
||||
export const useModalStore = defineStore('modalStore', {
|
||||
state: () => ({
|
||||
isModalOpen: false,
|
||||
@@ -10,7 +12,8 @@ export const useModalStore = defineStore('modalStore', {
|
||||
this.isModalOpen = true;
|
||||
this.whichModal = whichModal;
|
||||
},
|
||||
closeModal() {
|
||||
async closeModal(){
|
||||
await delaySecond(2);
|
||||
this.isModalOpen = false;
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user