diff --git a/src/components/common/FetchData.vue b/src/components/common/FetchData.vue
new file mode 100644
index 00000000..26ec77a4
--- /dev/null
+++ b/src/components/common/FetchData.vue
@@ -0,0 +1,66 @@
+
+
+
+
diff --git a/src/pages/Account/AddressList.vue b/src/pages/Account/AddressList.vue
index a603715c..4a8305e8 100644
--- a/src/pages/Account/AddressList.vue
+++ b/src/pages/Account/AddressList.vue
@@ -5,11 +5,13 @@ import { useRouter } from 'vue-router';
import CardList from 'src/components/ui/CardList.vue';
import VnList from 'src/components/ui/VnList.vue';
+import FetchData from 'src/components/common/FetchData.vue';
import useNotify from 'src/composables/useNotify.js';
import { useVnConfirm } from 'src/composables/useVnConfirm.js';
import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
+import { useUserStore } from 'stores/user';
const router = useRouter();
const jApi = inject('jApi');
@@ -17,7 +19,9 @@ const { notify } = useNotify();
const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm();
const appStore = useAppStore();
+const userStore = useUserStore();
const { isHeaderMounted } = storeToRefs(appStore);
+const fetchAddressesRef = ref(null);
const addresses = ref([]);
const defaultAddress = ref(null);
@@ -38,19 +42,6 @@ const getDefaultAddress = async () => {
}
};
-const getActiveAddresses = async () => {
- try {
- addresses.value = await jApi.query(
- `SELECT a.id, a.nickname, p.name province, a.postalCode, a.city, a.street, a.isActive
- FROM myAddress a
- LEFT JOIN vn.province p ON p.id = a.provinceFk
- WHERE a.isActive`
- );
- } catch (error) {
- console.error('Error getting active addresses:', error);
- }
-};
-
const changeDefaultAddress = async () => {
if (!clientId.value) return;
await jApi.execQuery(
@@ -77,7 +68,7 @@ const removeAddress = async id => {
id
}
);
- getActiveAddresses();
+ fetchAddressesRef.value.fetch();
notify(t('dataSaved'), 'positive');
} catch (error) {
console.error('Error removing address:', error);
@@ -86,11 +77,28 @@ const removeAddress = async id => {
onMounted(async () => {
getDefaultAddress();
- getActiveAddresses();
});
+ (addresses = data)"
+ />