diff --git a/src/composables/useHasAccount.js b/src/composables/useHasAccount.js
new file mode 100644
index 000000000..1014bedf3
--- /dev/null
+++ b/src/composables/useHasAccount.js
@@ -0,0 +1,6 @@
+import axios from 'axios';
+
+export default async (id) => {
+ const { data } = await axios.get(`Accounts/${id}/exists`);
+ return data.exists;
+};
diff --git a/src/pages/Account/Card/AccountDescriptor.vue b/src/pages/Account/Card/AccountDescriptor.vue
index 3156f8e1e..e96b4e0c5 100644
--- a/src/pages/Account/Card/AccountDescriptor.vue
+++ b/src/pages/Account/Card/AccountDescriptor.vue
@@ -1,13 +1,13 @@
- (hasAccount = data.exists)"
- />
-
+
@@ -91,7 +90,7 @@ const hasAccount = ref(false);
import axios from 'axios';
-import { computed, ref, toRefs } from 'vue';
+import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useVnConfirm } from 'composables/useVnConfirm';
-import { useRoute } from 'vue-router';
import { useAcl } from 'src/composables/useAcl';
import { useArrayData } from 'src/composables/useArrayData';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
import useNotify from 'src/composables/useNotify.js';
+import useHasAccount from 'src/composables/useHasAccount.js';
const $props = defineProps({
- hasAccount: {
- type: Boolean,
- default: false,
+ entityId: {
+ type: Number,
required: true,
},
});
+
const { t } = useI18n();
-const { hasAccount } = toRefs($props);
const { openConfirmationModal } = useVnConfirm();
-const route = useRoute();
const { notify } = useNotify();
const account = computed(() => useArrayData('AccountId').store.data[0]);
-account.value.hasAccount = hasAccount.value;
-const entityId = computed(() => +route.params.id);
+
+onMounted(async () => {
+ account.value.hasAccount = await useHasAccount($props.entityId);
+});
async function updateStatusAccount(active) {
if (active) {
- await axios.post(`Accounts`, { id: entityId.value });
+ await axios.post(`Accounts`, { id: $props.entityId });
} else {
- await axios.delete(`Accounts/${entityId.value}`);
+ await axios.delete(`Accounts/${$props.entityId}`);
}
account.value.hasAccount = active;
@@ -41,7 +41,7 @@ async function updateStatusAccount(active) {
});
}
async function updateStatusUser(active) {
- await axios.patch(`VnUsers/${entityId.value}`, { active });
+ await axios.patch(`VnUsers/${$props.entityId}`, { active });
account.value.active = active;
const status = active ? 'activate' : 'deactivate';
notify({
diff --git a/src/pages/Account/Card/AccountMailAlias.vue b/src/pages/Account/Card/AccountMailAlias.vue
index 8d3bd3b67..efd2b481b 100644
--- a/src/pages/Account/Card/AccountMailAlias.vue
+++ b/src/pages/Account/Card/AccountMailAlias.vue
@@ -9,6 +9,7 @@ import AccountMailAliasCreateForm from './AccountMailAliasCreateForm.vue';
import { useVnConfirm } from 'composables/useVnConfirm';
import { useArrayData } from 'composables/useArrayData';
import useNotify from 'src/composables/useNotify.js';
+import useHasAccount from 'src/composables/useHasAccount.js';
import axios from 'axios';
const { t } = useI18n();
@@ -50,16 +51,6 @@ const columns = computed(() => [
},
]);
-const fetchAccountExistence = async () => {
- try {
- const { data } = await axios.get(`Accounts/${route.params.id}/exists`);
- return data.exists;
- } catch (error) {
- console.error('Error fetching account existence', error);
- return false;
- }
-};
-
const deleteMailAlias = async (row) => {
await axios.delete(`${urlPath}/${row.id}`);
fetchMailAliases();
@@ -79,7 +70,7 @@ const fetchMailAliases = async () => {
const getAccountData = async (reload = true) => {
loading.value = true;
- hasAccount.value = await fetchAccountExistence();
+ hasAccount.value = await useHasAccount(route.params.id);
if (!hasAccount.value) {
loading.value = false;
store.data = [];
diff --git a/src/pages/Account/Card/AccountMailForwarding.vue b/src/pages/Account/Card/AccountMailForwarding.vue
index aa92e5072..0e5ae3122 100644
--- a/src/pages/Account/Card/AccountMailForwarding.vue
+++ b/src/pages/Account/Card/AccountMailForwarding.vue
@@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue';
import axios from 'axios';
import { useStateStore } from 'stores/useStateStore';
import useNotify from 'src/composables/useNotify.js';
+import useHasAccount from 'src/composables/useHasAccount';
const { t } = useI18n();
const route = useRoute();
@@ -30,16 +31,6 @@ const hasDataChanged = computed(
initialData.value.hasData !== hasData.value
);
-const fetchAccountExistence = async () => {
- try {
- const { data } = await axios.get(`Accounts/${route.params.id}/exists`);
- return data.exists;
- } catch (error) {
- console.error('Error fetching account existence', error);
- return false;
- }
-};
-
const fetchMailForwards = async () => {
const response = await axios.get(`MailForwards/${route.params.id}`);
return response.data;
@@ -68,7 +59,7 @@ const setInitialData = async () => {
loading.value = true;
initialData.value.account = route.params.id;
formData.value.account = route.params.id;
- hasAccount.value = await fetchAccountExistence(route.params.id);
+ hasAccount.value = await useHasAccount(route.params.id);
if (!hasAccount.value) {
loading.value = false;
return;
diff --git a/src/pages/Account/Card/AccountSummary.vue b/src/pages/Account/Card/AccountSummary.vue
index 5a21e18a5..ca17c7975 100644
--- a/src/pages/Account/Card/AccountSummary.vue
+++ b/src/pages/Account/Card/AccountSummary.vue
@@ -7,6 +7,7 @@ import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import { useArrayData } from 'src/composables/useArrayData';
+import AccountDescriptorMenu from './AccountDescriptorMenu.vue';
const route = useRoute();
const { t } = useI18n();
@@ -30,13 +31,15 @@ const filter = {
(account = data)"
>
{{ account.id }} - {{ account.nickname }}
+
+
+