Skip to content
This repository has been archived by the owner on May 21, 2020. It is now read-only.

Integrated basic info with API #236

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Empty file.
18 changes: 18 additions & 0 deletions packages/commercetools/api-client/src/api/getMe/defaultQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ const fullProfile = gql`
}
customer {
...DefaultCustomer
addresses {
defudef marked this conversation as resolved.
Show resolved Hide resolved
id
title
firstName
lastName
streetName
streetNumber
postalCode
city
region
state
country
apartment
contactInfo {
phone
}
}
shippingAddressIds
defudef marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
116 changes: 51 additions & 65 deletions packages/core/theme-module/theme/pages/MyAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
</template>
<script>
import { SfBreadcrumbs, SfContentPages } from '@storefront-ui/vue';
import { useUser } from '@vue-storefront/commercetools-composables';
import { computed } from '@vue/composition-api';
import MyProfile from './MyAccount/MyProfile';
import ShippingDetails from './MyAccount/ShippingDetails';
import LoyaltyCard from './MyAccount/LoyaltyCard';
Expand All @@ -64,79 +66,63 @@ export default {
OrderHistory,
MyReviews
},
data() {
return {
breadcrumbs: [
{
text: 'Home',
route: {
link: '#'
}
},
{
text: 'My Account',
route: {
link: '#'
}
setup(props, { root }) {
const { user } = useUser();
const breadcrumbs = [
{
text: 'Home',
route: {
link: '#'
}
},
{
text: 'My Account',
route: {
link: '#'
}
],
account: {
firstName: 'Sviatlana',
lastName: 'Havaka',
email: '[email protected]',
password: 'a*23Et',
shipping: [
{
firstName: 'Sviatlana',
lastName: 'Havaka',
streetName: 'Zielinskiego',
apartment: '24/193A',
city: 'Wroclaw',
state: 'Lower Silesia',
zipCode: '53-540',
country: 'Poland',
phoneNumber: '(00)560 123 456'
},
{
firstName: 'Sviatlana',
lastName: 'Havaka',
streetName: 'Zielinskiego',
apartment: '20/193A',
city: 'Wroclaw',
state: 'Lower Silesia',
zipCode: '53-603',
country: 'Poland',
phoneNumber: '(00)560 123 456'
}
],
orders: [
['#35765', '4th Nov, 2019', 'Visa card', '$12.00', 'In process'],
['#35766', '4th Nov, 2019', 'Paypal', '$12.00', 'Finalised'],
['#35768', '4th Nov, 2019', 'Mastercard', '$12.00', 'Finalised'],
['#35769', '4th Nov, 2019', 'Paypal', '$12.00', 'Finalised']
]
}
};
},
computed: {
activePage() {
const { pageName } = this.$route.params;
];

if (pageName) {
return (pageName.charAt(0).toUpperCase() + pageName.slice(1)).replace('-', ' ');
}
const activePage = computed(() => {
const { pageName } = root.$route.params;

return 'My profile';
}
},
methods: {
changeActivePage(title) {
return pageName
? (pageName.charAt(0).toUpperCase() + pageName.slice(1)).replace('-', ' ')
: 'My profile';
});

const changeActivePage = (title) => {
if (title === 'Log out') {
return;
}

this.$router.push(`/my-account/${title.toLowerCase().replace(' ', '-')}`);
}
root.$router.push(`/my-account/${title.toLowerCase().replace(' ', '-')}`);
};

const getShippingAddresses = () => (
defudef marked this conversation as resolved.
Show resolved Hide resolved
(user.value.addresses || []).filter(address => (user.value.shippingAddressIds || []).includes(address.id))
);

const account = computed(() => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you can't just pass account and avoid additional code while its not doing anything meaningful?

firstName: user.value.firstName,
lastName: user.value.lastName,
email: user.value.email,
shipping: getShippingAddresses(),
orders: [
['#35765', '4th Nov, 2019', 'Visa card', '$12.00', 'In process'],
['#35766', '4th Nov, 2019', 'Paypal', '$12.00', 'Finalised'],
['#35768', '4th Nov, 2019', 'Mastercard', '$12.00', 'Finalised'],
['#35769', '4th Nov, 2019', 'Paypal', '$12.00', 'Finalised']
]
}));

return {
user,
account,
breadcrumbs,
changeActivePage,
activePage
};
}
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<p class="message">
If you want to change the password to access your account, enter the
following information:<br />Your current email address is
<span class="message__label">[email protected]</span>
<span class="message__label">{{account.email}}</span>
</p>
<ValidationObserver v-slot="{ handleSubmit }">
<form class="form" @submit.prevent="handleSubmit(updatePassword)">
Expand Down
Loading