delete account and later on modal closing effect.

This commit is contained in:
Cindy Chang
2024-06-24 10:09:39 +08:00
parent b55cc0a6d6
commit 00d086ff1d
7 changed files with 51 additions and 11 deletions

View File

@@ -219,6 +219,7 @@ export default {
};
const onDeleteBtnClick = (usernameToDelete) => {
acctMgmtStore.setCurrentViewingUser(usernameToDelete);
modalStore.openModal(MODAL_DELETE);
};

View File

@@ -199,13 +199,6 @@ export default defineComponent({
}
//TODO: 這邊要記得回來加一個判斷帳號是否已經存在的邏輯
checkAccountIsUnique();
console.log('input content to feed in',
inputUserAccount.value,
inputPwd.value,
inputName.value,
isSetAsAdminChecked.value,
isSetActivedChecked.value,
);
await acctMgmtStore.createNewAccount({
username: inputUserAccount.value,
password: inputPwd.value,

View File

@@ -18,7 +18,9 @@
{{ i18next.t("No") }}
</button>
<button id="sure_to_delete_acct_btn" class="flex justify-center items-center rounded-full cursor-pointer w-[100px] h-[40px]
border-2 border-[#FF3366] text-[#FF3366]">
border-2 border-[#FF3366] text-[#FF3366]"
@click="onDeleteConfirmBtnClick"
>
{{ i18next.t("Yes") }}
</button>
</footer>
@@ -28,13 +30,25 @@
<script>
import { defineComponent, ref, computed, onBeforeMount, watch, } from 'vue';
import { useModalStore } from '@/stores/modal.js';
import { useRouter } from 'vue-router';
import useAcctMgmtStore from '@/stores/acctMgmt.js';
import i18next from '@/i18n/i18n.js';
import { useToast } from 'vue-toast-notification';
export default defineComponent({
setup() {
const acctMgmtStore = useAcctMgmtStore();
const modalStore = useModalStore();
const toast = useToast();
const router = useRouter();
const onDeleteConfirmBtnClick = async() => {
if(acctMgmtStore.deleteAccount(acctMgmtStore.currentViewingUser.username)){
toast.success(i18next.t("AcctMgmt.MsgAccountDeleteSuccess"));
modalStore.closeModal();
router.push("/account/account-admin");
}
}
const onNoBtnClick = () => {
modalStore.closeModal();
@@ -42,6 +56,7 @@ export default defineComponent({
return {
i18next,
onDeleteConfirmBtnClick,
onNoBtnClick,
};
},