Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: useUser #582

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/composables/src/composables/useUser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ interface UseUserFactoryParams<USER, UPDATE_USER_PARAMS, REGISTER_USER_PARAMS>
}) => Promise<USER>;
}

/**
* @deprecated since version <version?>
*
* @see <add docs link>
*/
const factoryParams: UseUserFactoryParams<
any,
UpdateCustomerEmailMutationVariables,
Expand Down Expand Up @@ -175,6 +180,7 @@ CustomerCreateInput

return factoryParams.load(context);
},

changePassword: async (context: Context, params) => {
Logger.debug('[Magento] changing user password');
const { data, errors } = await context.$magento.api.changeCustomerPassword(params);
Expand Down
4 changes: 4 additions & 0 deletions packages/composables/src/helpers/userDataGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { CustomerUpdateParameters } from '@vue-storefront/magento-api';

/**
* @deprecated
* @use packages/theme/helpers/customer/userDataGenerator.ts
*/
export const generateUserData = (userData): CustomerUpdateParameters => {
const baseData = {
email: userData.email,
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/components/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ import {
useCart,
useCategorySearch,
useFacet,
useUser,
wishlistGetters,
} from '@vue-storefront/magento';
import {
Expand All @@ -197,6 +196,7 @@ import {
useUiHelpers,
useUiState,
useWishlist,
useUser,
} from '~/composables';
import StoreSwitcher from '~/components/StoreSwitcher.vue';

Expand Down
3 changes: 1 addition & 2 deletions packages/theme/components/BottomNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@

<script>
import { SfBottomNavigation, SfIcon, SfCircleIcon } from '@storefront-ui/vue';
import { useUser } from '@vue-storefront/magento';
import { defineComponent, useRouter, useContext } from '@nuxtjs/composition-api';
import { useUiState } from '~/composables';
import { useUiState, useUser } from '~/composables';
import MobileMenuSidebar from '~/components/MobileMenuSidebar.vue';

export default defineComponent({
Expand Down
9 changes: 6 additions & 3 deletions packages/theme/components/CartSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,15 @@ import {
} from '@nuxtjs/composition-api';
import {
useCart,
useUser,
cartGetters,
useExternalCheckout,
} from '@vue-storefront/magento';
import _debounce from 'lodash.debounce';
import { useUiState, useUiNotification } from '~/composables';
import {
useUiState,
useUiNotification,
useUser,
useExternalCheckout,
} from '~/composables';
import stockStatusEnum from '~/enums/stockStatusEnum';
import CouponCode from './CouponCode.vue';

Expand Down
4 changes: 2 additions & 2 deletions packages/theme/components/LoginModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ import {
} from '@storefront-ui/vue';
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate';
import { required, email } from 'vee-validate/dist/rules';
import { useUser, useForgotPassword } from '@vue-storefront/magento';
import { useUiState, useWishlist } from '~/composables';
import { useForgotPassword } from '@vue-storefront/magento';
import { useUiState, useWishlist, useUser } from '~/composables';
import { customerPasswordRegExp, invalidPasswordMsg } from '~/helpers/customer/regex';

extend('email', {
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/components/MyAccount/ProfileUpdateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
<script>
import { defineComponent, ref } from '@nuxtjs/composition-api';
import { ValidationProvider, ValidationObserver } from 'vee-validate';
import { useUser, userGetters } from '@vue-storefront/magento';
import { userGetters } from '@vue-storefront/magento';
import {
SfInput,
SfButton,
SfModal,
} from '@storefront-ui/vue';
import { useUiNotification } from '~/composables';
import { useUiNotification, useUser } from '~/composables';

export default defineComponent({
name: 'ProfileUpdateForm',
Expand Down
3 changes: 2 additions & 1 deletion packages/theme/components/ProductAddReviewForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ import {
useContext,
} from '@nuxtjs/composition-api';
import {
reviewGetters, useReview, userGetters, useUser,
reviewGetters, useReview, userGetters,
} from '@vue-storefront/magento';
import { extend, ValidationObserver, ValidationProvider } from 'vee-validate';
import { min, oneOf, required } from 'vee-validate/dist/rules';
Expand All @@ -131,6 +131,7 @@ import {
SfSelect,
SfTextarea,
} from '@storefront-ui/vue';
import { useUser } from '~/composables';

extend('required', {
...required,
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/components/ProductsCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ import {
} from '@storefront-ui/vue';

import {
productGetters, useUser,
productGetters,
} from '@vue-storefront/magento';
import { computed, defineComponent } from '@nuxtjs/composition-api';
import { useAddToCart } from '~/helpers/cart/addToCart';
import { useImage, useWishlist } from '~/composables';
import { useImage, useWishlist, useUser } from '~/composables';

export default defineComponent({
name: 'ProductsCarousel',
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/components/SearchResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ import {
computed,
defineComponent,
} from '@nuxtjs/composition-api';
import { productGetters, useUser } from '@vue-storefront/magento';
import { useUiHelpers, useImage, useWishlist } from '~/composables';
import { productGetters } from '@vue-storefront/magento';
import { useUiHelpers, useImage, useWishlist, useUser } from '~/composables';

export default defineComponent({
name: 'SearchResults',
Expand Down
5 changes: 3 additions & 2 deletions packages/theme/components/WishlistSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ import {
} from '@storefront-ui/vue';
import { computed, defineComponent, onMounted } from '@nuxtjs/composition-api';
import {
useUser,
wishlistGetters,
productGetters,
} from '@vue-storefront/magento';
import { useUiState, useImage, useWishlist } from '~/composables';
import {
useUiState, useImage, useWishlist, useUser,
} from '~/composables';

export default defineComponent({
name: 'WishlistSidebar',
Expand Down
1 change: 1 addition & 0 deletions packages/theme/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { default as useStore } from './useStore';
export { default as useCurrency } from './useCurrency';
export { default as useExternalCheckout } from './useExternalCheckout';
export { default as useWishlist } from './useWishlist';
export { default as useUser } from './useUser';
Loading