From 663486c9d077a9e676a9bf7b64e667125012ec02 Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Thu, 23 Jun 2022 17:04:28 +0200 Subject: [PATCH] fix: my account - display country names, not codes M2-859 --- .../AddressesDetails/AddressesDetails.vue | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/theme/modules/customer/pages/MyAccount/AddressesDetails/AddressesDetails.vue b/packages/theme/modules/customer/pages/MyAccount/AddressesDetails/AddressesDetails.vue index ef53db35c..f5efb8ccc 100644 --- a/packages/theme/modules/customer/pages/MyAccount/AddressesDetails/AddressesDetails.vue +++ b/packages/theme/modules/customer/pages/MyAccount/AddressesDetails/AddressesDetails.vue @@ -52,13 +52,17 @@ class="addresses-list" >
- + + +
@@ -103,6 +107,7 @@ import { useRouter, useContext, ref, + computed, useFetch, } from '@nuxtjs/composition-api'; import { useAddresses } from '~/modules/customer/composables/useAddresses'; @@ -111,6 +116,8 @@ import SvgImage from '~/components/General/SvgImage.vue'; import UserAddressDetails from '~/components/UserAddressDetails.vue'; import { CustomerAddress } from '~/modules/GraphQL/types'; import SkeletonLoader from '~/components/SkeletonLoader/index.vue'; +import { useCountrySearch } from '~/composables/useCountrySearch'; +import type { Country } from '~/modules/GraphQL/types'; export default defineComponent({ name: 'AddressesDetails', @@ -126,10 +133,14 @@ export default defineComponent({ const router = useRouter(); const userAddresses = ref([]); + const countries = ref([]); const { load, remove } = useAddresses(); + const { load: loadCountries } = useCountrySearch(); + const { fetch } = useFetch(async () => { - const addressesData = await load(); - userAddresses.value = userAddressesGetters.getAddresses(addressesData); + const [addressesResponse, countriesResponse] = await Promise.all([load(), loadCountries()]); + userAddresses.value = userAddressesGetters.getAddresses(addressesResponse); + countries.value = countriesResponse; }); const goToCreateAddressPage = () => router.push( @@ -145,8 +156,18 @@ export default defineComponent({ fetch(); }; + const addressesWithCountryName = computed(() => userAddresses.value.map((address) => ({ + ...address, + countryName: countries.value + .find(({ id }) => id === address.country_code) + ?.full_name_locale + ?? address.country_code, + }))); + return { + countries, userAddresses, + addressesWithCountryName, goToCreateAddressPage, goToEditAddressPage, removeAddress,