Skip to content

Commit

Permalink
fix: m2-613. fixed order details 500 error (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frodigo committed Jul 4, 2022
1 parent 543e165 commit 56f2b0e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ import {
SfLoader,
SfHeading,
} from '@storefront-ui/vue';
import { defineComponent, useAsync, useContext } from '@nuxtjs/composition-api';
import {
defineComponent, useAsync, useContext, useRouter,
} from '@nuxtjs/composition-api';
import { useUserOrder } from '~/modules/customer/composables/useUserOrder';
import orderGetters from '~/modules/checkout/getters/orderGetters';
import { useCountrySearch } from '~/composables';
Expand All @@ -157,12 +159,19 @@ export default defineComponent({
props: { orderId: { type: String, required: true } },
setup(props) {
const context = useContext();
const router = useRouter();
const { search, loading } = useUserOrder();
const { search: searchCountries } = useCountrySearch();
const asyncData = useAsync(async () => {
const orderResult = await search({ filter: { number: { eq: props.orderId } } });
const order = orderResult.items[0] ?? null;
if (!order) {
router.push(context.localeRoute({ name: 'customer-order-history' }));
return null;
}
const uniqueCountryCodePromises = [...new Set([order.shipping_address.country_code, order.billing_address.country_code])]
.map((countryCode) => searchCountries({ id: countryCode }));
const countries = await Promise.all(uniqueCountryCodePromises);
Expand Down

0 comments on commit 56f2b0e

Please sign in to comment.